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.wordnik.springmvc.UserResource.java

@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", position = 1)
public ResponseEntity createUser(@ApiParam(value = "Created user object", required = true) User user,
        String arbitraryString) {
    userData.addUser(user);//from   w w w  . jav  a  2s  .c om
    return new ResponseEntity(HttpStatus.OK);
}

From source file:cr.ac.siua.tec.controllers.FormController.java

/**
 * In charge of receiving mobile requests (forms) and validating them. No captcha response required.
 *//*from w  ww .  ja va  2  s .c o m*/
@RequestMapping(value = "/mobileRequest", method = RequestMethod.POST)
public ResponseEntity<HashMap<String, String>> createMobileTicket(@RequestBody HashMap<String, String> map) {
    return new ResponseEntity<>(getRequestResponseMap(map), HttpStatus.OK);
}

From source file:me.j360.boot.microservice.profile.test.J360ApplicationTests.java

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

    System.out.println(entity.getBody());
    assertThat(entity.getBody(), startsWith("{\"id\":1,\"firstName\":\"Oliver\"" + ",\"lastName\":\"Gierke\""));
    assertThat(entity.getBody(), containsString("_links\":{\"self\":{\"href\""));
}

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

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

From source file:fi.helsinki.opintoni.integration.pagemetadata.SpringPageMetaDataHttpClient.java

@Override
public Optional<String> getPageBody(String pageUrl) {
    Optional<String> pageBody = Optional.empty();
    try {//from w ww. j  ava2  s .  c o  m
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Lists.newArrayList(MediaType.TEXT_HTML));
        headers.add(USER_AGENT_KEY, USER_AGENT);
        HttpEntity<String> entity = new HttpEntity<>(PARAMETERS_KEY, headers);

        ResponseEntity<String> response = metaDataRestTemplate.exchange(pageUrl, HttpMethod.GET, entity,
                String.class);
        if (response.getStatusCode().equals(HttpStatus.OK)) {
            pageBody = Optional.ofNullable(response.getBody());
        }
    } catch (Exception e) {
    }

    return pageBody;

}

From source file:org.openlmis.notification.web.NotificationController.java

/**
 * Send an email notification.// ww w  . j a  v  a 2 s .co m
 * @param notificationRequest details of the message
 */
@RequestMapping("/notification")
@ResponseStatus(HttpStatus.OK)
public void sendNotification(@RequestBody NotificationRequest notificationRequest) throws MessagingException {
    notificationService.sendNotification(notificationRequest.getFrom(), notificationRequest.getTo(),
            notificationRequest.getSubject(), notificationRequest.getContent());
}

From source file:com.alcatel.hello.actuator.ui.SampleActuatorUIApplicationTests.java

@Test
public void testHome() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port,
            HttpMethod.GET, new HttpEntity<Void>(headers), String.class);

    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
            entity.getBody().contains("<title>Hello"));
}

From source file:be.bittich.quote.controller.impl.AbstractController.java

@Override
@RequestMapping(value = "/create", method = { RequestMethod.POST }, consumes = APPLICATION_JSON)
@ResponseStatus(HttpStatus.OK)
public T create(@RequestBody @Valid T t) {
    if (t.getId() != null && getService().findOneById((PK) t.getId()) != null) {
        getLogger().info(String.format("%s: %s", "Attempt to create an existing entity with id", t.getId()));
        throw new EntityExistException("Ajout impossible : l'entit existe dj!");

    }//from   ww  w . j  a v  a2 s.c  o m
    checkArgument(this.canCreate(t), "Cration impossible: permission non accorde.");

    T insert = this.getService().insert(t);
    getLogger().info(String.format("%s: %s", "Entity added successfully with id", t.getId()));

    return insert;

}

From source file:sample.jersey.SampleJerseyApplicationTests.java

@Test
public void reverse() {
    ResponseEntity<String> entity = this.restTemplate
            .getForEntity("http://localhost:" + this.port + "/reverse?input=olleh", String.class);

    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertEquals("hello", entity.getBody());
}

From source file:uk.urchinly.wabi.expose.ApplicationConfigurationTests.java

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