use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class TeamSynchronizerTest method testGetEmployeesFromProjectTree_startingFromSubproject.
@Test
public void testGetEmployeesFromProjectTree_startingFromSubproject() {
Employee employee1 = new Employee("emp1");
Employee employee2 = new Employee("emp2");
Employee employee3 = new Employee("emp3");
Employee employee4 = new Employee("emp4");
Employee employee5 = new Employee("emp5");
Project master = new Project();
master.setCode("master");
master.setTeamFilter(new TeamFilter(Type.PROJECT_CODES, "abc"));
master.addTeamMember(employee1);
Project subProjectBasedOnMaster1 = new Project(master);
subProjectBasedOnMaster1.setCode("subBased1");
subProjectBasedOnMaster1.setTeamFilter(new TeamFilter(BASED_ON_MASTER));
subProjectBasedOnMaster1.addTeamMember(employee2);
subProjectBasedOnMaster1.addTeamMember(employee3);
Project subProjectBasedOnMaster2 = new Project(master);
subProjectBasedOnMaster2.setCode("subBased2");
subProjectBasedOnMaster2.setTeamFilter(new TeamFilter(BASED_ON_MASTER));
subProjectBasedOnMaster2.addTeamMember(employee4);
Project subProjectNotBasedOnMaster = new Project(master);
subProjectNotBasedOnMaster.setCode("subNotBased");
subProjectNotBasedOnMaster.setTeamFilter(new TeamFilter(Type.PROJECT_CODES));
subProjectNotBasedOnMaster.addTeamMember(employee5);
ProjectRepository.ProjectQuery query = mock(ProjectRepository.ProjectQuery.class);
ProjectRepository.ProjectQuery query1 = mock(ProjectRepository.ProjectQuery.class);
ProjectRepository.ProjectQuery query2 = mock(ProjectRepository.ProjectQuery.class);
expect(projectRepository.query()).andReturn(query).times(2);
expect(query.masters(asList(master))).andReturn(query1);
expect(query.masters(asList(subProjectBasedOnMaster1, subProjectBasedOnMaster2))).andReturn(query2);
expect(query1.status(ACTIVE)).andReturn(query1);
expect(query1.list()).andReturn(asList(subProjectBasedOnMaster1, subProjectBasedOnMaster2, subProjectNotBasedOnMaster));
expect(query2.status(ACTIVE)).andReturn(query2);
expect(query2.list()).andReturn(emptyList());
replay(projectRepository, query, query1, query2);
List<Employee> teamFromSubproject = teamSynchronizer.getEmployeesFromProjectTree(subProjectBasedOnMaster1);
verify(projectRepository, query);
assertTrue(teamFromSubproject.contains(employee1));
assertTrue(teamFromSubproject.contains(employee2));
assertTrue(teamFromSubproject.contains(employee3));
assertTrue(teamFromSubproject.contains(employee4));
assertFalse(teamFromSubproject.contains(employee5));
}
use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class TeamSynchronizerTest method testImportTeam_projectWithDisabledFilterType.
@Test
public void testImportTeam_projectWithDisabledFilterType() {
Project project = new Project();
project.setTeamFilter(new TeamFilter(DISABLED));
Employee employee1 = new Employee("employee1");
employee1.setFormer(true);
Employee employee2 = new Employee("employee2");
project.setTeam(asList(employee1, employee2));
EasyMock.expect(projectRepository.update(project)).andReturn(project);
notificationManager.notifyAboutTeamChanges(project, asList(employee1), emptyList());
EasyMock.expectLastCall();
employeeService.setCalendar(emptyList());
EasyMock.expectLastCall();
replay(employeeService, projectRepository, teamTrackingSystem, notificationManager);
teamSynchronizer.importTeam(project);
verify(employeeService, projectRepository, teamTrackingSystem, notificationManager);
ListAssert.assertEquals(asList(employee2), new ArrayList<>(project.getTeam()));
}
use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class TeamSynchronizerTest method testImportTeam_subprojectWithProjectCodeFilterType_MasterWithDisabledFilterType.
@Test
public void testImportTeam_subprojectWithProjectCodeFilterType_MasterWithDisabledFilterType() throws NoSuchFieldException {
Project master = new Project();
master.setTeamFilter(new TeamFilter(DISABLED));
Project subproject = new Project(master);
subproject.setTeamFilter(new TeamFilter(PROJECT_CODES));
Employee employee1 = new Employee("employee1");
employee1.setFormer(true);
Employee employee2 = new Employee("employee2");
List<Employee> teamMembers = asList(employee1, employee2);
master.setTeam(teamMembers);
subproject.setTeam(teamMembers);
ProjectRepository.ProjectQuery projectQuery = Mockito.mock(ProjectRepository.ProjectQuery.class, Mockito.RETURNS_DEEP_STUBS);
teamSynchronizer = createMockBuilder(TeamSynchronizer.class).addMockedMethod("getTeam", Project.class).createMock();
setField(teamSynchronizer, "teamTrackingSystem", teamTrackingSystem);
setField(teamSynchronizer, "projectRepository", projectRepository);
setField(teamSynchronizer, "notificationManager", notificationManager);
setField(teamSynchronizer, "employeeService", employeeService);
EasyMock.expect(teamSynchronizer.getTeam(subproject)).andReturn(asList(employee2));
EasyMock.expect(projectRepository.query()).andReturn(projectQuery);
Mockito.when(projectQuery.masters(asList(subproject)).status(ACTIVE).list()).thenReturn(emptyList());
EasyMock.expect(projectRepository.update(subproject)).andReturn(subproject);
notificationManager.notifyAboutTeamChanges(subproject, asList(employee1), emptyList());
EasyMock.expectLastCall();
employeeService.setCalendar(emptyList());
EasyMock.expectLastCall();
replay(employeeService, projectRepository, teamTrackingSystem, notificationManager, teamSynchronizer);
teamSynchronizer.importTeam(subproject);
EasyMock.verify(employeeService, projectRepository, teamTrackingSystem, notificationManager);
Mockito.verify(projectQuery.masters(asList(subproject)).status(ACTIVE)).list();
ListAssert.assertEquals(asList(employee2), new ArrayList<>(subproject.getTeam()));
}
use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class TeamSynchronizerTest method testImportTeam_subprojectBasedOnMaster.
@Test
public void testImportTeam_subprojectBasedOnMaster() throws NoSuchFieldException {
Project master = new Project();
master.setCode("master");
master.setTeamFilter(new TeamFilter(Type.PROJECT_CODES));
Project subProjectBasedOnMaster = new Project(master);
subProjectBasedOnMaster.setTeamFilter(new TeamFilter(BASED_ON_MASTER));
subProjectBasedOnMaster.setCode("subBased");
Project subProjectNotBasedOnMaster = new Project(master);
subProjectNotBasedOnMaster.setTeamFilter(new TeamFilter(Type.PROJECT_CODES));
subProjectNotBasedOnMaster.setCode("subNotBased");
Employee employee1 = new Employee("emp1");
Employee employee2 = new Employee("emp2");
Employee employee3 = new Employee("emp3");
Employee employee4 = new Employee("emp4");
List<Employee> employeesFromTrackingSystem = asList(employee1, employee2, employee3, employee4);
master.addTeamMember(employee1);
master.addTeamMember(employee2);
subProjectBasedOnMaster.addTeamMember(employee3);
subProjectNotBasedOnMaster.addTeamMember(employee1);
teamSynchronizer = createMockBuilder(TeamSynchronizer.class).addMockedMethod("getCurrentTeamMembers", Project.class).addMockedMethod("getNewTeamMembers", Project.class, List.class, List.class).addMockedMethod("getTeam", Project.class).createMock();
setField(teamSynchronizer, "teamTrackingSystem", teamTrackingSystem);
setField(teamSynchronizer, "employeeService", employeeService);
setField(teamSynchronizer, "notificationManager", notificationManager);
expect(teamSynchronizer.getTeam(subProjectBasedOnMaster)).andReturn(employeesFromTrackingSystem);
expect(teamSynchronizer.getCurrentTeamMembers(subProjectBasedOnMaster)).andReturn(asList(employee1, employee2, employee3));
expect(teamSynchronizer.getNewTeamMembers(anyObject(), anyObject(), anyObject())).andReturn(emptyList());
replay(teamTrackingSystem, teamSynchronizer);
teamSynchronizer.importTeam(subProjectBasedOnMaster);
verify(teamTrackingSystem, teamSynchronizer);
assertTrue(subProjectBasedOnMaster.isTeamMember(employee3));
assertFalse(subProjectBasedOnMaster.isTeamMember(employee1));
assertFalse(subProjectBasedOnMaster.isTeamMember(employee2));
assertFalse(subProjectBasedOnMaster.isTeamMember(employee4));
}
use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class TeamSynchronizerTest method testGetCurrentTeamMembers.
@Test
public void testGetCurrentTeamMembers() {
Project project = new Project();
project.setTeamFilter(new TeamFilter(Type.PROJECT_CODES, "abc"));
Project subproject = new Project(project);
subproject.setTeamFilter(new TeamFilter(DISABLED));
Employee employee1 = new Employee("emp1");
Employee employee2 = new Employee("emp2");
Employee employee3 = new Employee("emp3");
project.addTeamMember(employee1);
project.addTeamMember(employee2);
subproject.addTeamMember(employee2);
subproject.addTeamMember(employee3);
ProjectRepository.ProjectQuery query = mock(ProjectRepository.ProjectQuery.class);
expect(projectRepository.query()).andReturn(query);
expect(query.masters(asList(project))).andReturn(query);
expect(query.status(ACTIVE)).andReturn(query);
expect(query.list()).andReturn(asList(subproject));
replay(projectRepository, query);
List<Employee> currentTeamMembers = teamSynchronizer.getCurrentTeamMembers(project);
verify(projectRepository, query);
assertTrue(currentTeamMembers.containsAll(project.getTeam()));
assertFalse(currentTeamMembers.contains(employee3));
}
Aggregations