use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class IntegrationFacadeTest method testGetHours.
@Test
public void testGetHours() {
List<Hours> expecteds = new ArrayList<>();
Project project = new Project();
project.setCode("TEST-PROJECT");
Date from = new GregorianCalendar(2011, 1, 5).getTime();
Date to = new GregorianCalendar(2011, 1, 15).getTime();
Period period = new Period(from, to);
Filter expectedFilter = new Filter();
expectedFilter.setProjects(asList(project));
expectedFilter.setApproved(null);
RangePeriodSelector rangePeriodSelector = new RangePeriodSelector(period);
expectedFilter.setRangePeriodSelector(rangePeriodSelector);
HoursSearchCriteria hoursSearchCriteria = new HoursSearchCriteria(from, to, true, asList("TEST-PROJECT"));
Project anotherProject = new Project();
anotherProject.setCode("OtherProject");
List<Project> allProjects = Arrays.asList(project, anotherProject);
expect(projectService.getAll()).andReturn(allProjects).anyTimes();
EasyMock.expect(hoursService.getHours(expectedFilter)).andReturn(expecteds);
EasyMock.replay(projectService, hoursService);
List<Hours> actuals = facade.getHours(hoursSearchCriteria);
verify(projectService, hoursService);
assertSame(expecteds, actuals);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifEmployeesAreEmpty.
@Test
public void testGetEmployeesByDepartments_ifEmployeesAreEmpty() {
Employee employee1 = new Employee("employee1", "test1", "test1", "department1");
Employee employee2 = new Employee("employee2", "test2", "test2", "department2");
Filter filter = new Filter();
filter.setEmployees(Collections.emptyList());
filter.setDepartments(Arrays.asList("department1", "department2"));
entityManager.persist(employee1);
entityManager.persist(employee2);
List<Employee> expected = filter.getEmployees();
List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
ListAssert.assertEquals(expected, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class EmployeeRepositoryTest method testGetEmployeesByDepartments.
@Test
public void testGetEmployeesByDepartments() {
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);
entityManager.persist(project1);
entityManager.persist(project2);
entityManager.persist(employee1);
entityManager.persist(employee2);
entityManager.persist(employee3);
Filter filter = new Filter();
filter.setProjects(Arrays.asList(project1, project2));
filter.setEmployees(Arrays.asList(employee1, employee2, employee3));
filter.setDepartments(Arrays.asList("department1", "department2", "department3"));
List<Employee> expected = Arrays.asList(employee1, employee2, employee3);
List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
ListAssert.assertEquals(expected, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterRepositoryTest method testCreate.
@Test
public void testCreate() {
Filter expected = new Filter();
Filter actual = filterRepository.create(expected);
assertSame(expected, actual);
assertNotNull(actual.getId());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class FilterRepositoryTest method testUpdate.
@Test
public void testUpdate() {
Filter expected = new Filter();
expected.setName("old filter name");
entityManager.persist(expected);
entityManager.flush();
entityManager.clear();
expected.setName("new filter name");
filterRepository.update(expected);
Filter actual = entityManager.find(Filter.class, expected.getId());
assertEquals(expected.getName(), actual.getName());
}
Aggregations