Example usage for org.springframework.http HttpStatus NO_CONTENT

List of usage examples for org.springframework.http HttpStatus NO_CONTENT

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus NO_CONTENT.

Prototype

HttpStatus NO_CONTENT

To view the source code for org.springframework.http HttpStatus NO_CONTENT.

Click Source Link

Document

204 No Content .

Usage

From source file:io.github.howiefh.jeews.modules.oauth2.controller.ClientController.java

@RequiresPermissions("clients:delete")
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") Long id) {
    clientService.delete(id);/*from   w  ww .jav a 2s. c o  m*/
}

From source file:com.musiccorp.controller.MusicCorpController.java

@RequestMapping(value = "/artist/{id}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteArtist(@PathVariable("id") int artistID) {
    Artist artist = database.get(artistID);
    database.remove(artist);//from ww  w.j av a2 s.c  o m
    log.info("== Artist data DELETED");
    database.remove(artist.getId());
    return new ResponseEntity<String>(HttpStatus.NO_CONTENT);
}

From source file:com.example.notes.NotesController.java

@RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
@ResponseStatus(HttpStatus.NO_CONTENT)
void updateNote(@PathVariable("id") long id, @RequestBody NotePatchInput noteInput) {
    Note note = findNoteById(id);/*from w  ww  .j  a v a 2 s . c om*/
    if (noteInput.getTagUris() != null) {
        note.setTags(getTags(noteInput.getTagUris()));
    }
    if (noteInput.getTitle() != null) {
        note.setTitle(noteInput.getTitle());
    }
    if (noteInput.getBody() != null) {
        note.setBody(noteInput.getBody());
    }
    this.noteRepository.save(note);
}

From source file:com.tsguild.upsproject.controller.HomeController.java

@ResponseStatus(HttpStatus.NO_CONTENT)
@RequestMapping(value = "/cannister/{cannisterId}", method = RequestMethod.DELETE)
public void removeCannister(@PathVariable("cannisterId") int cannisterId) {
    dao.removeCannister(cannisterId);/*from  w ww. j ava 2s.c  o  m*/
}

From source file:io.curly.gathering.item.ItemControllerTests.java

@Test
public void testRemoveItem() throws Exception {
    this.mvc.perform(
            asyncDispatch(this.mvc
                    .perform(delete("/lists/{listId}/delete/artifact/{artifact}", this.list.getId(),
                            this.body.getItem()).principal(User.builder().id("6969").build()))
                    .andExpect(request().asyncStarted())
                    .andExpect(request().asyncResult(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
                    .andReturn()));//from   w  w  w.  j  a  v  a  2 s .c om

}

From source file:org.lecture.unit.tutorial.controller.TutorialControllerUnitTest.java

@Test
public void patchShouldPatchADocumentWithNewContent() throws Exception {
    String original = new String(Files.readAllBytes(Paths.get(getClass().getResource("/original.md").toURI())));

    Tutorial instance = new Tutorial();
    instance.setId("1");
    instance.setContent(original);/*from   w  w w  . j  ava2  s  .co  m*/
    instance.setFormat("MARKDOWN");
    TutorialResource testResource = new TutorialResource(instance);
    when(tutorialRepository.findOne("1")).thenReturn(instance);

    String modified = new String(Files.readAllBytes(Paths.get(getClass().getResource("/modified.md").toURI())));
    String patch = new DmpPatchService().createPatch(original, modified);
    ResponseEntity<?> response = testInstance.update("1", patch);

    assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());

    assertEquals(instance.getContent(), modified);

}

From source file:ca.qhrtech.controllers.ResultController.java

@ApiMethod(description = "Deletes the Game Result at the specified location")
@RequestMapping(value = "/result/{id}", method = RequestMethod.DELETE)
public ResponseEntity<Void> deleteResult(@PathVariable("id") long id) {
    if (resultService.findResultById(id) == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }/*  w  ww.  j ava2 s  .  c  o m*/
    resultService.deleteResult(id);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

From source file:com.consol.citrus.demo.javaland.EmployeeResourceTest.java

@Test
@InSequence(3)//w  w  w. j av a  2 s  .co m
@CitrusTest
public void testPut(@CitrusResource TestDesigner citrus) {
    citrus.http().client(serviceUri).put().contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .payload("name=Howard&age=21&email=howard@example.com");

    citrus.http().client(serviceUri).response(HttpStatus.NO_CONTENT);

    citrus.http().client(serviceUri).get().accept(MediaType.APPLICATION_XML);

    citrus.http().client(serviceUri).response(HttpStatus.OK)
            .payload("<employees>" + "<employee>" + "<age>20</age>" + "<name>Penny</name>" + "</employee>"
                    + "<employee>" + "<age>21</age>" + "<name>Leonard</name>" + "</employee>" + "<employee>"
                    + "<age>22</age>" + "<name>Sheldon</name>" + "</employee>" + "<employee>" + "<age>21</age>"
                    + "<name>Howard</name>" + "<email>howard@example.com</email>" + "</employee>"
                    + "</employees>");

    citrusFramework.run(citrus.getTestCase());
}

From source file:org.zalando.github.spring.MembersTemplate.java

@Override
public boolean isPublicMemberOfOrganization(String organization, String username) {
    Map<String, Object> uriVariables = new HashMap<>();
    uriVariables.put("organization", organization);
    uriVariables.put("username", username);
    HttpStatus status = HttpStatus.NOT_FOUND;
    try {//from w w  w. ja  v a2 s. c  om

        ResponseEntity<Void> responseEntity = getRestOperations().getForEntity(
                buildUri("/orgs/{organization}/public_members/{username}", uriVariables), Void.class);
        status = responseEntity.getStatusCode();
    } catch (HttpClientErrorException e) {
        // skip
    }
    return HttpStatus.NO_CONTENT.equals(status) ? true : false;
}

From source file:sample.RestTests.java

@Test
public void logout() {
    String auth = getAuth("user", "password");
    HttpHeaders headers = getHttpHeaders();
    headers.set(AUTHORIZATION, BASIC + auth);
    ResponseEntity<User> entity = getForUser(this.baseUrl + "/", headers, User.class);

    String token = entity.getHeaders().getFirst(X_AUTH_TOKEN);

    HttpHeaders logoutHeader = getHttpHeaders();
    logoutHeader.set(X_AUTH_TOKEN, token);
    ResponseEntity<User> logoutResponse = getForUser(this.baseUrl + "/logout", logoutHeader, User.class);
    assertThat(logoutResponse.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}