List of usage examples for org.springframework.http HttpEntity getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:gateway.test.ServiceTests.java
/** * Test PUT /service/{serviceId}// w ww . j a v a 2s .co m */ @Test public void testUpdateMetadata() { // Mock HttpEntity<Service> request = new HttpEntity<Service>(null, null); doReturn(new ResponseEntity<PiazzaResponse>(new SuccessResponse("Yes", "Gateway"), HttpStatus.OK)) .when(restTemplate).exchange(any(String.class), eq(HttpMethod.PUT), any(request.getClass()), eq(SuccessResponse.class)); // Test ResponseEntity<PiazzaResponse> entity = serviceController.updateService("123456", mockService, user); // Verify assertTrue(entity.getBody() instanceof SuccessResponse); // Test Exception doThrow(new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR)).when(restTemplate).exchange( any(String.class), eq(HttpMethod.PUT), any(request.getClass()), eq(SuccessResponse.class)); ResponseEntity<PiazzaResponse> entity2 = serviceController.updateService("123456", mockService, user); assertTrue(entity2.getStatusCode().equals(HttpStatus.INTERNAL_SERVER_ERROR)); assertTrue(entity2.getBody() instanceof ErrorResponse); }