use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testGetSpecialDays_ByCalendar.
@Test
public void testGetSpecialDays_ByCalendar() {
WorkdaysCalendar expectedCalendar = new WorkdaysCalendar();
WorkdaysCalendar unexpectedCalendar = new WorkdaysCalendar();
String expectedName = "expected calendar name";
String unexpectedName = "unexpected calendar name";
expectedCalendar.setName(expectedName);
unexpectedCalendar.setName(unexpectedName);
Date start = new Date();
Date finish = getOffsetDate(1);
Day expectedDay = new Day(start, expectedCalendar);
Day unexpectedDay = new Day(start, unexpectedCalendar);
entityManager.persist(expectedCalendar);
entityManager.persist(unexpectedCalendar);
entityManager.persist(expectedDay);
entityManager.persist(unexpectedDay);
Period period = new Period(start, finish);
List<Day> actuals = workdaysCalendarRepository.getSpecialDays(expectedCalendar, period);
assertEquals(1, actuals.size());
assertTrue(actuals.contains(expectedDay));
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkdaysCalendarRepositoryTest method testGetSpecialDays_ByPeriod.
@Test
public void testGetSpecialDays_ByPeriod() {
WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar();
workdaysCalendar.setName("calendarName");
Date start = new GregorianCalendar(2011, 0, 2).getTime();
Date finish = new GregorianCalendar(2011, 0, 29).getTime();
Date expectedDate = new GregorianCalendar(2011, 0, 15).getTime();
Date unexpectedDate1 = new GregorianCalendar(2011, 0, 1).getTime();
Date unexpectedDate2 = new GregorianCalendar(2011, 0, 30).getTime();
Period period = new Period(start, finish);
Day expected1 = new Day(start, workdaysCalendar);
Day expected2 = new Day(expectedDate, workdaysCalendar);
Day expected3 = new Day(finish, workdaysCalendar);
Day unexpected1 = new Day(unexpectedDate1, workdaysCalendar);
Day unexpected2 = new Day(unexpectedDate2, workdaysCalendar);
entityManager.persist(workdaysCalendar);
entityManager.persist(expected1);
entityManager.persist(expected3);
entityManager.persist(expected2);
entityManager.persist(unexpected1);
entityManager.persist(unexpected2);
List<Day> actuals = workdaysCalendarRepository.getSpecialDays(workdaysCalendar, period);
assertEquals(3, actuals.size());
assertFalse(actuals.contains(unexpected1));
assertFalse(actuals.contains(unexpected2));
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursDataSetTest method testOpen_dataByPeriod.
@Test
public void testOpen_dataByPeriod() throws NamingException, NoSuchFieldException {
Date start = new GregorianCalendar(2018, 9, 29).getTime();
Date finish = new GregorianCalendar(2018, 9, 31).getTime();
Map<String, Object> parameters = new HashMap<>();
parameters.put(REPORT_PARAM_NAME_START_DATE, start);
parameters.put(REPORT_PARAM_NAME_END_DATE, finish);
parameters.put(REPORT_PARAM_NAME_EMPLOYEE_USERNAMES, new String[] { "user1", "user2" });
parameters.put(REPORT_PARAM_NAME_PROJECT_IDS, new Long[] { 1L, 2L });
parameters.put(REPORT_PARAM_NAME_HOUR_TYPE_IDS, new Long[] { 1L, 3L });
parameters.put(REPORT_PARAM_NAME_DEPARTMENTS, new String[] { "dep1", "dep2" });
expect(hoursDataSet.getHoursService()).andReturn(hoursService);
expect(hoursService.getHours(new Period(start, finish), Arrays.asList("user1", "user2"), Arrays.asList(1L, 2L), Arrays.asList(1L, 3L), Arrays.asList("dep1", "dep2"))).andReturn(Collections.emptyList());
replayAll();
hoursDataSet.open(null, parameters);
verifyAll();
}
Aggregations