List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:ch.silviowangler.dox.web.ImportControllerTest.java
@Test public void importDocumentDuplicateDocument() throws DocumentClassNotFoundException, DocumentDuplicationException, ValidationException { when(request.getParameterNames()).thenReturn(Lists.asList("a", new String[] { "b", "c" }).iterator()); when(request.getParameter("a")).thenReturn("A"); when(request.getParameter("b")).thenReturn("B"); when(request.getParameter("c")).thenReturn("C"); when(documentService.importDocument(any(PhysicalDocument.class))) .thenThrow(new DocumentDuplicationException(1L, "hash")); ResponseEntity responseEntity = controller.importDocument( new MockMultipartFile("test.pdf", "this is just a test".getBytes()), request, "Client"); assertThat(responseEntity.getStatusCode(), is(CONFLICT)); verify(documentService).importDocument(any(PhysicalDocument.class)); }
From source file:ch.silviowangler.dox.web.ImportControllerTest.java
@Test public void importDocument() throws DocumentClassNotFoundException, DocumentDuplicationException, ValidationException { when(request.getParameterNames()).thenReturn(Lists.asList("a", new String[] { "b", "c" }).iterator()); when(request.getParameter("a")).thenReturn("A"); when(request.getParameter("b")).thenReturn("B"); when(request.getParameter("c")).thenReturn("C"); when(documentService.importDocument(any(PhysicalDocument.class))) .thenReturn(new DocumentReference("test.pdf")); ResponseEntity responseEntity = controller.importDocument( new MockMultipartFile("test.pdf", "this is just a test".getBytes()), request, "Client"); assertThat(responseEntity.getStatusCode(), is(CREATED)); verify(documentService).importDocument(any(PhysicalDocument.class)); }
From source file:ch.silviowangler.dox.web.ImportControllerTest.java
@Test public void importDocumentValidationException() throws DocumentClassNotFoundException, DocumentDuplicationException, ValidationException { when(request.getParameterNames()).thenReturn(Lists.asList("a", new String[] { "b", "c" }).iterator()); when(request.getParameter("a")).thenReturn("A"); when(request.getParameter("b")).thenReturn("B"); when(request.getParameter("c")).thenReturn("C"); when(documentService.importDocument(any(PhysicalDocument.class))).thenThrow(new ValidationException("bla")); ResponseEntity responseEntity = controller.importDocument( new MockMultipartFile("test.pdf", "this is just a test".getBytes()), request, "Client"); assertThat(responseEntity.getStatusCode(), is(CONFLICT)); verify(documentService).importDocument(any(PhysicalDocument.class)); }
From source file:com.alcatel.hello.actuator.ui.SampleActuatorUIApplicationTests.java
@Test public void testMetrics() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.port + "/metrics", Map.class); assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode()); }
From source file:comsat.sample.freemarker.SampleWebFreeMarkerApplicationTests.java
@Test public void testFreeMarkerErrorTemplate() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); HttpEntity<String> requestEntity = new HttpEntity<String>(headers); ResponseEntity<String> responseEntity = new TestRestTemplate().exchange( "http://localhost:" + port + "/does-not-exist", HttpMethod.GET, requestEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody().contains("Something went wrong: 404 Not Found")); }
From source file:com.crazyacking.learn.spring.actuator.ManagementPortSampleActuatorApplicationTests.java
@Test public void testMetrics() { testHome(); // makes sure some requests have been made @SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.managementPort + "/actuator/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); }
From source file:de.codecentric.boot.admin.AdminApplicationTest.java
@Test public void testGetApplications() { @SuppressWarnings("rawtypes") ResponseEntity<List> entity = new TestRestTemplate() .getForEntity("http://localhost:" + port + "/api/applications", List.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); }
From source file:com.intel.databackend.handlers.Data.java
@RequestMapping(value = "/v1/accounts/{accountId}/dataInquiry", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody/*w ww.j a v a 2 s . com*/ public ResponseEntity dataInquiry(@PathVariable String accountId, @RequestBody DataInquiryRequest request) throws ServiceException, VcapEnvironmentException { logger.info(REQUEST_LOG_ENTRY, accountId); logger.debug(DEBUG_LOG, request); requestValidator = new DataRequestValidator(request); requestValidator.validate(); basicDataInquiryService.withParams(accountId, request); DataInquiryResponse dataInquiryResponse = basicDataInquiryService.invoke(); ResponseEntity res = new ResponseEntity<DataInquiryResponse>(dataInquiryResponse, HttpStatus.OK); logger.info(RESPONSE_LOG_ENTRY, res.getStatusCode()); logger.debug(DEBUG_LOG, dataInquiryResponse); return res; }
From source file:net.eusashead.hateoas.response.impl.GetResponseBuilderImplTest.java
@Test public void testEntityBuild() throws Exception { Entity entity = new Entity("foo"); ResponseEntity<Entity> response = builder.entity(entity).build(); Assert.assertNotNull(response);/* w w w . ja va2s. com*/ Assert.assertEquals(HttpStatus.OK, response.getStatusCode()); Assert.assertEquals(entity, response.getBody()); Assert.assertNull(response.getHeaders().getETag()); Assert.assertEquals(-1l, response.getHeaders().getLastModified()); Assert.assertNull(response.getHeaders().getCacheControl()); Assert.assertEquals(-1l, response.getHeaders().getExpires()); Assert.assertEquals(-1l, response.getHeaders().getDate()); }
From source file:com.crazyacking.learn.spring.actuator.ManagementPortAndPathSampleActuatorApplicationTests.java
@Test public void testMissing() { ResponseEntity<String> entity = new TestRestTemplate("user", getPassword()) .getForEntity("http://localhost:" + this.managementPort + "/admin/missing", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getBody()).contains("\"status\":404"); }