Search in sources :

Example 91 with Period

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));
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Period(com.artezio.arttime.datamodel.Period) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 92 with Period

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));
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Period(com.artezio.arttime.datamodel.Period) Day(com.artezio.arttime.datamodel.Day) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) Test(org.junit.Test)

Example 93 with Period

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();
}
Also used : HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Period(com.artezio.arttime.datamodel.Period) Date(java.util.Date) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Period (com.artezio.arttime.datamodel.Period)93 Test (org.junit.Test)87 Employee (com.artezio.arttime.datamodel.Employee)59 Date (java.util.Date)56 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)44 HourType (com.artezio.arttime.datamodel.HourType)43 Project (com.artezio.arttime.datamodel.Project)42 Hours (com.artezio.arttime.datamodel.Hours)40 BigDecimal (java.math.BigDecimal)34 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)22 Day (com.artezio.arttime.datamodel.Day)17 HashMap (java.util.HashMap)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)13 List (java.util.List)13 Map (java.util.Map)11 ArrayList (java.util.ArrayList)8 GregorianCalendar (java.util.GregorianCalendar)8 HoursRepository (com.artezio.arttime.repositories.HoursRepository)7 Mail (com.artezio.arttime.services.mailing.Mail)7