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:com.nobu.dvdrentalweb.test.restapi.AccountRestControllerTest.java
public void testreadClubByNameName() { String accountName = "Savings"; HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Account> responseEntity = restTemplate.exchange(URL + "api/account/name/" + accountName, HttpMethod.GET, requestEntity, Account.class); Account account = responseEntity.getBody(); Assert.assertNotNull(account);// ww w .j av a 2 s. c o m }
From source file:org.openlmis.fulfillment.service.referencedata.PeriodReferenceDataServiceTest.java
@Test public void shouldReturnOrderablesById() { ProcessingPeriodDto period = mockPageResponseEntityAndGetDto(); String startDate = "2018-04-05"; String endDate = "2018-05-05"; List<ProcessingPeriodDto> response = service.search(LocalDate.parse(startDate), LocalDate.parse(endDate)); assertThat(response, hasSize(1));//from ww w .j a va 2s . c o m assertThat(response, hasItems(period)); verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(), refEq(new DynamicPageTypeReference<>(ProcessingPeriodDto.class))); URI uri = uriCaptor.getValue(); assertEquals(serviceUrl + service.getUrl() + "?startDate=" + startDate + "&endDate=" + endDate, uri.toString()); assertAuthHeader(entityCaptor.getValue()); assertNull(entityCaptor.getValue().getBody()); }
From source file:edu.wisc.cypress.dao.levstmt.RestLeaveStatementDao.java
@Override public void getLeaveStatement(String emplid, String docId, StatementType type, ProxyResponse proxyResponse) { final HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.set("HRID", emplid); this.restOperations.proxyRequest(proxyResponse, this.statementUrl, HttpMethod.GET, httpHeaders, docId, type.getKey());//from ww w . j ava 2 s .c o m }
From source file:org.moserp.inventory.rest.InventoryTest.java
@Test public void testInventoryItemsPerProduct() { InventoryTransfer inventoryTransfer = new InventoryTransfer(new ProductInstance(product), facility, mobileFacility, new Quantity(55)); restTemplate.postForLocation(testEnvironment.createRestUri("inventoryTransfers"), inventoryTransfer); Resources<InventoryItem> inventories = restTemplate.exchange( testEnvironment.createRestUri("inventoryItems/search/findByProductIdOrFacilityId?productId=1"), HttpMethod.GET, null, new ParameterizedTypeReference<Resources<InventoryItem>>() { }).getBody();/* w w w. java 2s . c o m*/ assertEquals("size", 2, inventories.getContent().size()); }
From source file:org.zalando.github.spring.MembersTemplateTest.java
@Test public void isMember() throws Exception { mockServer.expect(requestTo("https://api.github.com/orgs/zalando-stups/members/klaus")) .andExpect(method(HttpMethod.GET)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(withNoContent()); boolean answer = membersTemplate.isMemberOfOrganization("zalando-stups", "klaus"); Assertions.assertThat(answer).isTrue(); }
From source file:org.cloudfoundry.identity.uaa.login.feature.SamlLoginIT.java
@Test public void testContentTypes() throws Exception { String loginUrl = baseUrl + "/login"; HttpHeaders jsonHeaders = new HttpHeaders(); jsonHeaders.add("Accept", "application/json"); ResponseEntity<Map> jsonResponseEntity = restOperations.exchange(loginUrl, HttpMethod.GET, new HttpEntity<>(jsonHeaders), Map.class); assertThat(jsonResponseEntity.getHeaders().get("Content-Type").get(0), containsString(APPLICATION_JSON_VALUE)); HttpHeaders htmlHeaders = new HttpHeaders(); htmlHeaders.add("Accept", "text/html"); ResponseEntity<Void> htmlResponseEntity = restOperations.exchange(loginUrl, HttpMethod.GET, new HttpEntity<>(htmlHeaders), Void.class); assertThat(htmlResponseEntity.getHeaders().get("Content-Type").get(0), containsString(TEXT_HTML_VALUE)); HttpHeaders defaultHeaders = new HttpHeaders(); defaultHeaders.add("Accept", "*/*"); ResponseEntity<Void> defaultResponseEntity = restOperations.exchange(loginUrl, HttpMethod.GET, new HttpEntity<>(defaultHeaders), Void.class); assertThat(defaultResponseEntity.getHeaders().get("Content-Type").get(0), containsString(TEXT_HTML_VALUE)); }
From source file:khs.trouble.service.impl.TroubleService.java
public String kill(String serviceName, String instanceId, String ltoken) { if (token != ltoken) { throw new RuntimeException("Invalid Access Token"); }//w ww. j a v a2s . c om String url = FormatUrl.url(serviceInstanceURL(serviceName, instanceId) + "trouble/kill", ssl); // invoke kill api... RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_PLAIN)); headers.add("token", token); HttpEntity<String> entity = new HttpEntity<String>("parameters", headers); try { // int instanceCount = registry.instanceCount(serviceName); ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); if (result.getStatusCode() == HttpStatus.OK) { eventService.killed(serviceName, url); // monitorServiceRecovery(serviceName, instanceCount); } } catch (Exception e) { eventService.attempted("Attempted to Kill service " + serviceName + " at " + url + " Failed due to exception " + e.getMessage()); } return serviceName; }
From source file:sample.jetty.SampleJetty8ApplicationTests.java
@Test public void testHomeBasicAuthWrongCredentials403() throws Exception { ResponseEntity<String> entity = new TestRestTemplate().exchange( "http://localhost:" + this.port + "/static.html", HttpMethod.GET, new HttpEntity<String>(createHeaders("admin", "wrong-password")), String.class); assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode()); }
From source file:business.security.HttpSecurityConfiguration.java
@Override protected void configure(HttpSecurity http) throws Exception { http.exceptionHandling().authenticationEntryPoint(new Http403ForbiddenEntryPoint()).and() .userDetailsService(userDetailsService()).formLogin().permitAll() .failureHandler(authenticationFailureHandler).and().logout().permitAll() .logoutSuccessUrl("/#/login").and().authorizeRequests().antMatchers("/admin/**") .access("hasRole('palga')").and().authorizeRequests() .antMatchers("/", "/robots.txt", "/public/labs/**", "/password/request-new", "/password/reset", "/index.html", "/bower_components/**", "/app/**", "/js/**", "/messages/**", "/css/**", "/*.ico", "/images/**") .permitAll().antMatchers(HttpMethod.POST, "/register/users").permitAll() .antMatchers(HttpMethod.POST, "/register/users/**").permitAll() .antMatchers(HttpMethod.GET, "/register/users/activate/**").permitAll() .antMatchers(HttpMethod.GET, "/status").permitAll().antMatchers(HttpMethod.GET, "/ping").permitAll() .anyRequest().authenticated().and().addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class).csrf() .csrfTokenRepository(csrfTokenRepository()).and().headers() .addHeaderWriter(new StaticHeadersWriter("Content-Security-Policy-Report-Only", "default-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:")); }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * @return the list of supported operations under /v2 *//*from ww w . j a v a 2 s .c o m*/ public ListenableFuture<Map<String, String>> getV2() { ListenableFuture<ResponseEntity<JsonNode>> responseFuture = request(HttpMethod.GET, baseURL + "v2", null, JsonNode.class); return new ListenableFutureAdapter<Map<String, String>, ResponseEntity<JsonNode>>(responseFuture) { @Override protected Map<String, String> adapt(ResponseEntity<JsonNode> result) throws ExecutionException { Map<String, String> services = new HashMap<>(); result.getBody().fields() .forEachRemaining(entry -> services.put(entry.getKey(), entry.getValue().textValue())); return services; } }; }