@Test public void shouldListAllUsers() throws Exception { stubServiceToReturnExistingUsers(10); Collection<User> users = userController.listUsers(); assertNotNull(users); assertEquals(10, users.size()); // verify user was passed to UserService verify(userService, times(1)).getAll(); }
@Test public void shouldCreateUser() throws Exception { final User savedUser = stubServiceToReturnStoredUser(); final User user = UserUtil.createUser(); User returnedUser = userController.createUser(user); // verify user was passed to UserService verify(userService, times(1)).create(user); assertEquals("Returned user should come from the service", savedUser, returnedUser); }