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:com.walmart.gatling.AbstractRestIntTest.java

protected <T> T putForObject(String url, Object input, Class<T> responseType, HttpStatus expectedStatus) {
    ResponseEntity<T> entity = template.putForEntity(url, input, responseType);
    if (expectedStatus != entity.getStatusCode()) {
        if (entity.hasBody())
            logger.debug("Error processings put:  {}", entity.getBody().toString());
    }//  www  . ja  v  a 2 s . c o m

    assertEquals(expectedStatus, entity.getStatusCode());

    return entity.getBody();
}

From source file:org.oauth2.SampleServletApplicationTests.java

@Test
public void testHomeIsSecure() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:8080/home.beannote",
            String.class);
    System.out.println(entity.getStatusCode());
    System.out.println(entity.toString());
}

From source file:com.walmart.gatling.AbstractRestIntTest.java

protected <T> T postForObject(String url, Object post, Class<T> responseType, HttpStatus expectedStatus) {
    ResponseEntity<T> entity = template.postForEntity(url, post, responseType);
    assertEquals(expectedStatus, entity.getStatusCode());
    return entity.getBody();
}

From source file:me.j360.boot.microservice.profile.test.J360ApplicationTests.java

@Test
public void hasHalLinks() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate()
            .getForEntity("http://localhost:" + this.port + "/profiles/1", String.class);
    assertThat(entity.getStatusCode(), equalTo(HttpStatus.OK));

    System.out.println(entity.getBody());
    assertThat(entity.getBody(), startsWith("{\"id\":1,\"firstName\":\"Oliver\"" + ",\"lastName\":\"Gierke\""));
    assertThat(entity.getBody(), containsString("_links\":{\"self\":{\"href\""));
}

From source file:org.zaizi.SensefySearchUiApplicationTests.java

@Test
public void userEndpointProtected() {
    ResponseEntity<String> response = template.getForEntity("http://localhost:" + port + "/user", String.class);
    assertEquals(HttpStatus.FOUND, response.getStatusCode());
}

From source file:com.digitalriver.artifact.NickArtifactServerTests.java

public void testHome() throws Exception {
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port,
            String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
            entity.getBody().contains("<title>Static"));
}

From source file:com.seb.aws.demo.tomcat.SampleTomcatApplicationTests.java

@Test
public void testHome() throws Exception {
    LOG.info("Tests...");
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port,
            String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertEquals("Hello World", entity.getBody());
}

From source file:it.reply.orchestrator.service.SlamServiceImpl.java

@Override
public SlamPreferences getCustomerPreferences() {

    ResponseEntity<SlamPreferences> response = restTemplate
            .getForEntity(url.concat(preferences).concat("/indigo-dc"), SlamPreferences.class);
    if (response.getStatusCode().is2xxSuccessful()) {
        return response.getBody();
    }// w  w w  .java 2  s . co m
    throw new DeploymentException("Unable to find SLAM preferences. " + response.getStatusCode().toString()
            + " " + response.getStatusCode().getReasonPhrase());
}

From source file:org.camunda.bpm.spring.boot.starter.webapp.WebappEeTest.java

@Test
public void testAdminEndpointAvailable() throws Exception {
    final ResponseEntity<String> response = testRestTemplate
            .getForEntity("http://localhost:" + this.port + "/app/admin", String.class);

    assertEquals(HttpStatus.OK, response.getStatusCode());
}

From source file:com.rest.unit.ProjectRestUnitTest.java

@Test
public void createProject() {
    when(mockSecurityContextReader.getUsername()).thenReturn("admin@gmail.com");

    ResponseEntity responseEntity = projectRest.createProject(projectRequestDto);

    assertTrue(responseEntity.getStatusCode() == HttpStatus.OK);
    verify(mockProjectRepository, times(1)).save(any(ProjectEntity.class));

    verify(mockProjectUserRepository, times(1)).save(any(ProjectUserEntity.class));
    verify(mockAuthorityRepository, times(1)).save(any(AuthorityEntity.class));
    verify(mockTranslationRepository, times(1)).save(any(TranslationEntity.class));
    verify(mockGroupRepository, times(1)).save(any(GroupEntity.class));
    verify(mockProjectGroupRepository, times(1)).save(any(ProjectGroupEntity.class));
    verify(mockInvitationRepository, times(1)).save(any(InvitationEntity.class));
    verify(mockInvitationGroupRepository, times(1)).save(any(InvitationGroupEntity.class));
}