Search in sources :

Example 1 with TeamFilter

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

the class TeamSynchronizerTest method testImportTeam_ifTeamNotChanged.

@Test
public void testImportTeam_ifTeamNotChanged() throws Exception {
    Employee employee = new Employee("employee");
    Project project = new Project();
    setField(project, "id", 1L);
    project.addTeamMember(employee);
    project.setTeamFilter(new TeamFilter(FilterType.PROJECT_CODES, "foreign code"));
    List<Employee> projectTeam = Arrays.asList(employee);
    expect(projectRepository.fetchComplete(project)).andReturn(project);
    expect(projectService.getSubprojectsByProject(project)).andReturn(Arrays.asList(project));
    expect(teamTrackingSystem.getTeam(project)).andReturn(projectTeam);
    expect(projectService.addTeamMembers(project, new ArrayList<>())).andReturn(new ArrayList<>());
    replay(projectRepository, projectService, teamTrackingSystem);
    teamSynchronizer.importTeam(project);
    verify(projectRepository, projectService, teamTrackingSystem);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Test(org.junit.Test)

Example 2 with TeamFilter

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

the class TeamSynchronizerTest method testImportTeam_ifBasedOnMaster.

@Test
public void testImportTeam_ifBasedOnMaster() throws Exception {
    Employee employee = new Employee("employee");
    Project project = new Project();
    setField(project, "id", 1L);
    project.addTeamMember(employee);
    project.setTeamFilter(new TeamFilter(FilterType.BASED_ON_MASTER));
    List<Employee> projectTeam = Arrays.asList(new Employee("new employee"));
    expect(projectRepository.fetchComplete(project)).andReturn(project);
    expect(projectService.getSubprojectsByProject(project)).andReturn(Arrays.asList(project));
    expect(teamTrackingSystem.getTeam(project)).andReturn(projectTeam);
    expect(projectService.addTeamMembers(project, new ArrayList<>())).andReturn(new ArrayList<>());
    expect(projectRepository.update(project)).andReturn(project);
    expect(mailTemplateManager.getTemplateText(anyString(), anyObject(Map.class))).andReturn("").anyTimes();
    replay(projectRepository, projectService, teamTrackingSystem, mailTemplateManager);
    teamSynchronizer.importTeam(project);
    verify(projectRepository, projectService, teamTrackingSystem, mailTemplateManager);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Test(org.junit.Test)

Example 3 with TeamFilter

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

the class TeamSynchronizerTest method testImportTeamByProject.

@Test
public void testImportTeamByProject() throws MessagingException {
    Project project = new Project();
    project.setTeamFilter(new TeamFilter(FilterType.PROJECT_CODES, "foreign code"));
    Employee employee = new Employee("employee");
    List<Employee> projectTeam = Arrays.asList(employee);
    expect(projectRepository.fetchComplete(project)).andReturn(project);
    expect(projectService.getSubprojectsByProject(project)).andReturn(new ArrayList<>());
    expect(teamTrackingSystem.getTeam(project)).andReturn(projectTeam);
    expect(projectService.addTeamMembers(project, projectTeam)).andReturn(projectTeam);
    expect(projectRepository.update(project)).andReturn(project);
    expect(mailTemplateManager.getTemplateText(anyString(), anyObject(Map.class))).andReturn("").anyTimes();
    replay(teamTrackingSystem, projectRepository, projectService, mailTemplateManager);
    teamSynchronizer.importTeam(project);
    verify(teamTrackingSystem, projectRepository, projectService, mailTemplateManager);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) TeamFilter(com.artezio.arttime.datamodel.TeamFilter) Test(org.junit.Test)

Example 4 with TeamFilter

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

the class TeamSynchronizerTest method createProject.

private Project createProject(Long id, Project master, FilterType filterType) throws NoSuchFieldException {
    Project project = new Project(master);
    setField(project, "id", id);
    TeamFilter teamFilter = new TeamFilter(filterType);
    project.setTeamFilter(teamFilter);
    return project;
}
Also used : Project(com.artezio.arttime.datamodel.Project) TeamFilter(com.artezio.arttime.datamodel.TeamFilter)

Example 5 with TeamFilter

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

the class LdapAdapterTest method testGetTeam_TwoTeamCodes.

@Test
public void testGetTeam_TwoTeamCodes() 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,_ART-PRJ-ART-TIME-PM");
    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)

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