@Before public void setUp_dependencies() { teamBusiness = new TeamBusinessImpl(); teamDAO = createMock(TeamDAO.class); teamBusiness.setTeamDAO(teamDAO); userBusiness = createMock(UserBusiness.class); teamBusiness.setUserBusiness(userBusiness); }
@Test public void testStoreTeam_newTeam() { Team team = new Team(); expect(teamDAO.create(team)).andReturn(555); expect(teamDAO.get(555)).andReturn(team); replayAll(); Team actual = teamBusiness.storeTeam(team, null, null, null); verifyAll(); assertEquals(team, actual); }
@Test public void testStoreTeam_existing() { Team team = new Team(); team.setId(123); User user = new User(); expect(userBusiness.retrieve(22)).andReturn(user); expect(userBusiness.retrieve(13)).andReturn(new User()); teamDAO.store(team); replayAll(); Team actual = teamBusiness.storeTeam(team, new HashSet<Integer>(Arrays.asList(22, 13)), null, null); verifyAll(); assertEquals(team, actual); assertEquals(2, team.getUsers().size()); assertTrue(team.getUsers().contains(user)); }
@Test(expected = IllegalArgumentException.class) public void testStoreTeam_nullCheck() { replayAll(); teamBusiness.storeTeam(null, null, null, null); verifyAll(); }