use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class ProjectServiceTest method testGetAvailableProjects_userIsExec_expectAllProjects.
@Test
public void testGetAvailableProjects_userIsExec_expectAllProjects() throws NoSuchFieldException {
Employee currentEmployee = new Employee("curr", "fn", "ln", "mail");
Employee manager1 = new Employee("man1", "fn1", "ln1", "mail1");
Employee manager2 = new Employee("man2", "fn2", "ln2", "mail2");
Project project1 = createProject(1L, null);
Project project2 = createProject(2L, null);
Project project3 = createProject(3L, null);
project1.setManagers(Arrays.asList(manager1));
project2.setManagers(Arrays.asList(manager2));
project3.setManagers(Arrays.asList(currentEmployee));
Subject subject = createMock(Subject.class);
PowerMock.mockStatic(SecurityUtils.class);
projectRepository = createMock(ProjectRepository.class);
setField(projectService, "projectRepository", projectRepository);
expect(SecurityUtils.getSubject()).andReturn(subject);
expect(subject.hasRole(UserRoles.EXEC_ROLE)).andReturn(true);
expect(projectRepository.getAll()).andReturn(Arrays.asList(project1, project2, project3));
List<Project> expected = Arrays.asList(project1, project2, project3);
PowerMock.replayAll(projectRepository, subject, SecurityUtils.class);
List<Project> actual = projectService.getAvailableProjects(currentEmployee);
PowerMock.verifyAll();
ListAssert.assertEquals(expected, actual);
}
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);
}
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));
}
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));
}
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);
}
Aggregations