UserService { public User createUser(String name, String email) { failIfInvalid(name, email); User user = new User(name, email); Key key = keyFactory.newKey(user.getId()); Entity entity = Entity.newBuilder(key) .set("id", user.getId()) .set("name", name) .set("email", email) .build(); datastore.add(entity); return user; } UserService(Datastore datastore, String kind); List<User> getAllUsers(); User createUser(String name, String email); String deleteUser(String id); User updateUser(String id, String name, String email);  }
@Test public void testCreateUser() { String name = "myNewName"; String email = "mynew@email.com"; User actualUser = USER_SERVICE.createUser(name, email); assertEquals(name, actualUser.getName()); assertEquals(email, actualUser.getEmail()); assertNotNull(actualUser.getId()); try { USER_SERVICE.createUser(null, email); fail("Expected to fail because name is null."); } catch (IllegalArgumentException e) { assertEquals("Parameter 'name' cannot be empty", e.getMessage()); } try { USER_SERVICE.createUser(name, null); fail("Expected to fail because email is null."); } catch (IllegalArgumentException e) { assertEquals("Parameter 'email' cannot be empty", e.getMessage()); } }