Search in sources :

Example 41 with Project

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

the class TeamSynchronizerTest method testGetCommonImportSettingsProjects.

@Test
public void testGetCommonImportSettingsProjects() throws NoSuchFieldException {
    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);
    List<Project> expected = Arrays.asList(master, project01, project11);
    replay(projectService);
    List<Project> actual = teamSynchronizer.getCommonImportSettingsProjects(master);
    verify(projectService);
    ListAssert.assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Test(org.junit.Test)

Example 42 with Project

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

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

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

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

Aggregations

Project (com.artezio.arttime.datamodel.Project)310 Test (org.junit.Test)278 Employee (com.artezio.arttime.datamodel.Employee)195 HourType (com.artezio.arttime.datamodel.HourType)119 Hours (com.artezio.arttime.datamodel.Hours)108 Date (java.util.Date)61 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)56 Period (com.artezio.arttime.datamodel.Period)43 BigDecimal (java.math.BigDecimal)39 Filter (com.artezio.arttime.filter.Filter)33 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 ArrayList (java.util.ArrayList)18 Arrays.asList (java.util.Arrays.asList)18 ProjectRepository (com.artezio.arttime.repositories.ProjectRepository)17 List (java.util.List)17 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 HashMap (java.util.HashMap)13 Map (java.util.Map)11