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.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:com.gsr.myschool.server.reporting.excel.ExcelController.java

@RequestMapping(method = RequestMethod.POST, value = "/excel")
@ResponseStatus(HttpStatus.OK)
public void generateExcel(@RequestBody DossierFilterDTO requestdata, HttpServletRequest request,
        HttpServletResponse response) {/*from  w w  w  .ja v a  2 s. c  o m*/
    try {

        List<Dossier> dossiers = dossierService.findAllDossiersByCriteria(requestdata, null, null)
                .getDossiers();
        List<DossierExcelDTO> resultDossiers = map(dossiers);

        String fileName = new Date().getTime() + ".xls";
        File file = new File(
                request.getSession().getServletContext().getRealPath("/") + TMP_FOLDER_PATH + fileName);
        if (!file.getParentFile().exists()) {
            file.getParentFile().mkdirs();
        }
        file.createNewFile();

        FileOutputStream fileOutputStream = new FileOutputStream(file);
        xlsExportService.saveSpreadsheetRecords(DossierExcelDTO.class, resultDossiers, fileOutputStream);
        fileOutputStream.flush();
        fileOutputStream.close();

        response.getWriter().println(fileName);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

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

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

From source file:sample.jetty.SampleJettyApplicationTests.java

@Test
public void testHome() throws Exception {
    ResponseEntity<String> entity = this.restTemplate.getForEntity("/", String.class);
    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
    //assertThat(entity.getBody()).isEqualTo("Hello World");
}

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

@RequestMapping(value = "/add", method = RequestMethod.POST)
public ResponseEntity<?> add(OAuth2Authentication authentication, @RequestBody Factura factura) {
    Usuarios user = facadeService.getUsuariosDAO().findUsuarioByUsername(authentication.getName());
    factura.setUsuarioCreacion(user.getIdUsuario());
    factura.setFechaCreacion(new Date());
    factura.setEstado("RESERVADO");
    factura.setIdSucursal(user.getUsuarioSucursal().getIdSucursal());
    factura.setTotal(BigDecimal.ZERO);
    int idFactura = facadeService.getFacturaDAO().add(factura);
    JsonResponse msg = new JsonResponse("Success", String.valueOf(idFactura));
    return new ResponseEntity<>(msg, HttpStatus.OK);
}

From source file:com.ogaclejapan.dotapk.WebApiController.java

protected ResponseEntity<WebApiReturns> success(Object result) {
    return success(result, HttpStatus.OK);
}

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

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

From source file:net.thewaffleshop.nimbus.web.WebJarsController.java

@ResponseBody
@RequestMapping("/webjarslocator/{webjar}/**")
public ResponseEntity locateWebjarAsset(@PathVariable String webjar, HttpServletRequest request) {
    try {/*w ww  .  ja  v  a 2  s .  co  m*/
        String mvcPrefix = "/webjarslocator/" + webjar + "/";
        String mvcPath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
        String fullPath = assetLocator.getFullPath(webjar, mvcPath.substring(mvcPrefix.length()));
        return new ResponseEntity(new ClassPathResource(fullPath), HttpStatus.OK);
    } catch (Exception e) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:io.syndesis.runtime.APIDocsITCase.java

@Test
public void testSwaggerYaml() {
    ResponseEntity<Map<String, Map<?, ?>>> response = restTemplate().getForEntity("/api/v1/swagger.yaml", TYPE);
    assertThat(response.getStatusCode()).as("swagger yaml response code").isEqualTo(HttpStatus.OK);
    assertThat((response.getBody().get("paths")).size()).as("swagger json number of paths").isPositive();
}

From source file:ar.com.zauber.commons.social.oauth.examples.web.controllers.WelcomeController.java

/**
 * @throws IOException/* w  w  w  .j  a  v a2  s .  c om*/
 */
@RequestMapping(method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public ModelAndView getIndex() throws IOException {
    ModelAndView out;

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    ExampleUserDetails principal = (ExampleUserDetails) auth.getPrincipal();

    String username = principal.getUsername();
    if (username == null) {
        out = new ModelAndView("newuser");
        out.addObject("twitterUsername", principal.getAccessToken().getScreenName());
    } else {
        out = new ModelAndView("welcome");
        out.addObject("username", username);
    }

    return out;
}