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:org.zalando.github.spring.IssuesTemplate.java

@Override
public List<Issue> listOrganizationIssues(String organization) {
    Map<String, Object> uriVariables = new HashMap<>();
    uriVariables.put("organization", organization);
    return getRestOperations().exchange(buildUri("/orgs/{organization}/issues?per_page=25", uriVariables),
            HttpMethod.GET, null, issueListTypeRef).getBody();
}

From source file:svc.data.citations.datasources.tyler.TylerCitationDataSourceTest.java

@SuppressWarnings("unchecked")
@Test//from   ww  w.j  a v  a 2 s .co  m
public void returnsCitationsGivenCitationNumberAndDOB() {
    final String CITATIONNUMBER = "F3453";
    final LocalDate DOB = LocalDate.parse("2000-06-01");
    mockTylerConfiguration.rootUrl = "http://myURL.com";
    mockTylerConfiguration.apiKey = "1234";
    final Citation CITATION = new Citation();
    CITATION.id = 3;
    final List<Citation> CITATIONS = Lists.newArrayList(CITATION);
    final List<TylerCitation> tylerCitations = Lists.newArrayList();
    Mockito.doReturn(tylerCitations).when(tylerCitationsResponseSpy).getBody();

    when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET), any(HttpEntity.class),
            any(ParameterizedTypeReference.class))).thenReturn(tylerCitationsResponseSpy);

    when(mockCitationTransformer.fromTylerCitations(tylerCitations)).thenReturn(CITATIONS);
    when(mockCitationFilter.RemoveCitationsWithExpiredDates(CITATIONS)).thenReturn(CITATIONS);

    List<Citation> citations = mockTylerCitationDataSource.getByCitationNumberAndDOB(CITATIONNUMBER, DOB);

    assertThat(citations.get(0).id, is(3));
}

From source file:org.openlmis.fulfillment.service.referencedata.OrderableReferenceDataServiceTest.java

@Test
public void shouldReturnOrderablesById() {
    OrderableDto product = mockPageResponseEntityAndGetDto();

    UUID orderableId = UUID.randomUUID();
    List<OrderableDto> response = service.findByIds(Collections.singleton(orderableId));

    assertThat(response, hasSize(1));/* w  w  w .  j  a  va 2 s.  co m*/
    assertThat(response, hasItem(product));

    verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(),
            refEq(new DynamicPageTypeReference<>(OrderableDto.class)));

    URI uri = uriCaptor.getValue();
    assertEquals(serviceUrl + service.getUrl() + "?id=" + orderableId.toString(), uri.toString());

    assertAuthHeader(entityCaptor.getValue());
    assertNull(entityCaptor.getValue().getBody());
}

From source file:io.fabric8.che.starter.client.CheRestClient.java

public List<Workspace> listWorkspaces(String cheServerURL) {
    String url = generateURL(cheServerURL, CheRestEndpoints.LIST_WORKSPACES);
    RestTemplate template = new RestTemplate();
    ResponseEntity<List<Workspace>> response = template.exchange(url, HttpMethod.GET, null,
            new ParameterizedTypeReference<List<Workspace>>() {
            });//from www.  java2  s  . c o m

    List<Workspace> workspaces = response.getBody();
    for (Workspace workspace : workspaces) {
        workspace.setName(workspace.getConfig().getName());
        workspace.setDescription(workspace.getConfig().getDescription());

        for (WorkspaceLink link : workspace.getLinks()) {
            if (WORKSPACE_LINK_IDE_URL.equals(link.getRel())) {
                workspace.setWorkspaceIdeUrl(link.getHref());
                break;
            }
        }
    }
    return workspaces;
}

From source file:pl.hycom.jira.plugins.gitlab.integration.dao.CommitRepository.java

@Override
public Commit getOneCommit(ConfigEntity configEntity, String shaSum) {
    HttpEntity<?> requestEntity = new HttpEntity<>(
            new TemplateFactory().getHttpHeaders().setAuth(configEntity.getClientId()).build());
    ResponseEntity<Commit> response = new TemplateFactory().getRestTemplate().exchange(
            configEntity.getLink() + COMMIT_SINGLE_URL, HttpMethod.GET, requestEntity,
            new ParameterizedTypeReference<Commit>() {
            }, shaSum);/*from  w  ww.  j a v  a2  s  .co  m*/

    return response.getBody();
}

From source file:fi.helsinki.opintoni.integration.coursepage.CoursePageRestClient.java

@Cacheable(CacheConstants.COURSE_PAGE)
public CoursePageCourseImplementation getCoursePage(String courseImplementationId) {
    return restTemplate
            .exchange("{baseUrl}/course_implementations?course_implementation_id={courseImplementationId}",
                    HttpMethod.GET, null, new ParameterizedTypeReference<CoursePageCourseImplementation>() {
                    }, baseUrl, courseImplementationId)
            .getBody();/*from   w w w.j a v  a  2s .c o m*/
}

From source file:org.zalando.github.spring.OrganizationTemplateTest.java

@Test
public void listOrganizationsForCurrentUser() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/user/orgs?per_page=25"))
            .andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("listOrgas.json", getClass()),
                    MediaType.APPLICATION_JSON));

    List<Organization> emailList = usersTemplate.listOrganizations();

    Assertions.assertThat(emailList).isNotNull();
    Assertions.assertThat(emailList.size()).isEqualTo(1);
}

From source file:org.moserp.inventory.rest.BaseWebInventoryTest.java

protected void checkInventory(String productUri, String facilityUri, int quantity) {
    String url = facilityUri + "/inventoryItems?productId=" + getProductIdFromUri(productUri);
    ParameterizedTypeReference<Resources<InventoryItem>> responseType = new ParameterizedTypeReference<Resources<InventoryItem>>() {
    };//from w w  w  .  j a  va 2  s .c om
    Resources<InventoryItem> inventories = restTemplate.exchange(url, HttpMethod.GET, null, responseType)
            .getBody();
    InventoryItem inventory = inventories.getContent().iterator().next();
    assertNotNull("environment", inventory);
    assertEquals("Inventory quantity", quantity, inventory.getQuantityOnHand().intValue());
}

From source file:edu.infsci2560.AboutIT.java

@Test
public void testAboutPageValid() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    ResponseEntity<String> entity = this.restTemplate.exchange("/about.html", HttpMethod.GET,
            new HttpEntity<>(headers), String.class);
    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
    PageHtmlValidator.validatePage(entity.getBody());
}

From source file:sample.undertow.SampleUndertowApplicationTests.java

@Test
public void testCompression() throws Exception {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("Accept-Encoding", "gzip");
    HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
    RestTemplate restTemplate = new TestRestTemplate();
    ResponseEntity<byte[]> entity = restTemplate.exchange("http://localhost:" + this.port, HttpMethod.GET,
            requestEntity, byte[].class);
    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
    GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()));
    try {//  ww w . j a  v  a  2  s  .c  o  m
        assertThat(StreamUtils.copyToString(inflater, Charset.forName("UTF-8"))).isEqualTo("Hello World");
    } finally {
        inflater.close();
    }
}