@Test(expected = NotFoundException.class)
  public void shouldFailUpdateNonexistentTodoItemIs() throws Exception {
    final TodoItem todoItem = createTodoItem();
    given(todoItems.updateTodoItem(todoItem.getId(), todoItem.getTitle(), todoItem.getCompleted()))
        .willReturn(Optional.empty());

    todoItemsResource.updateTodoItem(todoItem.getId(), todoItem);
  }
 public static void writeTodo(JsonWriter writer, TodoItem todo) throws IOException {
   writer.beginObject();
   writer.name("key").value(todo.getKey());
   writer.name("title").value(todo.getTitle());
   writer.name("completed").value(todo.isCompleted());
   writer.name("archived").value(todo.isArchived());
   writer.endObject();
 }
  @Test
  public void shouldUpdateTodoItem() throws Exception {
    final TodoItem todoItem = createTodoItem();
    given(todoItems.updateTodoItem(todoItem.getId(), todoItem.getTitle(), todoItem.getCompleted()))
        .willReturn(Optional.of(todoItem));

    final Response response = todoItemsResource.updateTodoItem(todoItem.getId(), todoItem);

    assertThat(response.getStatus(), is(equalTo(Status.OK)));
  }
  @Test
  public void shouldCreateTodoItem() throws Exception {
    final TodoItem todoItem = createTodoItem();
    final UriInfo uriInfo = mock(UriInfo.class);
    final UriBuilder uriBuilder = mock(UriBuilder.class);
    final URI todoUri = new URI(baseUri + todoItem.getId());
    given(todoItems.createTodoItem(todoItem.getTitle(), todoItem.getCompleted()))
        .willReturn(todoItem);
    given(uriInfo.getAbsolutePathBuilder()).willReturn(uriBuilder);
    given(uriBuilder.path("/" + todoItem.getId())).willReturn(uriBuilder);
    given(uriBuilder.build()).willReturn(todoUri);

    final Response response = todoItemsResource.createTodoItem(todoItem, uriInfo);

    assertThat(response.getStatus(), is(equalTo(Status.CREATED)));
  }
 @Test
 public void testSetterGetterTitle() {
   underTest.setTitle("99l");
   assertEquals("99l", underTest.getTitle());
 }