@Test public void testFirstDayOfWeekOk() throws Exception { DataSetLookupFactory.newDataSetLookupBuilder() .group(COLUMN_DATE) .fixed(DAY_OF_WEEK, true) .firstDay(DayOfWeek.MONDAY); }
@Test public void testFirstDayOfWeekOk() throws Exception { DataSetLookupFactory.newDataSetLookupBuilder() .group(COLUMN_DATE) .fixed(DAY_OF_WEEK, true) .firstDay(DayOfWeek.MONDAY); }
@Test public void testFirstDayOfWeekNok() throws Exception { try { DataSetLookupFactory.newDataSetLookupBuilder() .group(COLUMN_DATE) .fixed(QUARTER, true) .firstDay(DayOfWeek.MONDAY); fail("firstDayOfWeek required a DAY_OF_WEEK fixed domain."); } catch (Exception e) { // Expected. } }
@Test public void testFirstDayOfWeekNok() throws Exception { try { DataSetLookupFactory.newDataSetLookupBuilder() .group(COLUMN_DATE) .fixed(QUARTER, true) .firstDay(DayOfWeek.MONDAY); fail("firstDayOfWeek required a DAY_OF_WEEK fixed domain."); } catch (Exception e) { // Expected. } }
@Test public void testGroupByDayOfWeekFixed() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DATE).fixed(DAY_OF_WEEK, true).firstDay(DayOfWeek.MONDAY) .column(COLUMN_DATE, "Period") .column(COUNT, "Occurrences") .column(COLUMN_AMOUNT, SUM, "totalAmount") .buildLookup()); // printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"2", "10.00", "3,904.17"}, {"3", "8.00", "4,525.69"}, {"4", "7.00", "4,303.14"}, {"5", "4.00", "1,021.95"}, {"6", "8.00", "3,099.08"}, {"7", "5.00", "2,012.05"}, {"1", "8.00", "3,865.18"} }, 0); }
@Test public void testGroupByDayOfWeekFixed() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DATE).fixed(DAY_OF_WEEK, true).firstDay(DayOfWeek.MONDAY) .column(COLUMN_DATE, "Period") .column(COUNT, "Occurrences") .column(COLUMN_AMOUNT, SUM, "totalAmount") .buildLookup()); // printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"2", "10.00", "3,904.17"}, {"3", "8.00", "4,525.69"}, {"4", "7.00", "4,303.14"}, {"5", "4.00", "1,021.95"}, {"6", "8.00", "3,099.08"}, {"7", "5.00", "2,012.05"}, {"1", "8.00", "3,865.18"} }, 0); }