Example usage for org.springframework.http HttpStatus OK

List of usage examples for org.springframework.http HttpStatus OK

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus OK.

Prototype

HttpStatus OK

To view the source code for org.springframework.http HttpStatus OK.

Click Source Link

Document

200 OK .

Usage

From source file:com.mycompany.springrest.controllers.UserController.java

@RequestMapping(value = "/user", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<User>> listUsers() {
    List<User> users = userService.listUsers();
    if (users.isEmpty()) {
        return new ResponseEntity<List<User>>(HttpStatus.NO_CONTENT);
    }//from  w w w .  j  a  va  2 s.  c o  m
    return new ResponseEntity<List<User>>(users, HttpStatus.OK);
}

From source file:md.ibanc.rm.controllers.rest.RestExchangeRateController.java

@RequestMapping(value = "/rest/valueExchangeRate", method = RequestMethod.GET)
public ResponseEntity<List<ExchangeRate>> getAllExchangeRate() {

    ExchangeRate exchangeRate = new ExchangeRate();
    exchangeRate.setBuyCurs(BigDecimal.ONE);
    exchangeRate.setDataIns(new Date());
    exchangeRate.setOfficialCurs(BigDecimal.TEN);
    exchangeRate.setSellCurs(BigDecimal.TEN);
    exchangeRateService.save(exchangeRate);

    List<ExchangeRate> ExchangeRateRestList = (ArrayList<ExchangeRate>) exchangeRateService.findAll();

    return new ResponseEntity<>(ExchangeRateRestList, HttpStatus.OK);
}

From source file:com.crazyacking.learn.spring.actuator.ManagementPathSampleActuatorApplicationTests.java

@Test
public void testHealth() {
    ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword())
            .getForEntity("/admin/health", String.class);
    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}

From source file:de.hamburg.mse.ui.SampleWebUiApplicationTests.java

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

}

From source file:com.aplikasi.penjualan.controller.DataPelangganController.java

@RequestMapping(value = "/pelanggan/{kode}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.OK)
public void updateDataPelanggan(@PathVariable("kode") String kode, @RequestBody @Valid DataPelanggan k) {
    k.setKode(kode);// w  ww .  j ava  2  s.co m
    kd.save(k);
}

From source file:com.crazyacking.learn.spring.actuator.NoManagementSampleActuatorApplicationTests.java

@Test
public void testHome() {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/",
            Map.class);
    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
    @SuppressWarnings("unchecked")
    Map<String, Object> body = entity.getBody();
    assertThat(body.get("message")).isEqualTo("Hello Phil");
}

From source file:com.xinferin.controller.ProductController.java

@RequestMapping(value = "/{productId}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public Product getProduct(@PathVariable int productId) {
    Product product = daoProduct.get(productId);
    daoProduct.deleteTemp(productId);/*  ww w .j  a  va2  s.c  om*/

    return product;
}

From source file:gt.dakaik.rest.impl.SchoolImpl.java

@Override
public ResponseEntity<School> findAll(int idUsuario, String token) throws EntidadNoEncontradaException {
    return new ResponseEntity(repoSchool.findAll(), HttpStatus.OK);
}

From source file:com.dolphine.ultrasimple.microservice.ApplicationTests.java

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

From source file:com.opensearchserver.hadse.index.IndexTest.java

@Test
public void t01_deleteIndex() {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));

    RestTemplate template = new RestTemplate();

    ResponseEntity<String> entity = template.exchange("http://localhost:8080/my_index", HttpMethod.DELETE, null,
            String.class);
    assertNotNull(entity);/*w w w.  j  a  va 2  s .co  m*/
    HttpStatus res = entity.getStatusCode();
    assertNotNull(res);
    switch (res) {
    case OK:
        assertEquals(HttpStatus.OK, res);
        break;
    case NOT_FOUND:
        assertEquals(HttpStatus.NOT_FOUND, res);
        break;
    default:
        fail("Unexpected result: " + res);
        break;
    }
}