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.demo.FakeAuthorizator.java

private void doGet(String url) {
    System.out.println("try to send to " + url);
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity<String> entity = new HttpEntity<String>(headers);
    ResponseEntity<String> rese = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
    System.out.println("RESPONSE STRING " + rese.getBody());
}

From source file:fi.helsinki.opintoni.server.CoursePageServer.java

public void expectCourseImplementationActivityRequest(List<String> courseImplementationIds,
        String responseFile) {/*from w  w w .  j  av a 2  s.  c  o  m*/
    server.expect(requestTo(new UserNotificationServiceTest.ActivityUrlMatcher(coursePageBaseUrl,
            courseImplementationIdsToString(courseImplementationIds)))).andExpect(method(HttpMethod.GET))
            .andRespond(withSuccess(SampleDataFiles.toText("coursepage/" + responseFile),
                    MediaType.APPLICATION_JSON));
}

From source file:com.epam.ta.reportportal.core.externalsystem.ExternalSystemEurekaDelegate.java

@Override
public List<PostFormField> getTicketFields(String issueType, ExternalSystem system) {
    return eurekaTemplate.exchange(
            getServiceInstance(system.getExternalSystemType()).getUri().toString()
                    + "/{systemId}/ticket/{issueType}/fields",
            HttpMethod.GET, null, new ParameterizedTypeReference<List<PostFormField>>() {
            }, system.getId(), issueType).getBody();
}

From source file:com.orange.ngsi2.client.Ngsi2ClientTest.java

@Test
public void testGetV2_ClientError() throws Exception {
    thrown.expect(Ngsi2Exception.class);
    thrown.expectMessage("error: 400 | description: Bad Request | affectedItems: []");

    mockServer.expect(requestTo(baseURL + "/v2")).andExpect(method(HttpMethod.GET))
            .andRespond(withBadRequest().body(Utils.loadResource("json/error400Response.json")));

    ngsiClient.getV2().get();/*from  w  w w  .j  a va 2 s .c  om*/
}

From source file:demo.RestServiceIntegrationTests.java

@Test
public void findByLocation() {
    TestRestTemplate template = new TestRestTemplate();
    ResponseEntity<Resource<ServiceLocation>> result = template.exchange(
            "http://localhost:" + this.port
                    + "/serviceLocations/search/findFirstByLocationNear?location={lat},{long}",
            HttpMethod.GET, new HttpEntity<Void>((Void) null),
            new ParameterizedTypeReference<Resource<ServiceLocation>>() {
            }, 39, -84);// w w w.j av  a 2s  .  c  om
    assertEquals(HttpStatus.OK, result.getStatusCode());
}

From source file:com.codeabovelab.dm.cluman.cluster.registry.DockerRegistryAuthAdapter.java

@SuppressWarnings("unchecked")
private String getToken(AuthInfo authInfo) {
    RegistryCredentials registryCredentials = provider.getRegistryCredentials();
    // realm="https://auth.docker.io/token",service="registry.docker.io"
    // get https://auth.docker.io/token?service=registry.docker.io
    try {// ww w . j  a  v a 2  s.  com
        URI path = getPath(authInfo);
        HttpEntity<String> request = null;
        if (checkCredentials()) {
            request = new HttpEntity<>(createHeaders(registryCredentials));
        }
        Map<String, String> token = restTemplate.exchange(path, HttpMethod.GET, request, Map.class).getBody();

        if (!token.isEmpty()) {
            return token.get("token");
        }
    } catch (HttpClientErrorException e) {
        log.error("Can't do request " + e.getResponseBodyAsString(), e);
    } catch (Exception e) {
        log.error("Can't do request", e);
    }
    return null;
}

From source file:org.moserp.product.rest.ProductController.java

@ResponseBody
@RequestMapping(method = RequestMethod.GET, value = "/{productId}/quantityOnHand")
public Quantity getProductQuantityOnHand(@RequestHeader(value = "Authorization") String authorization,
        @PathVariable String productId) {
    if (!moduleRegistry.isModuleRegistered(OtherResources.MODULE_INVENTORY)) {
        return Quantity.ZERO;
    }//from   www.j a  va2s  .com
    HttpHeaders headers = new HttpHeaders();
    headers.put("Authorization", Collections.singletonList(authorization));
    HttpEntity request = new HttpEntity(headers);
    String url = "http://" + OtherResources.MODULE_INVENTORY + "/" + OtherResources.PRODUCTS + "/" + productId
            + "/quantityOnHand";
    ResponseEntity<Quantity> responseEntity = restTemplate.exchange(url, HttpMethod.GET, request,
            Quantity.class);
    return responseEntity.getBody();
}

From source file:com.capitalone.dashboard.collector.DefaultNexusIQClientTest.java

@Test
public void getApplicationsEmpty() throws Exception {
    settings.setSelectStricterLicense(true);
    String appJson = getJson("applications.json");

    String instanceUrl = "http://nexusiq.com";
    String appListUrl = "http://nexusiq.com/api/v2/applications";

    doReturn(new ResponseEntity<>("", HttpStatus.OK)).when(rest).exchange(eq(appListUrl), eq(HttpMethod.GET),
            Matchers.any(HttpEntity.class), eq(String.class));
    List<NexusIQApplication> apps = defaultNexusIQClient.getApplications(instanceUrl);
    assertThat(apps.size(), is(0));//from  ww w.  j  a  va  2 s.c  om
}

From source file:com.appglu.impl.PushTemplateTest.java

@Test
public void readDeviceNotFound() {
    mockServer.expect(requestTo("http://localhost/appglu/v1/push/device/f3f71c5a-0a98-48f7-9acd-d38d714d76ad"))
            .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)
                    .body(compactedJson("data/error_not_found")).headers(responseHeaders));

    Device device = pushOperations.readDevice("f3f71c5a-0a98-48f7-9acd-d38d714d76ad");
    Assert.assertNull(device);//from   ww w  . j av  a 2 s .c o  m

    mockServer.verify();
}

From source file:fi.okm.mpass.shibboleth.profile.impl.BuildMetaRestResponseTest.java

/**
 * Initialize test variables./*from  w  ww. ja v a2 s  .c  om*/
 * @throws ComponentInitializationException
 */
@BeforeMethod
public void initTests() throws ComponentInitializationException {
    entityId = "mockEntityId";
    metadataUrl = "mockMetadataUrl";
    organization = "mockOrganization";
    name = "mockName";
    id = "mockId";
    description = "mockDescription";
    countryCode = "fi";
    email = "mock.email@example.org";
    action = new BuildMetaRestResponse();
    final MockHttpServletRequest httpRequest = new MockHttpServletRequest();
    httpRequest.setMethod(HttpMethod.GET.toString());
    action.setHttpServletRequest(httpRequest);
    action.setHttpServletResponse(new MockHttpServletResponse());
}