Search in sources :

Example 1 with Range

use of com.artezio.arttime.web.criteria.RangePeriodSelector.Range in project ART-TIME by Artezio.

the class CalendarPeriodSelectorTest 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"));
    PowerMock.mockStatic(Locale.class);
    expect(Locale.getDefault()).andReturn(Locale.US);
    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) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with Range

use of com.artezio.arttime.web.criteria.RangePeriodSelector.Range 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 3 with Range

use of com.artezio.arttime.web.criteria.RangePeriodSelector.Range 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 4 with Range

use of com.artezio.arttime.web.criteria.RangePeriodSelector.Range 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 5 with Range

use of com.artezio.arttime.web.criteria.RangePeriodSelector.Range in project ART-TIME by Artezio.

the class CalendarPeriodSelectorTest 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"));
    PowerMock.mockStatic(Locale.class);
    expect(Locale.getDefault()).andReturn(Locale.US);
    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) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Period (com.artezio.arttime.datamodel.Period)6 Range (com.artezio.arttime.web.criteria.RangePeriodSelector.Range)6 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3