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:comsat.sample.actuator.log4j2.SampleActuatorApplicationTests.java

@Test
public void testHome() throws Exception {
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> entity = new TestRestTemplate().getForEntity("http://localhost:" + port, Map.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    @SuppressWarnings("unchecked")
    Map<String, Object> body = entity.getBody();
    assertEquals("Hello Daniel", body.get("message"));
}

From source file:name.bpdp.bootswipl.BootSwiplAppTests.java

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

From source file:org.ng200.openolympus.controller.errors.BindingErrorController.java

@ResponseStatus(value = HttpStatus.OK)
@ExceptionHandler({ BindException.class })
@ResponseBody/* www .  j  ava2s.  co  m*/
public BindingResponse handleBindException(BindException exception) {
    BindingErrorController.logger.info("Handling binding exception");
    return new BindingResponse(Status.BINDING_ERROR, exception.getBindingResult().getFieldErrors());
}

From source file:org.khmeracademy.btb.auc.pojo.controller.Top_Bidder_controller.java

@RequestMapping(value = "/get-top-bidder", method = RequestMethod.GET, produces = "application/json")
@ResponseBody//from w  w  w  .j a v a 2  s  . com
public ResponseEntity<Map<String, Object>> getTopBidder() {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        ArrayList<Top_Bidder> top_bidder = top_bidder_service.getTop_Bidder();

        if (!top_bidder.isEmpty()) {
            map.put("DATA", top_bidder);
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA FOUND!");
        } else {
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA NOT FOUND");
        }
    } catch (Exception e) {
        map.put("STATUS", false);
        map.put("MESSAGE", "Error!");
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}

From source file:web.UsersRESTController.java

/**
 * Gets a list of users through a REST API
 * @return//w  ww . j ava 2 s . co  m
 */
@RequestMapping(value = "/api/users/", method = RequestMethod.GET)
public ResponseEntity<List<Users>> listUsers() {
    List<Users> users = dao.getUsersList();
    //returns NO_CONTENT error if no Users are provided
    if (users.isEmpty()) {
        return new ResponseEntity<List<Users>>(HttpStatus.NO_CONTENT);
    }
    //otherwise returns list of all Users
    return new ResponseEntity<List<Users>>(users, HttpStatus.OK);
}

From source file:org.openbaton.vnfm.api.RestMonitor.java

/**
 * Returns the consumed capacity of the requested MediaServer
 *
 * @param hostName : hostName of the MediaServer
 * @return consumed_capacity: Consumed Capacity of the MediaServer
 *//* w  w  w .j  a v a 2  s.  co m*/
@RequestMapping(value = "CONSUMED_CAPACITY", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public String get(@PathVariable("hostname") String hostName) throws NotFoundException {
    MediaServer mediaServer = mediaServerManagement.queryByHostName(hostName);
    if (mediaServer == null)
        throw new NotFoundException("MediaServer with name " + hostName + " not found.");
    return Double.toString(mediaServer.getUsedPoints());
}

From source file:com.consol.citrus.demo.devoxx.ReportOrdersIT.java

@CitrusTest
public void getOrders() {
    final String orderId = Functions.randomNumber(10L);
    variable("orderId", orderId);

    echo("First check order id not present");

    http().client(reportingClient).get("/reporting/orders");

    http().client(reportingClient).response(HttpStatus.OK).messageType(MessageType.PLAINTEXT)
            .validationCallback(new AbstractValidationCallback<String>() {
                @Override/* w  ww . j  a  v a 2 s  . co  m*/
                public void validate(String payload, Map headers, TestContext context) {
                    Assert.assertFalse(payload.contains(orderId));
                }
            });

    echo("Add some 'blueberry' order with id");

    http().client(reportingClient).put("/reporting").queryParam("id", "${orderId}")
            .queryParam("name", "blueberry").queryParam("amount", "1");

    http().client(reportingClient).response(HttpStatus.OK);

    echo("Receive order id in list of produced goods");

    http().client(reportingClient).get("/reporting/orders");

    http().client(reportingClient).response(HttpStatus.OK).messageType(MessageType.PLAINTEXT)
            .validationCallback(new AbstractValidationCallback<String>() {
                @Override
                public void validate(String payload, Map headers, TestContext context) {
                    Assert.assertTrue(payload.contains(orderId));
                }
            });
}

From source file:com._8x8.presentation.restfulController.GCMRestController.java

@RequestMapping(value = "/gcm/{id}/update", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> updateGCMById(@PathVariable("id") String id, @RequestBody GCM gcm,
        UriComponentsBuilder ucBuilder) {

    try {/*  ww w. j ava  2  s .  c  o m*/
        _gcmService.UpdateGCMById(gcm);
        return new ResponseEntity<String>("{'status': 'success'}", HttpStatus.OK);
    } catch (Exception ex) {
        return new ResponseEntity<String>(HttpStatus.BAD_REQUEST);
    }

}

From source file:com.consol.citrus.demo.devoxx.ReportSummaryIT.java

@CitrusTest
public void getHtmlReport() {
    echo("Receive Html report");

    http().client(reportingClient).get("/reporting");

    http().client(reportingClient).response(HttpStatus.OK).payload(
            "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"org/w3/xhtml/xhtml1-strict.dtd\">\n"
                    + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head>\n" + "<title></title>\n"
                    + "</head>\n" + "<body>\n" + "<h1>Camel bakery reporting</h1>\n"
                    + "<p>Today we have produced following goods:</p>\n" + "<ul>\n"
                    + "<li>@startsWith('chocolate:')@</li>\n" + "<li>@startsWith('caramel:')@</li>\n"
                    + "<li>@startsWith('blueberry:')@</li>\n" + "</ul>"
                    + "<p><a href=\"reporting/orders\">Show orders</a></p>" + "</body>" + "</html>")
            .build().setMessageType("xhtml");
}

From source file:org.ohdsi.webapi.test.CohortAnalysisServiceIT.java

private void assertOk(final ResponseEntity<?> entity) {
    Assert.state(entity.getStatusCode() == HttpStatus.OK);
}