Search in sources :

Example 6 with TeamFilter

use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.

the class LdapAdapterTest method testGetTeam.

@Test
public void testGetTeam() throws Exception {
    Logger log = createMock(Logger.class);
    setField(ldapImpl, "log", log);
    Project project = new Project();
    TeamFilter teamFilter = new TeamFilter(FilterType.PROJECT_CODES, "_ART-PRJ-ART-TIME-PG");
    project.setTeamFilter(teamFilter);
    setField(ldapImpl, "workdaysCalendarRepository", workdaysCalendarRepository);
    expect(workdaysCalendarRepository.findDefaultCalendar(anyObject(Employee.class))).andReturn(null).anyTimes();
    replay(workdaysCalendarRepository);
    List<Employee> team = ldapImpl.getTeam(project);
    verify(workdaysCalendarRepository);
    assertTrue(team.size() > 0);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Logger(java.util.logging.Logger) Test(org.junit.Test)

Example 7 with TeamFilter

use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.

the class LdapAdapterTest method testListEmployeesByTeamCodes.

@Test
public void testListEmployeesByTeamCodes() throws Exception {
    Logger log = createMock(Logger.class);
    setField(ldapImpl, "log", log);
    Project project = new Project();
    TeamFilter teamFilter = new TeamFilter(FilterType.PROJECT_CODES, "_ART-PRJ-ART-TIME-PG");
    project.setTeamFilter(teamFilter);
    setField(ldapImpl, "workdaysCalendarRepository", workdaysCalendarRepository);
    expect(workdaysCalendarRepository.findDefaultCalendar(anyObject(Employee.class))).andReturn(null).anyTimes();
    replay(workdaysCalendarRepository);
    List<Employee> team = ldapImpl.getTeam(project);
    verify(workdaysCalendarRepository);
    assertTrue(team.size() > 0);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Logger(java.util.logging.Logger) Test(org.junit.Test)

Example 8 with TeamFilter

use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.

the class ProjectRepositoryIntegrationTest method createTestProject.

private Project createTestProject(String code, boolean isSubproject, Project master) {
    Project project = new Project();
    project.setCode(code);
    project.setStatus(ACTIVE);
    project.setAccountableHours(Arrays.asList(testHourType));
    project.setManagers(Arrays.asList(testEmployee));
    project.setAllowEmployeeReportTime(true);
    TeamFilter teamFilter;
    if (isSubproject) {
        project.setMaster(master);
        teamFilter = new TeamFilter(TeamFilter.Type.BASED_ON_MASTER);
    } else {
        teamFilter = new TeamFilter(TeamFilter.Type.DISABLED);
    }
    project.setTeamFilter(teamFilter);
    return project;
}
Also used : Project(com.artezio.arttime.datamodel.Project) TeamFilter(com.artezio.arttime.datamodel.TeamFilter)

Example 9 with TeamFilter

use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.

the class LdapAdapterIntegrationTest method testGetDepartments.

@Test
public void testGetDepartments() {
    Project project = new Project();
    TeamFilter teamFilter = new TeamFilter(TeamFilter.Type.DISABLED, "");
    project.setTeamFilter(teamFilter);
    Set<String> expected = Sets.newHashSet("Department1", "Department2");
    Set<String> actual = ldapAdapter.getDepartments();
    assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Test(org.junit.Test) IntegrationTest(com.artezio.arttime.markers.IntegrationTest)

Example 10 with TeamFilter

use of com.artezio.arttime.datamodel.TeamFilter in project ART-TIME by Artezio.

the class TeamSynchronizerTest method testGetEmployeesFromProjectTree_expectNoEmployeesFromClosedSubprojects.

@Test
public void testGetEmployeesFromProjectTree_expectNoEmployeesFromClosedSubprojects() {
    Employee employee1 = new Employee("emp1");
    Employee employee2 = new Employee("emp2");
    Employee employee3 = new Employee("emp3");
    Employee employee4 = new Employee("emp4");
    Project master = new Project();
    master.setCode("master");
    master.setTeamFilter(new TeamFilter(Type.PROJECT_CODES, "abc"));
    master.addTeamMember(employee1);
    Project activeSubproject = new Project(master);
    activeSubproject.setStatus(ACTIVE);
    activeSubproject.setCode("activeSubBased");
    activeSubproject.setTeamFilter(new TeamFilter(BASED_ON_MASTER));
    activeSubproject.addTeamMember(employee2);
    activeSubproject.addTeamMember(employee3);
    Project closedSubproject = new Project(master);
    closedSubproject.setStatus(Project.Status.CLOSED);
    closedSubproject.setCode("subBased2");
    closedSubproject.setTeamFilter(new TeamFilter(BASED_ON_MASTER));
    closedSubproject.addTeamMember(employee3);
    closedSubproject.addTeamMember(employee4);
    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(activeSubproject))).andReturn(query2);
    expect(query1.status(ACTIVE)).andReturn(query1);
    expect(query1.list()).andReturn(asList(activeSubproject));
    expect(query2.status(ACTIVE)).andReturn(query2);
    expect(query2.list()).andReturn(emptyList());
    replay(projectRepository, query, query1, query2);
    List<Employee> teamFromSubproject = teamSynchronizer.getEmployeesFromProjectTree(activeSubproject);
    verify(projectRepository, query);
    assertTrue(teamFromSubproject.contains(employee1));
    assertTrue(teamFromSubproject.contains(employee2));
    assertTrue(teamFromSubproject.contains(employee3));
    assertFalse(teamFromSubproject.contains(employee4));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) ProjectRepository(com.artezio.arttime.repositories.ProjectRepository) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Test(org.junit.Test)

Aggregations

TeamFilter (com.artezio.arttime.datamodel.TeamFilter)27 Project (com.artezio.arttime.datamodel.Project)26 Employee (com.artezio.arttime.datamodel.Employee)24 Test (org.junit.Test)24 ProjectRepository (com.artezio.arttime.repositories.ProjectRepository)6 Logger (java.util.logging.Logger)6 IntegrationTest (com.artezio.arttime.markers.IntegrationTest)2 HourType (com.artezio.arttime.datamodel.HourType)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 HashMap (java.util.HashMap)1