Example usage for org.springframework.http HttpMethod GET

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

Introduction

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

Prototype

HttpMethod GET

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

Click Source Link

Usage

From source file:com.acc.test.UserWebServiceTest.java

@Test()
public void testGetUser_Success_JSON_Deep() {
    final HttpEntity<String> requestEntity = new HttpEntity<String>(getJSONHeaders());
    final ResponseEntity<CustomerData> response = template.exchange(
            "http://localhost:9001/rest/v1/users/{userid}", HttpMethod.GET, requestEntity, CustomerData.class,
            TestConstants.USERNAME);// w w w  .j av a2s.c o m
    assertEquals("application/json;charset=UTF-8", response.getHeaders().getContentType().toString());

    final CustomerData customer = response.getBody();
    assertEquals("Klaus Demokunde", customer.getName());
    assertEquals("demo", customer.getUid());
    assertNotNull(customer.getCurrency());
    assertNotNull(customer.getLanguage());
    assertNotNull(customer.getDefaultBillingAddress());
    assertNotNull(customer.getDefaultShippingAddress());
}

From source file:rest.ApplianceRestController.java

@Test
public void testgetAllAppliances() {
    HttpEntity<?> requestEntity = getHttpEntity();
    ResponseEntity<Appliance[]> responseEntity = restTemplate.exchange(URL + "api/app/allapps", HttpMethod.GET,
            requestEntity, Appliance[].class);
    Appliance[] apps = responseEntity.getBody();
    for (Appliance app : apps) {
        System.out.println("The Appliance brand is " + app.getBrand());

    }//  www  .j  ava2s. co m

    Assert.assertTrue(apps.length > 0);
}

From source file:eu.cloudwave.wp5.common.rest.BaseRestClientTest.java

@Test
public void testWithMultipleHeaders() throws UnsupportedEncodingException, IOException {
    mockServer.expect(requestTo(ANY_URL)).andExpect(method(HttpMethod.GET))
            .andExpect(header(HEADER_ONE_NAME, HEADER_ONE_VALUE))
            .andExpect(header(HEADER_TWO_NAME, HEADER_TWO_VALUE))
            .andExpect(header(HEADER_THREE_NAME, HEADER_THREE_VALUE))
            .andRespond(withSuccess(getResponseStub(), MediaType.APPLICATION_JSON));

    final ResponseEntity<String> responseEntity = restClientMock.get(ANY_URL, String.class,
            RestRequestHeader.of(HEADER_ONE_NAME, HEADER_ONE_VALUE),
            RestRequestHeader.of(HEADER_TWO_NAME, HEADER_TWO_VALUE),
            RestRequestHeader.of(HEADER_THREE_NAME, HEADER_THREE_VALUE));
    assertThat(responseEntity.getBody()).isEqualTo(getResponseStub());
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.steps.AppRouteCreatingStep.java

private String getAvailableDomain() throws IOException {
    String cfDomainsUrl = cfApiUrl + SHARED_DOMAINS_ENDPOINT;
    ResponseEntity<String> response = cfRestTemplate.exchange(cfDomainsUrl, HttpMethod.GET,
            HttpCommunication.simpleJsonRequest(), String.class);
    return JsonDataFetcher.getStringValue(response.getBody(), DOMAIN_JSON_PATH);
}

From source file:net.orpiske.tcs.client.services.TagCloudServiceClient.java

@Override
public DomainList requestDomainList() {
    ResponseEntity<DomainList> responseEntity = restTemplate.exchange(endPoint.getDomainListLocation(),
            HttpMethod.GET, new HttpEntity<Object>(getHeaders()), DomainList.class);

    return responseEntity.getBody();
}

From source file:org.shaigor.rest.retro.security.gateway.config.OAuth2SecurityConfigurer.java

@Override
public void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/login.jsp").permitAll().and().authorizeRequests()
            .expressionHandler(expressionHandler).anyRequest().hasRole("USER").and().authorizeRequests()
            .regexMatchers(HttpMethod.GET, "/word/list(\\?.*)?")
            .access("#oauth2.hasScope('words') and hasRole('ROLE_USER') "
                    //+ "and hasAnyRole('"+ ROLE_WORDS_DEMO +"','" + ROLE_WORDS_PRODUCTION +"') " 
                    + "and #wordsServiceAuthorizer.accessAllowed()")
            .and().exceptionHandling().accessDeniedPage("/login.jsp?authorization_error=true").and()
            // TODO: put CSRF protection back into this endpoint
            .csrf().requireCsrfProtectionMatcher(new AntPathRequestMatcher("/oauth/authorize")).disable()
            .logout().logoutSuccessUrl("/index.jsp").logoutUrl("/logout.do").and().formLogin()
            .usernameParameter("j_username").passwordParameter("j_password")
            .failureUrl("/login.jsp?authentication_error=true").loginPage("/login.jsp")
            .loginProcessingUrl("/j_spring_security_check");
}

From source file:it.reply.orchestrator.service.CmdbServiceImpl.java

@Override
public List<Image> getImagesByService(String serviceId) {
    ResponseEntity<CmdbHasManyList<CmdbRow<Image>>> response = restTemplate.exchange(
            url.concat(serviceIdUrlPath).concat(serviceId).concat("/has_many/images?include_docs=true"),
            HttpMethod.GET, null, new ParameterizedTypeReference<CmdbHasManyList<CmdbRow<Image>>>() {
            });/*from  w ww  .j ava  2  s  . c o  m*/

    if (response.getStatusCode().is2xxSuccessful()) {
        return response.getBody().getRows().stream().map(e -> e.getDoc()).collect(Collectors.toList());
    }
    throw new DeploymentException("Unable to find images for service <" + serviceId + "> in the CMDB."
            + response.getStatusCode().toString() + " " + response.getStatusCode().getReasonPhrase());
}

From source file:com.bradley.musicapp.test.restapi.TrackRestControllerTest.java

public void testreadTrackByNameName() {
    String trackName = "yolo";
    HttpEntity<?> requestEntity = getHttpEntity();
    ResponseEntity<Track> responseEntity = restTemplate.exchange(URL + "api/track/name/" + trackName,
            HttpMethod.GET, requestEntity, Track.class);
    Track track = responseEntity.getBody();

    Assert.assertNotNull(track);/*from   ww w .j a  v a2  s  .c  om*/

}