use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class TeamSynchronizerTest method testImportTeam_subprojectWithBasedOnMasterFilterType_MasterWithDisabledFilterType.
@Test
public void testImportTeam_subprojectWithBasedOnMasterFilterType_MasterWithDisabledFilterType() {
Project master = new Project();
master.setTeamFilter(new TeamFilter(DISABLED));
Project subproject = new Project(master);
subproject.setTeamFilter(new TeamFilter(BASED_ON_MASTER));
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);
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.importTeam(subproject);
verify(employeeService, projectRepository, teamTrackingSystem, notificationManager);
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 testGetEmployeesFromProjectTree.
@Test
public void testGetEmployeesFromProjectTree() {
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> teamFromMaster = teamSynchronizer.getEmployeesFromProjectTree(master);
verify(projectRepository, query);
assertTrue(teamFromMaster.contains(employee1));
assertTrue(teamFromMaster.contains(employee2));
assertTrue(teamFromMaster.contains(employee3));
assertTrue(teamFromMaster.contains(employee4));
assertFalse(teamFromMaster.contains(employee5));
}
use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class TeamSynchronizerTest method testGetCurrentTeamMembers_existSubprojectsBasedOnMaster.
@Test
public void testGetCurrentTeamMembers_existSubprojectsBasedOnMaster() throws NoSuchFieldException {
Project project = new Project();
project.setTeamFilter(new TeamFilter(Type.PROJECT_CODES, "abc"));
Project subproject = new Project(project);
subproject.setTeamFilter(new TeamFilter(BASED_ON_MASTER));
Project subprojectNotBasedOnMaster = new Project(project);
subprojectNotBasedOnMaster.setTeamFilter(new TeamFilter(Type.PROJECT_CODES));
Employee employee1 = new Employee("emp1");
Employee employee2 = new Employee("emp2");
Employee employee3 = new Employee("emp3");
Employee employee4 = new Employee("emp4");
project.addTeamMember(employee1);
project.addTeamMember(employee2);
subproject.addTeamMember(employee2);
subproject.addTeamMember(employee3);
subprojectNotBasedOnMaster.addTeamMember(employee4);
teamSynchronizer = createMockBuilder(TeamSynchronizer.class).addMockedMethod("getEmployeesFromProjectTree", Project.class).createMock();
setField(teamSynchronizer, "projectRepository", projectRepository);
ProjectRepository.ProjectQuery query = mock(ProjectRepository.ProjectQuery.class);
expect(teamSynchronizer.getEmployeesFromProjectTree(project)).andReturn(asList(employee1, employee2, employee3));
expect(projectRepository.query()).andReturn(query);
expect(query.masters(asList(project))).andReturn(query);
expect(query.status(ACTIVE)).andReturn(query);
expect(query.list()).andReturn(asList(subproject, subprojectNotBasedOnMaster));
replay(projectRepository, teamSynchronizer, query);
List<Employee> currentTeamMembers = teamSynchronizer.getCurrentTeamMembers(project);
verify(projectRepository, teamSynchronizer, query);
assertTrue(currentTeamMembers.containsAll(project.getTeam()));
assertTrue(currentTeamMembers.containsAll(subproject.getTeam()));
assertFalse(currentTeamMembers.contains(employee4));
}
use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class TeamSynchronizerTest method testGetTeam_projectCodesFilterType.
@Test
public void testGetTeam_projectCodesFilterType() {
Project project = new Project();
String projectCodes = "code1, code2";
project.setTeamFilter(new TeamFilter(TeamFilter.Type.PROJECT_CODES, projectCodes));
Employee employee1 = new Employee("uname1");
Employee employee2 = new Employee("uname2");
expect(teamTrackingSystem.getTeamByGroupCode("code1")).andReturn(asList(employee1));
expect(teamTrackingSystem.getTeamByGroupCode("code2")).andReturn(asList(employee2));
replay(teamTrackingSystem);
List<Employee> actual = teamSynchronizer.getTeam(project);
verify(teamTrackingSystem);
assertNotNull(actual);
assertEquals(2, actual.size());
assertTrue(actual.contains(employee1));
assertTrue(actual.contains(employee2));
}
use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.
the class LdapAdapter method getTeam.
public List<Employee> getTeam(Project project) {
List<Employee> team = new ArrayList<Employee>();
TeamFilter teamFilter = project.getTeamFilter();
if (!TeamFilter.FilterType.DISABLED.equals(teamFilter.getFilterType())) {
switch(teamFilter.getFilterType()) {
case PROJECT_CODES:
team = listEmployeesByTeamCodes(teamFilter.getValue());
break;
case NATIVE:
Filter filter = new Filter(teamFilter.getValue(), null);
team = listEmployees(filter);
break;
case BASED_ON_MASTER:
return getTeam(project.getMaster());
default:
throw new IllegalStateException("No matching TeamFilter.FilterType for '" + teamFilter.getFilterType() + "' found.");
}
}
return new ArrayList<Employee>(team);
}
Aggregations