ProfileManager { public Profile getById(String userId) throws NotFoundException, ServerException { requireNonNull(userId, "Required non-null user id"); return profileDao.getById(userId); }  Profile getById(String userId); void create(Profile profile); void update(Profile profile); void remove(String userId);  }
@Test public void shouldGetProfileById() throws Exception { final ProfileImpl profile = new ProfileImpl("user123"); when(profileDao.getById(profile.getUserId())).thenReturn(profile); assertEquals(profile, profileManager.getById(profile.getUserId())); }
@Test(expectedExceptions = NullPointerException.class) public void shouldThrowNpeWhenGettingProfileByNullId() throws Exception { profileManager.getById(null); }