@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); }
@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))); }