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:org.fon.documentmanagementsystem.controllers.rest.RestApiDocumentsController.java

@RequestMapping(path = "{id}", method = RequestMethod.GET)
public ResponseEntity<List<TreeDto>> getDocuments(@PathVariable("id") long id) {
    System.out.println("U restu sam za dokumente");
    Aktivnost a = activityService.findOne(id);
    List<TreeDto> data = new ArrayList<>();
    if (a.getDokumentList().isEmpty()) {
        TreeDto nemadokumenata = new TreeDto("0", id + "", "No documents", TreeDto.ACTIVITY_ICON, "", "");
        data.add(nemadokumenata);/*from   w w  w .  j  a  v  a  2  s .  c  om*/
    } else {

    }
    System.out.println("data" + data.size());
    return new ResponseEntity<>(data, HttpStatus.OK);
}

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

@CitrusTest
public void placeChocolateCookieOrder() {
    variable("amount", Functions.randomNumber(2L));
    variable("orderId", Functions.randomNumber(10L));

    http().client(bakeryClient).post("/order").contentType("application/json")
            .payload("{ \"order\": { \"type\": \"chocolate\", \"id\": ${orderId}, \"amount\": ${amount}}}");

    repeatOnError(http().client(reportingClient).get("/reporting/order").queryParam("id", "${orderId}"), http()
            .client(reportingClient).response(HttpStatus.OK).messageType(MessageType.PLAINTEXT).payload("true"))
                    .until(new IteratingConditionExpression() {
                        @Override
                        public boolean evaluate(int index, TestContext context) {
                            return index > 20;
                        }/*from w  w  w  . j  ava 2s . c  o m*/
                    }).autoSleep(100L);

    http().client(bakeryClient).response(HttpStatus.OK).messageType(MessageType.PLAINTEXT);
}

From source file:edu.infsci2560.services.LocationsService.java

@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public ResponseEntity<Location> create(@RequestBody Location locations) {
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(repository.save(locations), headers, HttpStatus.OK);
}

From source file:com.sms.server.controller.MediaController.java

@RequestMapping(value = "/folder/{id}", method = RequestMethod.GET)
public ResponseEntity<MediaFolder> getMediaFolder(@PathVariable("id") Long id) {
    MediaFolder mediaFolder = settingsDao.getMediaFolderByID(id);

    if (mediaFolder == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }//  www.j  a  v  a  2 s.  c  om

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

From source file:org.sharetask.controller.TaskControllerIT.java

@Test
public void testAddComment() throws IOException {
    //given/* w  w  w  . j  a va2s. c  om*/
    final HttpPost httpPost = new HttpPost(URL_TASK + "/1/comment");
    httpPost.addHeader(new BasicHeader("Content-Type", "application/json"));
    final StringEntity httpEntity = new StringEntity("{\"comment\":\"test comment\"}");
    httpPost.setEntity(httpEntity);

    //when
    final HttpResponse response = getClient().execute(httpPost);

    //then
    Assert.assertEquals(HttpStatus.OK.value(), response.getStatusLine().getStatusCode());
}

From source file:com.abdin.noorsingles.web.AdminController.java

@RequestMapping(value = "/logout", method = RequestMethod.GET)
public ResponseEntity loginPage(HttpSession session) {

    adminService.logout(session);/*w w w.ja va  2s. c  o m*/

    return new ResponseEntity(HttpStatus.OK);
}

From source file:com.biz.report.controller.CustomerReportControler.java

@ResponseBody
@RequestMapping(value = "customerreport/{year}/get", method = RequestMethod.POST, headers = {
        "Content-type=application/json" })
public ResponseEntity<ReportDataSet> readFTypes(@PathVariable("year") String year, @RequestBody Map data) {
    logger.info(year);//from w  ww  .ja v  a2 s.  c  om
    logger.info(data);
    Assert.notNull(data, "Data is null.");
    Assert.notNull(year, "Year is null.");
    String items = data.get("customers").toString();
    String months = data.get("months").toString();
    ReportDataSet reportDataSet = customerService.getReports(items, months, year);
    HttpHeaders headers = new HttpHeaders();
    headers.add("success", "Success");
    return new ResponseEntity<ReportDataSet>(reportDataSet, headers, HttpStatus.OK);
}

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

@Override
public ResponseEntity<Licences> findBySchool(int idUsuario, String token, long idSchool)
        throws EntidadNoEncontradaException {
    School school = repoSchool.findOne(idSchool);

    if (school == null) {
        throw new EntidadNoEncontradaException("Entity School");
    }//from   w  w w  . j a va  2s  .c o m
    return new ResponseEntity(repoLic.findBySchool(school), HttpStatus.OK);
}

From source file:comsat.sample.mustache.SampleWebMustacheApplicationTests.java

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

From source file:com.consol.citrus.samples.docker.TodoListIT.java

@Test
@CitrusTest//from   w  w w .  j a v  a2s .  com
public void testTodoService() {
    variable("todoId", "citrus:randomUUID()");
    variable("todoName", "citrus:concat('todo_', citrus:randomNumber(4))");
    variable("todoDescription", "Description: ${todoName}");
    variable("done", "false");

    http().client(todoClient).send().post("/todolist").messageType(MessageType.JSON)
            .contentType("application/json").payload(
                    "{ \"id\": \"${todoId}\", \"title\": \"${todoName}\", \"description\": \"${todoDescription}\", \"done\": ${done}}");

    http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT)
            .payload("${todoId}");

    http().client(todoClient).send().get("/todo/${todoId}").accept("application/json");

    http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.JSON).payload(
            "{ \"id\": \"${todoId}\", \"title\": \"${todoName}\", \"description\": \"${todoDescription}\", \"done\": ${done}}");
}