List of usage examples for org.springframework.http ResponseEntity getStatusCode
public HttpStatus getStatusCode()
From source file:org.lecture.unit.tutorial.controller.TutorialControllerUnitTest.java
@Test public void getOneShouldReturnResponseContainingTheDataOfOneTutorialAsJson() throws Exception { Tutorial instance = new Tutorial(); instance.setId("1"); instance.setFormat("MARKDOWN"); instance.setContent("# Hallo Welt!"); TutorialResource testResource = new TutorialResource(instance); when(tutorialRepository.findOne("1")).thenReturn(instance); when(tutorialAssembler.toResource(instance)).thenReturn(testResource); ResponseEntity response = testInstance.getOne("1"); assertEquals(200, response.getStatusCode().value()); verify(tutorialRepository, times(1)).findOne("1"); verify(tutorialAssembler, times(1)).toResource(instance); }
From source file:tools.RequestSendingRunnable.java
@Override public void run() { log.info(String.format("Sending the request to url [%s] with trace id in headers [%d]", this.url, this.traceId)); ResponseEntity<String> responseEntity = this.restTemplate.exchange(requestWithTraceId(), String.class); then(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK); log.info(String.format("Received the following response [%s]", responseEntity)); }
From source file:fr.patouche.soat.google.GoogleApplicationTests.java
@Test public void everythingIsSecuredByDefault() throws Exception { TestRestTemplate restTemplate = new TestRestTemplate(); ResponseEntity<Void> entity = restTemplate.getForEntity("http://localhost:" + this.port, Void.class); assertThat(entity.getStatusCode(), is(HttpStatus.FOUND)); assertThat(entity.getHeaders().getLocation(), is(equalTo(URI.create("http://localhost:" + this.port + "/login")))); }
From source file:io.spring.initializr.service.InitializrServiceSmokeTests.java
@Test public void configurationCanBeSerialized() throws URISyntaxException { RequestEntity<Void> request = RequestEntity.get(new URI("/metadata/config")) .accept(MediaType.APPLICATION_JSON).build(); ResponseEntity<String> response = this.restTemplate.exchange(request, String.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); InitializrMetadata actual = InitializrMetadataBuilder.create() .withInitializrMetadata(new ByteArrayResource(response.getBody().getBytes())).build(); assertThat(actual).isNotNull();//from ww w . j ava 2 s . c o m InitializrMetadata expected = this.metadataProvider.get(); assertThat(actual.getDependencies().getAll().size()).isEqualTo(expected.getDependencies().getAll().size()); assertThat(actual.getConfiguration().getEnv().getBoms().size()) .isEqualTo(expected.getConfiguration().getEnv().getBoms().size()); }
From source file:org.cloudfoundry.identity.varz.integration.VarzEndpointIntegrationTests.java
/** * tests a happy-day flow of the <code>/varz</code> endpoint *///from w ww . j ava 2 s . c o m @Test public void testHappyDay() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", testAccounts.getVarzAuthorizationHeader()); ResponseEntity<String> response = serverRunning.getForString("/", headers); assertEquals(HttpStatus.OK, response.getStatusCode()); String map = response.getBody(); assertTrue(map.contains("thread_pool")); }
From source file:io.syndesis.runtime.APIDocsITCase.java
@Test public void testSwaggerDocsIndex() { ResponseEntity<String> response = restTemplate().getForEntity("/api/v1/index.html", String.class); assertThat(response.getStatusCode()).as("swagger docs index.html response code").isEqualTo(HttpStatus.OK); assertThat(response.getBody().length()).as("swagger index.html length").isPositive(); assertThat(response.getBody()).as("swagger index.html example path").contains("/connectors/{id}"); }
From source file:org.zalando.stups.twintip.TwintipApplicationIT.java
@Test public void isConfigured() { String endpointUrl = "http://localhost:" + port + "/.well-known/schema-discovery"; LOG.info("ENDPOINT_URL : {}", endpointUrl); RestTemplate template = new RestTemplate(); ResponseEntity<String> entity = template.getForEntity(endpointUrl, String.class); HttpStatus statusCode = entity.getStatusCode(); String body = entity.getBody(); Assertions.assertThat(statusCode).isEqualTo(HttpStatus.OK); Assertions.assertThat(body).contains("swagger-2.0"); LOG.info("BODY : {}", body); }
From source file:com.unknown.pkg.TwintipCustomProfileApplicationIT.java
@Test public void isConfigured() { String endpointUrl = "http://localhost:" + port + "/.well-known/schema-discovery"; LOG.info("ENDPOINT_URL : {}", endpointUrl); RestTemplate template = new RestTemplate(); ResponseEntity<String> entity = template.getForEntity(endpointUrl, String.class); HttpStatus statusCode = entity.getStatusCode(); String body = entity.getBody(); Assertions.assertThat(statusCode).isEqualTo(HttpStatus.OK); Assertions.assertThat(body).contains("swagger-unreleased"); LOG.info("BODY : {}", body); }
From source file:org.bonitasoft.web.designer.controller.preview.PreviewerTest.java
@Test public void should_generate_html_and_print_it_in_response() throws Exception { when(pageRepository.get(page.getId())).thenReturn(page); when(generator.generateHtml("/runtime/", page)).thenReturn("foobar"); ResponseEntity<String> response = previewer.render(page.getId(), pageRepository, request); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response.getBody()).isEqualTo("foobar"); }
From source file:org.cloudfoundry.identity.batch.integration.BatchEndpointIntegrationTests.java
/** * tests a happy-day flow of the <code>/batch</code> endpoint */// w w w . j av a2 s . co m @Test public void testHappyDay() throws Exception { String credentials = String.format("%s:%s", "batch", "batchsecret"); String auth = String.format("Basic %s", new String(Base64.encode(credentials.getBytes()))); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", auth); ResponseEntity<String> response = serverRunning.getForString("/batch/", headers); assertEquals(HttpStatus.OK, response.getStatusCode()); String map = response.getBody(); assertTrue(map.contains("jobs")); }