Пример #1
0
  @Before
  public void setUp_dependencies() {
    teamBusiness = new TeamBusinessImpl();

    teamDAO = createMock(TeamDAO.class);
    teamBusiness.setTeamDAO(teamDAO);

    userBusiness = createMock(UserBusiness.class);
    teamBusiness.setUserBusiness(userBusiness);
  }
Пример #2
0
  @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);
  }
Пример #3
0
  @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));
  }
Пример #4
0
 @Test(expected = IllegalArgumentException.class)
 public void testStoreTeam_nullCheck() {
   replayAll();
   teamBusiness.storeTeam(null, null, null, null);
   verifyAll();
 }