public Mono<ResponseEntity<T>> patch() { RequestEntity<Object> requestEntity = headers(RequestEntity.patch(uri)) .body(body()); return exchange(requestEntity); }
public ResponseEntity<T> patch() { RequestEntity<Object> requestEntity = headers(RequestEntity.patch(uri)) .body(body()); return exchange(requestEntity); }
@Test public void methods() throws URISyntaxException { URI url = new URI("http://example.com"); RequestEntity<?> entity = RequestEntity.get(url).build(); assertEquals(HttpMethod.GET, entity.getMethod()); entity = RequestEntity.post(url).build(); assertEquals(HttpMethod.POST, entity.getMethod()); entity = RequestEntity.head(url).build(); assertEquals(HttpMethod.HEAD, entity.getMethod()); entity = RequestEntity.options(url).build(); assertEquals(HttpMethod.OPTIONS, entity.getMethod()); entity = RequestEntity.put(url).build(); assertEquals(HttpMethod.PUT, entity.getMethod()); entity = RequestEntity.patch(url).build(); assertEquals(HttpMethod.PATCH, entity.getMethod()); entity = RequestEntity.delete(url).build(); assertEquals(HttpMethod.DELETE, entity.getMethod()); }
@Override public Team updateTeam(long teamId, TeamRequest teamRequest) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("teamid", teamId); RequestEntity<TeamRequest> entity = RequestEntity.patch(buildUri("/teams/{teamid}", uriVariables)) .contentType(MediaType.APPLICATION_JSON).body(teamRequest); return getRestTemplate().exchange(entity, Team.class).getBody(); }
@Override public ExtOrganization updateOrganization(OrganizationUpdate update, String organization) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("organization", organization); RequestEntity<OrganizationUpdate> entity = RequestEntity.patch(buildUri("/orgs/{organization}", uriVariables)) .contentType(MediaType.APPLICATION_JSON).body(update); return getRestTemplate().exchange(entity, ExtOrganization.class).getBody(); }
@Override public ExtOrganization updateOrganization(OrganizationUpdate update, String organization) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("organization", organization); RequestEntity<OrganizationUpdate> entity = RequestEntity.patch(buildUri("/orgs/{organization}", uriVariables)) .contentType(MediaType.APPLICATION_JSON).body(update); return getRestOperations().exchange(entity, ExtOrganization.class).getBody(); }
@Override public Team updateTeam(long teamId, TeamRequest teamRequest) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("teamid", teamId); RequestEntity<TeamRequest> entity = RequestEntity.patch(buildUri("/teams/{teamid}", uriVariables)) .contentType(MediaType.APPLICATION_JSON).body(teamRequest); return getRestOperations().exchange(entity, Team.class).getBody(); }
@Test public void shouldBeAbleToPatchBookingsUsingHoverfly() throws Exception { // Given final RequestEntity<String> bookFlightRequest = RequestEntity.patch(new URI("http://www.other-anotherservice.com/api/bookings/1")) .contentType(APPLICATION_JSON) .body("{\"class\": \"BUSINESS\"}"); // When // Apache HttpClient is required for making PATCH request using RestTemplate HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); restTemplate.setRequestFactory(requestFactory); final ResponseEntity<Void> bookFlightResponse = restTemplate.exchange(bookFlightRequest, Void.class); // Then assertThat(bookFlightResponse.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); }