示例#1
0
 @Test
 public void getTeamsForUser() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   teamDao.save(insertedTeam);
   List<Team> teams = teamDao.getTeamsForUser(insertedUser);
   assertEquals("List of teams for particular user should not be empty", 1, teams.size());
   Team selectedTeam = teamDao.getTeamsForUser(insertedUser).get(0);
   assertEquals("Selected team is not equal to expected one", insertedTeam, selectedTeam);
 }
示例#2
0
 @Test
 public void getTeamByIdTest() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   teamDao.save(insertedTeam);
   teamDao.flushSession();
   long insertedTeamId = insertedTeam.getIdTeam();
   Team selectedTeam = teamDao.getTeam(insertedTeamId);
   assertEquals("Selected teams are not equal", selectedTeam, insertedTeam);
 }
示例#3
0
 @Test
 public void loadTeamByIdTest() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   teamDao.save(insertedTeam);
   teamDao.flushSession();
   long teamId = insertedTeam.getIdTeam();
   Team loadedTeam = teamDao.loadTeam(teamId);
   assertEquals("Loaded object is not equal", loadedTeam.getAlias(), insertedTeam.getAlias());
   assertEquals("Loaded object is not equal", loadedTeam.getName(), insertedTeam.getName());
 }
示例#4
0
 @Test
 public void getTeamsByProject() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   teamDao.save(insertedTeam);
   teamDao.flushSession();
   List<Team> teams = teamDao.getTeamsForProject(insertedProject);
   if (teams.size() != 1) {
     fail("List should have one related team");
   }
   assertEquals("Selected team is not equal", teams.get(0), insertedTeam);
 }
示例#5
0
 @Test
 public void getTeamId() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   teamDao.save(insertedTeam);
   teamDao.flushSession();
   long teamId = teamDao.getTeamId(insertedTeam.getAlias());
   assertEquals(
       "Team's selected id is not equal to expected one",
       insertedTeam.getIdTeam(),
       new Long(teamId));
 }
示例#6
0
 @Test
 public void saveTest() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   int rowsBeforeSave = super.countRowsInTable("Teams");
   teamDao.save(insertedTeam);
   teamDao.flushSession();
   int rowsAfterSave = super.countRowsInTable("Teams");
   assertEquals("Number of rows has not increased", rowsBeforeSave + 1, rowsAfterSave);
   long insertedTeamId = insertedTeam.getIdTeam();
   assertEquals("Teams are not equal", teamDao.getTeam(insertedTeamId), insertedTeam);
 }
示例#7
0
 @Test
 public void countTeamsForSprintTest() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   pbiDao.save(insertedPBI);
   sprintDao.save(insertedSprint);
   teamDao.save(insertedTeam);
   workItemDao.save(insertedWorkItem);
   teamDao.flushSession();
   assertEquals("Count number is not valid", 1, teamDao.countTeamsForSprint(insertedSprint));
   workItemDao.delete(insertedWorkItem);
   teamDao.delete(insertedTeam);
   teamDao.flushSession();
   assertEquals("Count number is not valid", 0, teamDao.countTeamsForSprint(insertedSprint));
 }
示例#8
0
 @Test
 public void deleteByIdTest() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   int rowsBeforeInsert = super.countRowsInTable("Teams");
   teamDao.save(insertedTeam);
   teamDao.flushSession();
   long teamId = insertedTeam.getIdTeam();
   teamDao.delete(teamId);
   teamDao.flushSession();
   int rowsAfterDelete = super.countRowsInTable("Teams");
   assertEquals(
       "JDBC query must return the same number of teams", rowsBeforeInsert, rowsAfterDelete);
   Team selectedTeam = teamDao.getTeam(teamId);
   assertNull("Selected team after delete should be null", selectedTeam);
 }
示例#9
0
 @Test
 public void getTeamsTest() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   teamDao.save(insertedTeam);
   teamDao.flushSession();
   List<Team> teams = teamDao.getTeams();
   if (teams.isEmpty()) {
     fail("List of teams cannot be empty after insert");
   }
   assertEquals(
       "JDBC query must show the same number of teams",
       super.countRowsInTable("Teams"),
       teams.size());
   Team team = teams.get(teams.size() - 1);
   assertEquals("Selected team is not equal", team.getAlias(), "ZZ");
   assertEquals("Selected team is not equal", team.getName(), "Test Testowy");
 }
示例#10
0
 @Test
 public void deleteWithWorkItemsTest() {
   userDao.save(insertedUser);
   projectDao.save(insertedProject);
   pbiDao.save(insertedPBI);
   sprintDao.save(insertedSprint);
   teamDao.save(insertedTeam);
   workItemDao.save(insertedWorkItem);
   insertedTeam.addWorkItem(insertedWorkItem);
   insertedWorkItem.setTeam(insertedTeam);
   teamDao.flushSession();
   long idTeam = insertedTeam.getIdTeam();
   teamDao.delete(insertedTeam);
   teamDao.flushSession();
   int counter =
       super.simpleJdbcTemplate.queryForInt(
           "select count(*) from Teams where idTeam=?", new Object[] {idTeam});
   assertEquals("JDBC query must return no teams with this id", 0, counter);
   counter =
       super.simpleJdbcTemplate.queryForInt(
           "select count(*) from WorkItems where idTeam=?", new Object[] {idTeam});
   assertEquals("JDBC query must return no workItems with this id", 0, counter);
 }