use of com.artezio.arttime.datamodel.Project 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);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifEmployeesDepartmentsAreEmpty.
@Test
public void testGetEmployeesByDepartments_ifEmployeesDepartmentsAreEmpty() {
Employee employee1 = new Employee("employee1");
employee1.setDepartment("department1");
Employee employee2 = new Employee("employee2");
employee2.setDepartment("department2");
Employee employee3 = new Employee("employee3");
employee3.setDepartment("department3");
Project project1 = new Project();
project1.addTeamMember(employee1);
project1.addTeamMember(employee2);
Project project2 = new Project();
project2.addTeamMember(employee1);
project2.addTeamMember(employee3);
Filter filter = new Filter();
filter.setEmployees(Collections.emptyList());
filter.setDepartments(Collections.emptyList());
entityManager.persist(project1);
entityManager.persist(project2);
entityManager.persist(employee1);
entityManager.persist(employee2);
entityManager.persist(employee3);
entityManager.flush();
List<Employee> expected = Arrays.asList(employee1, employee2, employee3);
List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
ListAssert.assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class FilterRepositoryTest method testFetchDetails.
@Test
public void testFetchDetails() throws NoSuchMethodException, SecurityException, NoSuchFieldException {
Filter filter = new Filter();
Project project = new Project();
List<Project> projects = Arrays.asList(project);
filter.setProjects(projects);
Project projectLoaded = new Project();
List<Project> projectsLoaded = Arrays.asList(projectLoaded);
entityManager.persist(project);
entityManager.persist(projectLoaded);
entityManager.persist(filter);
Method fetchCompleteMethod = ProjectRepository.class.getMethod("fetchComplete", List.class);
projectRepository = EasyMock.createMockBuilder(ProjectRepository.class).addMockedMethod(fetchCompleteMethod).createMock();
setField(filterRepository, "projectRepository", projectRepository);
PowerMock.mockStatic(Hibernate.class);
Hibernate.initialize(filter.getDepartments());
Hibernate.initialize(filter.getEmployees());
Hibernate.initialize(filter.getProjects());
Hibernate.initialize(filter.getHourTypes());
EasyMock.expect(projectRepository.fetchComplete(projects)).andReturn(projectsLoaded);
PowerMock.replayAll(Hibernate.class, projectRepository);
filterRepository.fetchDetails(filter);
PowerMock.verifyAll();
assertSame(projectLoaded, filter.getProjects().get(0));
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class FilterRepositoryTest method testFetchDetails_ifFilterNoPersisted.
@Test
public void testFetchDetails_ifFilterNoPersisted() throws NoSuchMethodException, SecurityException, NoSuchFieldException {
Filter filter = new Filter();
Project project = new Project();
List<Project> projects = Arrays.asList(project);
filter.setProjects(projects);
Project projectLoaded = new Project();
List<Project> projectsLoaded = Arrays.asList(projectLoaded);
entityManager.persist(project);
entityManager.persist(projectLoaded);
Method fetchCompleteMethod = ProjectRepository.class.getMethod("fetchComplete", List.class);
projectRepository = EasyMock.createMockBuilder(ProjectRepository.class).addMockedMethod(fetchCompleteMethod).createMock();
setField(filterRepository, "projectRepository", projectRepository);
EasyMock.expect(projectRepository.fetchComplete(projects)).andReturn(projectsLoaded);
EasyMock.replay(projectRepository);
filterRepository.fetchDetails(filter);
EasyMock.verify(projectRepository);
assertSame(projectLoaded, filter.getProjects().get(0));
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class HourTypeRepositoryTest method testRemoveHourType_RemoveForbidden.
@Test(expected = PersistenceException.class)
public void testRemoveHourType_RemoveForbidden() throws ActualTimeRemovalException {
HourType hourType = new HourType();
Project project = new Project();
project.addAccountableHours(hourType);
entityManager.persist(hourType);
entityManager.persist(project);
hourTypeRepository.remove(hourType);
}
Aggregations