Search in sources :

Example 41 with Period

use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.

the class WeekSelectorTest method setNextPeriod.

@Test
public void setNextPeriod() throws ParseException, NoSuchFieldException {
    Date firstDayOfWeek = sdf.parse("28-04-2014");
    Date lastDayOfWeek = sdf.parse("4-05-2014");
    Period period = new Period(firstDayOfWeek, lastDayOfWeek);
    setField(weekSelector, "period", period);
    Period expected = new Period(sdf.parse("5-05-2014"), sdf.parse("11-05-2014"));
    weekSelector.setNextPeriod();
    Period actual = (Period) getField(weekSelector, "period");
    assertEquals(expected, actual);
}
Also used : Period(com.artezio.arttime.datamodel.Period) Date(java.util.Date) Test(org.junit.Test)

Example 42 with Period

use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.

the class RangePeriodSelectorTest method testSetCustomPeriod.

@Test
public void testSetCustomPeriod() throws ParseException, NoSuchFieldException {
    Period period = new Period(sdf.parse("1-05-2014"), sdf.parse("3-05-2014"));
    setField(rangePeriodSelector, "period", period);
    setField(rangePeriodSelector, "range", Range.WEEK);
    Period expectedPeriod = new Period(sdf.parse("1-05-2014"), sdf.parse("3-05-2014"));
    rangePeriodSelector.setCustomPeriod();
    Range actualRange = (Range) getField(rangePeriodSelector, "range");
    Period actualPeriod = (Period) getField(rangePeriodSelector, "period");
    assertEquals(Range.CUSTOM, actualRange);
    assertEquals(expectedPeriod, actualPeriod);
}
Also used : Period(com.artezio.arttime.datamodel.Period) Range(com.artezio.arttime.web.criteria.RangePeriodSelector.Range) Test(org.junit.Test)

Example 43 with Period

use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.

the class RangePeriodSelectorTest method testSetMonthPeriod.

@Test
public void testSetMonthPeriod() throws ParseException, NoSuchFieldException {
    Period period = new Period(sdf.parse("1-05-2014"), sdf.parse("3-05-2014"));
    setField(rangePeriodSelector, "period", period);
    setField(rangePeriodSelector, "range", Range.CUSTOM);
    Period expectedPeriod = new Period(sdf.parse("1-05-2014"), sdf.parse("31-05-2014"));
    rangePeriodSelector.setMonthPeriod();
    Range actualRange = (Range) getField(rangePeriodSelector, "range");
    Period actualPeriod = (Period) getField(rangePeriodSelector, "period");
    assertEquals(Range.MONTH, actualRange);
    assertEquals(expectedPeriod, actualPeriod);
}
Also used : Period(com.artezio.arttime.datamodel.Period) Range(com.artezio.arttime.web.criteria.RangePeriodSelector.Range) Test(org.junit.Test)

Example 44 with Period

use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.

the class RangePeriodSelectorTest method testSetWeekPeriod.

@Test
public void testSetWeekPeriod() throws ParseException, NoSuchFieldException {
    Period period = new Period(sdf.parse("1-05-2014"), sdf.parse("3-05-2014"));
    setField(rangePeriodSelector, "period", period);
    setField(rangePeriodSelector, "range", Range.CUSTOM);
    Period expectedPeriod = new Period(sdf.parse("27-04-2014"), sdf.parse("3-05-2014"));
    rangePeriodSelector.setWeekPeriod();
    Range actualRange = (Range) getField(rangePeriodSelector, "range");
    Period actualPeriod = (Period) getField(rangePeriodSelector, "period");
    assertEquals(Range.WEEK, actualRange);
    assertEquals(expectedPeriod, actualPeriod);
}
Also used : Period(com.artezio.arttime.datamodel.Period) Range(com.artezio.arttime.web.criteria.RangePeriodSelector.Range) Test(org.junit.Test)

Example 45 with Period

use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.

the class WorkdaysCalendarBeanTest method testUpdateDaysOff_ifExtendedPeriodNotContainsDate.

@Test
public void testUpdateDaysOff_ifExtendedPeriodNotContainsDate() throws Exception {
    Period extendedPeriod = new Period(sdf.parse("01-12-2014"), sdf.parse("28-02-2015"));
    setField(calendarBean, "extendedPeriod", extendedPeriod);
    Date date = sdf.parse("1-03-2015");
    Map<Date, Day> days = new HashMap<Date, Day>();
    days.put(date, new Day(date, null, false));
    setField(calendarBean, "days", days);
    assertEquals(calendarBean.getDaysOff(), "");
}
Also used : Period(com.artezio.arttime.datamodel.Period) Day(com.artezio.arttime.datamodel.Day) 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