ProfileManager { public void create(Profile profile) throws ServerException, ConflictException { requireNonNull(profile, "Required non-null profile"); profileDao.create(new ProfileImpl(profile)); }  Profile getById(String userId); void create(Profile profile); void update(Profile profile); void remove(String userId);  }
@Test public void shouldCreateProfile() throws Exception { final ProfileImpl profile = new ProfileImpl("user123"); profileManager.create(profile); final ArgumentCaptor<ProfileImpl> captor = ArgumentCaptor.forClass(ProfileImpl.class); verify(profileDao).create(captor.capture()); assertEquals(captor.getValue(), profile); }
@Test(expectedExceptions = NullPointerException.class) public void shouldThrowNpeWhenCreatingNullProfile() throws Exception { profileManager.create(null); }