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:monkeys.web.MonkeysController.java

@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
public ResponseEntity<Void> deleteMonkey(@PathVariable Long id) {
    monkeyRepository.delete(id);/*from  w w  w.  j a  v a 2 s. c o m*/
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(headers, HttpStatus.OK);
}

From source file:br.edu.ifpb.blogsoon.webapp.controller.avaliacao.AvaliacaoController.java

@RequestMapping(value = "/add", method = RequestMethod.POST)
public ResponseEntity<String> addAvaliacao(@RequestParam("idPost") String idPost,
        @RequestParam("tipo") String tipo, HttpSession session) {
    Usuario usuario = (Usuario) session.getAttribute("usuario");
    if (usuario != null) {
        if (avaliacaoService.buscarPorIdPostEUsuario(idPost, usuario).size() >= 1)
            return new ResponseEntity<>(HttpStatus.FORBIDDEN);
        Avaliacao avaliacao = new Avaliacao();
        avaliacao.setIdPost(idPost);/*from   w  w  w .  j a v  a 2  s.c om*/
        avaliacao.setUsuario(usuario);
        avaliacao.setTipo(AvaliacaoEnum.valueOf(tipo));
        avaliacaoService.salvar(avaliacao);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:br.upe.community.ui.ControllerCategoria.java

@RequestMapping(value = "/cadastrar", headers = "Accept=*/*", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<?> adicionarCategoria(Categoria categoria) {
    try {//  www . ja v  a2s. c om
        fachada.cadastrar(categoria);
        return new ResponseEntity<String>(HttpStatus.OK);
    } catch (CategoriaExistenteException e) {
        return new ResponseEntity<CategoriaExistenteException>(e, HttpStatus.BAD_REQUEST);
    }
}

From source file:br.ufc.deti.ecgweb.application.controller.ClientController.java

@RequestMapping(value = "doctor/listAll", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
@ResponseBody/*from  w w w. ja v  a  2 s  .  c  o m*/
@ResponseStatus(HttpStatus.OK)
public List<ListDoctorsResponseDTO> listDoctors(@RequestBody ListDoctorsRequestDTO dto) {

    if (!loginService.hasAccess(dto.getLogin(), dto.getKey())) {
        throw new ServiceNotAuthorizedException();
    }

    return Converters.converterListClientsToListDoctorsResponseDTO(service.listAllDoctors());
}

From source file:com.consol.citrus.samples.bakery.ReportOrderMailIT.java

@CitrusTest
public void shouldSendMail() {
    echo("Add 1000+ order and receive mail");

    variable("orderType", "chocolate");

    http().client(reportingClient).send().put("/reporting").queryParam("id", "citrus:randomNumber(10)")
            .queryParam("name", "${orderType}").queryParam("amount", "1001");

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

    echo("Receive report mail for 1000+ order");

    receive(mailServer).payload(new ClassPathResource("templates/mail.xml"))
            .header(CitrusMailMessageHeaders.MAIL_SUBJECT, "Congratulations!")
            .header(CitrusMailMessageHeaders.MAIL_FROM, "cookie-report@example.com")
            .header(CitrusMailMessageHeaders.MAIL_TO, "stakeholders@example.com");

    send(mailServer).payload(new ClassPathResource("templates/mail_response.xml"));

    echo("Receive report with 1000+ order");

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

    http().client(reportingClient).receive().response(HttpStatus.OK).messageType(MessageType.JSON).payload(
            "{\"caramel\": \"@ignore@\",\"blueberry\": \"@ignore@\",\"chocolate\": \"@greaterThan(1000)@\"}");
}

From source file:nu.yona.server.rest.StandardResourcesController.java

@RequestMapping(value = "/.well-known/apple-app-site-association", method = RequestMethod.GET)
@ResponseBody//from ww w  . j a v  a  2s .c  om
public ResponseEntity<byte[]> getAppleAppSiteAssociation() {
    Context ctx = ThymeleafUtil.createContext();
    ctx.setVariable("appleAppId", yonaProperties.getAppleAppId());

    return new ResponseEntity<>(
            templateEngine.process("apple-app-site-association.json", ctx).getBytes(StandardCharsets.UTF_8),
            HttpStatus.OK);
}

From source file:sample.jersey.ApplicationTests.java

@Test
public void contextLoads() {
    ResponseEntity<String> entity = restTemplate.getForEntity(
            "http://localhost:" + server.getEmbeddedServletContainer().getPort() + "/hello", String.class);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
}

From source file:com.github.codersparks.dockerservice.HelloWorldConfigurationTests.java

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

    Greeting greeting = entity.getBody();

    assertEquals("hello", greeting.getGreeting());
    assertEquals("world", greeting.getName());
}

From source file:com.ar.dev.tierra.api.controller.TransferenciaController.java

@RequestMapping(value = "/all", method = RequestMethod.GET)
public ResponseEntity<?> getAll() {
    List<Transferencia> list = facadeService.getTransferenciaDAO().getAll();
    if (!list.isEmpty()) {
        return new ResponseEntity<>(list, HttpStatus.OK);
    } else {/*w w  w.  ja  va2s .co  m*/
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}