@Test
  public void testUpdateNote() {
    final Note newNote = new Note();
    newNote.setBody("updateme");

    Response responseMsg =
        target
            .path("notes")
            .request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.entity(newNote, MediaType.APPLICATION_JSON_TYPE));
    Note testNote = responseMsg.readEntity(Note.class);
    Assert.assertTrue("Note should have id greater than 0.", testNote.getId() > 0);

    final int testId = testNote.getId();
    final String testBody = "updated";
    testNote.setBody(testBody);

    responseMsg =
        target
            .path("notes/" + testId)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .put(Entity.entity(testNote, MediaType.APPLICATION_JSON_TYPE));
    testNote = responseMsg.readEntity(Note.class);

    Assert.assertEquals("Note has unexpected id.", testId, testNote.getId());
    Assert.assertEquals("Note has unexpected body.", testBody, testNote.getBody());
  }
  @Test
  public void testGetNoteById() {
    final int testId = 1;

    final Response responseMsg =
        target.path("notes/" + testId).request(MediaType.APPLICATION_JSON).get();
    final Note testNote = responseMsg.readEntity(Note.class);

    Assert.assertEquals("Note has unexpected id.", testId, testNote.getId());
    Assert.assertEquals("Note has unexpected body.", TEST_BODY + testId, testNote.getBody());
  }
  @Test
  public void testGetNotesWithQuery() {
    // test the first three (known) notes with a query
    final Response responseMsg =
        target
            .path("notes")
            .queryParam("query", TEST_BODY)
            .request(MediaType.APPLICATION_JSON)
            .get();
    final List<Note> testNotesList = responseMsg.readEntity(new GenericType<List<Note>>() {});

    Assert.assertEquals("Unexpected number of notes returned.", 3, testNotesList.size());
    for (final Note testNote : testNotesList) {
      if (testNote.getId() == 1) {
        Assert.assertEquals("Note has unexpected id.", 1, testNote.getId());
        Assert.assertEquals("Note has unexpected body.", TEST_BODY + 1, testNote.getBody());
      }
      if (testNote.getId() == 2) {
        Assert.assertEquals("Note has unexpected id.", 2, testNote.getId());
        Assert.assertEquals("Note has unexpected body.", TEST_BODY + 2, testNote.getBody());
      }
      if (testNote.getId() == 3) {
        Assert.assertEquals("Note has unexpected id.", 3, testNote.getId());
        Assert.assertEquals("Note has unexpected body.", TEST_BODY + 3, testNote.getBody());
      }
    }
  }
  @Test
  public void testUpdateNoteNotFound() {
    final Note newNote = new Note();
    newNote.setBody("updateme");

    final Response responseMsg =
        target
            .path("notes/" + newNote.getId())
            .request(MediaType.APPLICATION_JSON_TYPE)
            .put(Entity.entity(newNote, MediaType.APPLICATION_JSON_TYPE));

    Assert.assertEquals("Expected 404 Not Found.", 404, responseMsg.getStatus());
  }
  @Test
  public void testDeleteNoteById() {
    final String testBody = "deleteme";
    final Note newNote = new Note();
    newNote.setBody(testBody);

    Response responseMsg =
        target
            .path("notes")
            .request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.entity(newNote, MediaType.APPLICATION_JSON_TYPE));
    Note testNote = responseMsg.readEntity(Note.class);

    Assert.assertTrue("Note should have id greater than 0.", testNote.getId() > 0);

    final int testId = testNote.getId();

    target.path("notes/" + testId).request(MediaType.APPLICATION_JSON_TYPE).delete();

    responseMsg = target.path("notes/" + testId).request(MediaType.APPLICATION_JSON_TYPE).get();

    Assert.assertEquals("Expected 404 Not Found.", 404, responseMsg.getStatus());
  }
  @Test
  public void testAddNote() {
    final String testBody = "This is a note.";
    final Note newNote = new Note();
    newNote.setBody(testBody);

    final Response responseMsg =
        target
            .path("notes")
            .request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.entity(newNote, MediaType.APPLICATION_JSON_TYPE));
    final Note testNote = responseMsg.readEntity(Note.class);

    Assert.assertNotSame("Note has unexpected id.", 0, testNote.getId());
    Assert.assertEquals("Note has unexpected body.", testBody, testNote.getBody());
  }