Example usage for org.springframework.http HttpMethod POST

List of usage examples for org.springframework.http HttpMethod POST

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod POST.

Prototype

HttpMethod POST

To view the source code for org.springframework.http HttpMethod POST.

Click Source Link

Usage

From source file:org.schedoscope.metascope.controller.MetascopeAdminControllerTest.java

@Test
public void sometest() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.set("Referer", "/test");
    HttpEntity<String> entity = new HttpEntity<String>("parameters", headers);

    ResponseEntity<String> response = this.restTemplate.exchange("/admin/sync", HttpMethod.POST, entity,
            String.class);
    assertEquals(302, response.getStatusCodeValue());
    assertTrue(response.getHeaders().get("Location").get(0).endsWith("/test"));
}

From source file:io.pivotal.strepsirrhini.chaoslemur.reporter.DataDogReporterTest.java

@Test
public void sendEvent() {
    this.mockServer.expect(requestTo(URI)).andExpect(method(HttpMethod.POST))
            .andRespond(withSuccess("resultSuccess", MediaType.TEXT_PLAIN));

    this.dataDog.sendEvent(new Event(UUID.randomUUID(), Collections.emptyList()));

    this.mockServer.verify();
}

From source file:ai.emot.api.impl.EmotionTemplate.java

@Override
public EmotionProfile getFaceImageEmotionProfile(BufferedImage image) {

    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.IMAGE_JPEG);
    HttpEntity<BufferedImage> entity = new HttpEntity<BufferedImage>(image, headers);

    ResponseEntity<EmotionProfile> response = restTemplate.exchange(apiBaseUrl + "/face/emotion",
            HttpMethod.POST, entity, EmotionProfile.class);
    return response.getBody();

}

From source file:com.consol.citrus.admin.connector.WebSocketPushMessageListenerTest.java

@Test
public void testOnInboundMessage() throws Exception {
    Message inbound = new DefaultMessage("Hello Citrus!");

    reset(restTemplate, context);//from w ww .  j  a va  2s. c  o m
    when(restTemplate.exchange(eq("http://localhost:8080/connector/message/inbound?processId=MySampleTest"),
            eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class))).thenAnswer(invocation -> {
                HttpEntity request = (HttpEntity) invocation.getArguments()[2];

                Assert.assertEquals(request.getBody().toString(), inbound.toString());

                return ResponseEntity.ok().build();
            });

    when(context.getVariables())
            .thenReturn(Collections.singletonMap(Citrus.TEST_NAME_VARIABLE, "MySampleTest"));
    when(context.getVariable(Citrus.TEST_NAME_VARIABLE)).thenReturn("MySampleTest");

    pushMessageListener.onInboundMessage(inbound, context);
    verify(restTemplate).exchange(eq("http://localhost:8080/connector/message/inbound?processId=MySampleTest"),
            eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class));
}

From source file:customer.springboot.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.GET, "/api/customer/**").hasRole("CUSTOMER_VIEW")
            .antMatchers(HttpMethod.POST, "/api/customer/**").hasRole("CUSTOMER_CREATE")
            .antMatchers(HttpMethod.DELETE, "/api/customer/**").hasRole("CUSTOMER_DELETE")
            .antMatchers(HttpMethod.PUT, "/api/customer/**").hasRole("CUSTOMER_UPDATE")
            .antMatchers(HttpMethod.GET, "/api/user/**").hasRole("USER_VIEW").antMatchers("/lib/**").permitAll()
            .antMatchers("/scripts/**").permitAll().anyRequest().authenticated().and().formLogin()
            .loginPage("/login.html").defaultSuccessUrl("/").loginProcessingUrl("/login").permitAll().and()
            .logout().permitAll().and().csrf().disable();
}

From source file:mynotesrzd.springboot.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.GET, "/api/mynotes/**").hasRole("MYNOTES_VIEW")
            .antMatchers(HttpMethod.POST, "/api/mynotes/**").hasRole("MYNOTES_CREATE")
            .antMatchers(HttpMethod.DELETE, "/api/mynotes/**").hasRole("MYNOTES_DELETE")
            .antMatchers(HttpMethod.PUT, "/api/mynotes/**").hasRole("MYNOTES_UPDATE")
            .antMatchers(HttpMethod.GET, "/api/user/**").hasRole("USER_VIEW").antMatchers("/lib/**").permitAll()
            .antMatchers("/scripts/**").permitAll().anyRequest().authenticated().and().formLogin()
            .loginPage("/login.html").defaultSuccessUrl("/").loginProcessingUrl("/login").permitAll().and()
            .logout().permitAll().and().csrf().disable();
}

From source file:fleetmgt.ApiControllerTest.java

@Test
public void shouldReturnFleetCalculation() throws Exception {
    //given//from  www.  j  a  v  a2  s  . c  o  m
    final FleetConstraints fleetConstraints = new FleetConstraints(new int[] { 15, 10 }, 12, 5);

    // when:
    final ResponseEntity<Map> response = testRestTemplate.exchange("/fleet-calculation", HttpMethod.POST,
            new HttpEntity<>(fleetConstraints), Map.class);

    // then:
    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(response.getBody()).isNotNull();
    assertThat(response.getBody()).containsKey("fleet_engineers");
    assertThat(response.getBody()).containsKey("fleet_manager_location");
}

From source file:com.playhaven.android.req.CustomEventRequest.java

public CustomEventRequest(CustomEvent... customEvents) throws PlayHavenException {
    super();//ww  w  .ja  va 2s  .c  o m
    if (customEvents.length == 0)
        throw new PlayHavenException("No custom event specified for request");

    this.customEvents = new JSONArray();
    for (CustomEvent event : customEvents)
        this.customEvents.add(event.toJSONObject());

    setMethod(HttpMethod.POST);
}

From source file:com.pepaproch.gtswsdlclient.AuthTokenProviderImplTest.java

/**
 * Test of getAuthorisationToken method, of class AuthTokenProviderImpl.
 *//*from   www  .j  av a  2  s. com*/
@Test
public void testGetAuthorisationToken() {

    AuthTokenProvider instance = new AuthTokenProviderImpl(BASE_URL, "test", "test", restTemplate, 1);
    mockServer = MockRestServiceServer.createServer(restTemplate);
    String authResponseBody = "{\"accessToken\" : \"testtoken\" }";
    this.mockServer.expect(requestTo(BASE_URL + AUTH_PATH)).andExpect(method(HttpMethod.POST))
            .andRespond(withSuccess(authResponseBody, MediaType.APPLICATION_JSON));

    String authorisationToken = instance.getAuthorisationToken().getToken();
    String authorisationToken2 = instance.getAuthorisationToken().getToken();
    this.mockServer.verify();
    assertEquals(authorisationToken, authorisationToken2);
}

From source file:org.n52.restfulwpsproxy.wps.ExecuteClient.java

public StatusInfoDocument asyncExecute(String processId, String executeDocument) {
    HttpEntity<String> requestEntity = new HttpEntity<String>(executeDocument, headers);
    return restTemplate.exchange(baseUrl, HttpMethod.POST, requestEntity, StatusInfoDocument.class).getBody();
}