Search in sources :

Example 61 with Employee

use of com.artezio.arttime.datamodel.Employee 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 62 with Employee

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

the class TeamSynchronizerTest method testGetTeamMembers.

@Test
public void testGetTeamMembers() {
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    Employee employee3 = new Employee("employee3");
    Project project1 = new Project();
    project1.addTeamMember(employee1);
    Project project2 = new Project();
    project2.addTeamMember(employee2);
    project2.addTeamMember(employee3);
    List<Project> projects = Arrays.asList(project1, project2);
    List<Employee> expected = Arrays.asList(employee1, employee2, employee3);
    Set<Employee> actual = teamSynchronizer.getTeamMembers(projects);
    ListAssert.assertEquals(expected, new ArrayList<>(actual));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 63 with Employee

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

the class TeamSynchronizerTest method testGetFullTeam.

@Test
public void testGetFullTeam() throws Exception {
    Employee employee1 = new Employee("employee1");
    Employee employee2 = new Employee("employee2");
    Employee employee3 = new Employee("employee3");
    Employee employee4 = new Employee("employee4");
    Employee employee5 = new Employee("employee5");
    Project master = createProject(1L, null, FilterType.PROJECT_CODES);
    Project project01 = createProject(2L, master, FilterType.BASED_ON_MASTER);
    Project project02 = createProject(3L, master, FilterType.DISABLED);
    Project project11 = createProject(4L, project01, FilterType.BASED_ON_MASTER);
    Project project21 = createProject(5L, project02, FilterType.BASED_ON_MASTER);
    List<Project> projects = Arrays.asList(master, project01, project02, project11, project21);
    expect(projectService.getSubprojectsByProject(master)).andReturn(projects);
    master.addTeamMember(employee1);
    project01.addTeamMember(employee2);
    project11.addTeamMember(employee3);
    project02.addTeamMember(employee4);
    project21.addTeamMember(employee5);
    List<Employee> expected = Arrays.asList(employee1, employee2, employee3);
    replay(projectService);
    Set<Employee> actual = teamSynchronizer.getFullTeam(master);
    verify(projectService);
    ListAssert.assertEquals(expected, new ArrayList<>(actual));
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 64 with Employee

use of com.artezio.arttime.datamodel.Employee 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 65 with Employee

use of com.artezio.arttime.datamodel.Employee 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)

Aggregations

Employee (com.artezio.arttime.datamodel.Employee)201 Test (org.junit.Test)173 Project (com.artezio.arttime.datamodel.Project)121 HourType (com.artezio.arttime.datamodel.HourType)74 Hours (com.artezio.arttime.datamodel.Hours)65 Date (java.util.Date)39 BigDecimal (java.math.BigDecimal)33 Period (com.artezio.arttime.datamodel.Period)28 Filter (com.artezio.arttime.filter.Filter)23 ArrayList (java.util.ArrayList)20 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)19 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)18 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)15 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)13 HashMap (java.util.HashMap)12 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)7 Mail (com.artezio.arttime.services.mailing.Mail)7 ProjectRepository (com.artezio.arttime.services.repositories.ProjectRepository)7 List (java.util.List)7 Map (java.util.Map)7