List of usage examples for org.springframework.http HttpMethod GET
HttpMethod GET
To view the source code for org.springframework.http HttpMethod GET.
Click Source Link
From source file:fi.helsinki.opintoni.integration.coursepage.CoursePageRestClient.java
@Override public List<CoursePageNotification> getCoursePageNotifications(Set<String> courseImplementationIds, LocalDateTime from, Locale locale) { if (courseImplementationIds.isEmpty()) { return newArrayList(); }//from w w w .ja v a 2s. co m ResponseEntity<List<CoursePageNotification>> responseEntity = restTemplate.exchange( "{baseUrl}/course_implementation_activity" + "?course_implementation_id={courseImplementationIds}×tamp={from}&langcode={locale}", HttpMethod.GET, null, new ParameterizedTypeReference<List<CoursePageNotification>>() { }, baseUrl, courseImplementationIds.stream().collect(Collectors.joining(",")), from.format(DateFormatter.COURSE_PAGE_DATE_TIME_FORMATTER), locale.getLanguage()); return Optional.ofNullable(responseEntity.getBody()).orElse(newArrayList()); }
From source file:net.orpiske.tcs.client.services.TagCloudServiceClient.java
@Override public TagCloud requestTagCloud() { ResponseEntity<TagCloud> responseEntity = restTemplate.exchange(endPoint.getTagCloudServiceLocation(), HttpMethod.GET, new HttpEntity<Object>(getHeaders()), TagCloud.class); TagCloud tagCloud = responseEntity.getBody(); return tagCloud; }
From source file:org.trustedanalytics.h2oscoringengine.publisher.steps.CreatingPlanVisibilityStepTest.java
License:asdf
@Before public void setUp() { this.restTemplateMock = mock(RestTemplate.class); this.serviceGuidResponseMock = mock(ResponseEntity.class); when(restTemplateMock.exchange(eq(testCfServiceGuidEndpoint), same(HttpMethod.GET), eq(HttpCommunication.simpleJsonRequest()), same(String.class), eq(testServiceName))) .thenReturn(serviceGuidResponseMock); this.servicePlanResponseMock = mock(ResponseEntity.class); when(restTemplateMock.exchange(eq(testCfServicePlanEndpoint), same(HttpMethod.GET), eq(HttpCommunication.simpleJsonRequest()), same(String.class), eq(testServiceGuid))) .thenReturn(servicePlanResponseMock); }
From source file:com.iata.ndc.trial.controllers.DefaultController.java
@RequestMapping(value = "/ba", method = RequestMethod.GET) public String getCal() { RestTemplate restTemplate = new RestTemplate(); List<HttpMessageConverter<?>> converters = new ArrayList<>(); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.getObjectMapper().configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); converters.add(converter);//from www . j av a 2 s . com restTemplate.setMessageConverters(converters); HttpHeaders headers = new HttpHeaders(); headers.add("client-key", "zmd9apqgg2jwekf8zgqg5ybf"); headers.setContentType(MediaType.APPLICATION_JSON); ResponseEntity<BALocationsResponseWrapper> baLocationsResponse = restTemplate.exchange( "https://api.ba.com/rest-v1/v1/balocations", HttpMethod.GET, new HttpEntity<Object>(headers), BALocationsResponseWrapper.class); System.out.println(baLocationsResponse.getBody().getGetBALocationsResponse().getCountry().size()); return "index"; }
From source file:com.github.ffremont.microservices.springboot.manager.nexus.NexusClientApiTest.java
@Test public void testGetData() { String g = "gg", a = "aa", v = "1.0.0", c = "cc", p = "jar"; // init mock//from ww w . ja v a 2 s . c o m HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.parseMediaType(MediaType.APPLICATION_JSON.toString()))); HttpEntity<NexusDataResult> entity = new HttpEntity<>(headers); NexusDataResult nexusResult = new NexusDataResult(); nexusResult.setData(new NexusData()); ResponseEntity responseEntity = new ResponseEntity(nexusResult, HttpStatus.OK); when(this.nexusRestTemplate .exchange(prop.getBaseurl() + "/service/local/artifact/maven/resolve?r=snapshots&g=" + g + "&a=" + a + "&v=" + v + "&p=" + p + "&c=" + c, HttpMethod.GET, entity, NexusDataResult.class)) .thenReturn(responseEntity); NexusData r = nexus.getData(g, a, p, c, v); assertNotNull(r); }
From source file:com.sra.biotech.submittool.persistence.service.SubmissionServiceImpl.java
@Override public List<Submission> findAllSubmission() { HttpHeaders headers = new HttpHeaders(); headers.add("Accept", MediaType.APPLICATION_JSON_VALUE); HttpEntity<String> request = new HttpEntity<String>(headers); ResponseEntity<String> response = restTemplate.exchange(getSubmissionUrlTemplate(), HttpMethod.GET, request, String.class); String responseBody = response.getBody(); try {//from w w w .j a v a2 s . c om if (RestUtil.isError(response.getStatusCode())) { ErrorResource error = objectMapper.readValue(responseBody, ErrorResource.class); throw new RestClientException("[" + error.getCode() + "] " + error.getMessage()); } else { SubmissionResources resources = objectMapper.readValue(responseBody, SubmissionResources.class); // SubmissionResources resources = restTemplate.getForObject(getSubmissionUrlTemplate(), SubmissionResources.class); if (resources == null || CollectionUtils.isEmpty(resources.getContent())) { return Collections.emptyList(); } Link listSelfLink = resources.getLink(Link.REL_SELF); Collection<SubmissionResource> content = resources.getContent(); if (!content.isEmpty()) { SubmissionResource firstSubmissionResource = content.iterator().next(); Link linkToFirstResource = firstSubmissionResource.getLink(Link.REL_SELF); System.out.println("href = " + linkToFirstResource.getHref()); System.out.println("rel = " + linkToFirstResource.getRel()); } return resources.unwrap(); // return resources; } } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.work.petclinic.SampleWebUiApplicationTests.java
@Test public void testLoginPage() throws Exception { ResponseEntity<String> page = sendRequest("http://localhost:" + this.port + "/login", HttpMethod.GET); assertEquals(HttpStatus.OK, page.getStatusCode()); assertTrue("Wrong content:\n" + page.getBody(), page.getBody().contains("_csrf")); }
From source file:org.appverse.web.framework.backend.frontfacade.rest.MvcExceptionHandlerTests.java
@Test public void test() throws Exception { // Login first TestLoginInfo loginInfo = login();//from ww w. ja va 2 s. c o m HttpHeaders headers = new HttpHeaders(); headers.set("Cookie", loginInfo.getJsessionid()); HttpEntity<String> entity = new HttpEntity<String>(headers); // Calling protected resource - requires CSRF token UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl("http://localhost:" + port + baseApiPath + "/hello") .queryParam(DEFAULT_CSRF_PARAMETER_NAME, loginInfo.getXsrfToken()); ResponseEntity<String> responseEntity = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET, entity, String.class); String data = responseEntity.getBody(); assertEquals("Hello World!", data); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); }
From source file:com.github.ffremont.microservices.springboot.node.services.MsService.java
/** * Retourne un MS/*from w ww .j av a 2 s.c o m*/ * * @param msName * @return */ public MicroServiceRest getMs(String msName) { MasterUrlBuilder builder = new MasterUrlBuilder(cluster, node, masterhost, masterPort, masterCR); builder.setUri(msName); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.parseMediaType(MS_JSON_TYPE_MIME))); HttpEntity<MicroServiceRest> entity = new HttpEntity<>(headers); ResponseEntity<MicroServiceRest> response = restTempate.exchange(builder.build(), HttpMethod.GET, entity, MicroServiceRest.class); return HttpStatus.OK.equals(response.getStatusCode()) ? response.getBody() : null; }
From source file:rest.ApplianceRestController.java
@Test public void testreadApplianceByNameName() { String clubName = "samsung"; HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Appliance> responseEntity = restTemplate.exchange(URL + "api/app/name/" + clubName, HttpMethod.GET, requestEntity, Appliance.class); Appliance app = responseEntity.getBody(); Assert.assertNotNull(app);//from w w w .ja v a 2 s . co m }