Example usage for org.springframework.http ResponseEntity getStatusCode

List of usage examples for org.springframework.http ResponseEntity getStatusCode

Introduction

In this page you can find the example usage for org.springframework.http ResponseEntity getStatusCode.

Prototype

public HttpStatus getStatusCode() 

Source Link

Document

Return the HTTP status code of the response.

Usage

From source file:tds.assessment.web.endpoints.SegmentControllerTest.java

@Test
public void shouldReturnSegmentInformation() {
    SegmentItemInformation segmentItemInformation = new SegmentItemInformation.Builder().build();
    when(mockSegmentService.findSegmentItemInformation("segmentKey"))
            .thenReturn(Optional.of(segmentItemInformation));

    ResponseEntity<SegmentItemInformation> response = segmentController.getSegmentInformation("segmentKey");

    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(response.getBody()).isEqualTo(segmentItemInformation);
}

From source file:com.carlomicieli.jtrains.infrastructure.web.ResponsesTests.java

@Test
public void shouldCreateResponsesForNotFound() {
    ResponseEntity<VndErrors> notFound = Responses.notFound("details");
    assertThat(notFound).isNotNull();/*from   w  w w.j  a v a 2 s  .c  om*/
    assertThat(notFound.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
    assertThat(notFound.getBody()).isEqualTo(new VndErrors("details", "Resource not found"));
}

From source file:org.bonitasoft.web.designer.controller.preview.PreviewerTest.java

@Test
public void should_return_error_response_when_error_occur_on_generation() throws Exception {
    when(pageRepository.get(page.getId())).thenReturn(page);
    when(generator.generateHtml("/runtime/", page))
            .thenThrow(new GenerationException("error", new Exception()));

    ResponseEntity<String> response = previewer.render(page.getId(), pageRepository, request);

    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
    assertThat(response.getBody()).isEqualTo("Error during page generation");
}

From source file:io.syndesis.runtime.APIDocsITCase.java

@Test
public void testSwaggerJson() {
    ResponseEntity<JsonNode> response = restTemplate().getForEntity("/api/v1/swagger.json", JsonNode.class);
    assertThat(response.getStatusCode()).as("swagger json response code").isEqualTo(HttpStatus.OK);
    assertThat(response.getBody().get("paths").size()).as("swagger json number of paths").isPositive();
}

From source file:org.cloudfoundry.identity.uaa.integration.VarzEndpointIntegrationTests.java

/**
 * tests a happy-day flow of the <code>/varz</code> endpoint
 *///from w  ww  .  jav  a2 s . c  o  m
@Test
public void testHappyDay() throws Exception {

    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", testAccounts.getVarzAuthorizationHeader());
    ResponseEntity<String> response = serverRunning.getForString("/varz", headers);
    assertEquals(HttpStatus.OK, response.getStatusCode());

    String map = response.getBody();
    assertTrue(map.contains("spring.application"));
    assertTrue(map.contains("Catalina"));

}

From source file:sample.web.thymeleaf3.SampleWebThymeleaf3ApplicationTests.java

@Test
public void testCss() throws Exception {
    ResponseEntity<String> entity = this.restTemplate.getForEntity("/css/bootstrap.min.css", String.class);
    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(entity.getBody()).contains("body");
}

From source file:org.bonitasoft.web.designer.controller.preview.PreviewerTest.java

@Test
public void should_return_error_response_when_page_is_not_found() throws Exception {
    when(pageRepository.get("unexisting-page")).thenThrow(new NotFoundException("page not found"));

    ResponseEntity<String> response = previewer.render("unexisting-page", pageRepository, request);

    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
    assertThat(response.getBody()).isEqualTo("Page <unexisting-page> not found");
}

From source file:tds.assessment.web.endpoints.AccommodationControllerTest.java

@Test
public void shouldReturnAccommodationsByAssessmentId() {
    Accommodation accommodation = new Accommodation.Builder().build();
    when(accommodationsService.findAccommodationsByAssessmentId("client", "id"))
            .thenReturn(Collections.singletonList(accommodation));

    ResponseEntity<List<Accommodation>> response = controller.findAccommodations("client", null, "id");

    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(response.getBody()).containsOnly(accommodation);
}

From source file:dk.nsi.haiba.epimibaimporter.status.StatusReporterTest.java

@Test
public void willReturn200underNormalCircumstances() throws Exception {
    final ResponseEntity<String> response = reporter.reportStatus();

    assertEquals(200, response.getStatusCode().value());
    assertTrue(response.getBody().startsWith("OK"));
}

From source file:io.syndesis.runtime.APIDocsITCase.java

@Test
public void testSwaggerYaml() {
    ResponseEntity<Map<String, Map<?, ?>>> response = restTemplate().getForEntity("/api/v1/swagger.yaml", TYPE);
    assertThat(response.getStatusCode()).as("swagger yaml response code").isEqualTo(HttpStatus.OK);
    assertThat((response.getBody().get("paths")).size()).as("swagger json number of paths").isPositive();
}