@Test public void testFirstDayOfMonthOk() throws Exception { DataSetLookupFactory.newDataSetLookupBuilder() .group(COLUMN_DATE) .fixed(MONTH, true) .firstMonth(Month.APRIL); }
@Test public void testFirstDayOfMonthOk() throws Exception { DataSetLookupFactory.newDataSetLookupBuilder() .group(COLUMN_DATE) .fixed(MONTH, true) .firstMonth(Month.APRIL); }
@Test public void testFirstDayOfMonthNok() throws Exception { try { DataSetLookupFactory.newDataSetLookupBuilder() .group(COLUMN_DATE) .fixed(QUARTER, true) .firstMonth(Month.APRIL); fail("firstDayOfWeek required a DAY_OF_WEEK fixed domain."); } catch (Exception e) { // Expected. } }
@Test public void testFirstDayOfMonthNok() throws Exception { try { DataSetLookupFactory.newDataSetLookupBuilder() .group(COLUMN_DATE) .fixed(QUARTER, true) .firstMonth(Month.APRIL); fail("firstDayOfWeek required a DAY_OF_WEEK fixed domain."); } catch (Exception e) { // Expected. } }
@Test public void testNonEmptyIntervals() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_EMPTYINTERVALS_UUID) .group("DATE").fixed(MONTH, false).firstMonth(Month.JANUARY) .column("DATE", "Period") .column(COUNT, "Occurrences") .column("NUMBER", SUM, "total") .buildLookup()); // printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"1", "1.00", "1.00"}, {"2", "1.00", "1.00"}, {"3", "2.00", "2.00"}, {"4", "1.00", "1.00"}, {"5", "1.00", "1.00"}, {"6", "1.00", "1.00"}, {"7", "1.00", "1.00"}, {"8", "1.00", "1.00"}, {"10", "1.00", "1.00"}, {"11", "1.00", "1.00"} }, 0); }
@Test public void testGroupByMonthFirstMonthReverse() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DATE).fixed(MONTH, true).desc().firstMonth(Month.MARCH) .column(COLUMN_DATE, "Period") .column(COUNT, "Occurrences") .column(COLUMN_AMOUNT, SUM, "totalAmount") .buildLookup()); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"3", "5.00", "1,012.55"}, {"2", "6.00", "2,885.57"}, {"1", "3.00", "2,324.20"}, {"12", "4.00", "2,520.88"}, {"11", "3.00", "1,443.75"}, {"10", "3.00", "1,366.40"}, {"9", "3.00", "693.35"}, {"8", "2.00", "452.25"}, {"7", "4.00", "2,354.04"}, {"6", "9.00", "4,113.87"}, {"5", "5.00", "2,503.34"}, {"4", "3.00", "1,061.06"} }, 0); }
@Test public void testGroupByMonthFirstMonth() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DATE).fixed(MONTH, true).firstMonth(Month.NOVEMBER) .column(COLUMN_DATE, "Period") .column(COUNT, "Occurrences") .column(COLUMN_AMOUNT, SUM, "totalAmount") .buildLookup()); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"11", "3.00", "1,443.75"}, {"12", "4.00", "2,520.88"}, {"1", "3.00", "2,324.20"}, {"2", "6.00", "2,885.57"}, {"3", "5.00", "1,012.55"}, {"4", "3.00", "1,061.06"}, {"5", "5.00", "2,503.34"}, {"6", "9.00", "4,113.87"}, {"7", "4.00", "2,354.04"}, {"8", "2.00", "452.25"}, {"9", "3.00", "693.35"}, {"10", "3.00", "1,366.40"} }, 0); }
@Test public void testEmptyIntervalsUsingFirstMonth() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_EMPTYINTERVALS_UUID) .group("DATE").fixed(MONTH, true).firstMonth(Month.MARCH) .column("DATE", "Period") .column(COUNT, "Occurrences") .column("NUMBER", SUM, "total") .buildLookup()); // printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"3", "2.00", "2.00"}, {"4", "1.00", "1.00"}, {"5", "1.00", "1.00"}, {"6", "1.00", "1.00"}, {"7", "1.00", "1.00"}, {"8", "1.00", "1.00"}, {"9", "0.00", "0.00"}, {"10", "1.00", "1.00"}, {"11", "1.00", "1.00"}, {"12", "0.00", "0.00"}, {"1", "1.00", "1.00"}, {"2", "1.00", "1.00"} }, 0); }
@Test public void testGroupByMonthFirstMonth() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DATE).fixed(MONTH, true).firstMonth(Month.NOVEMBER) .column(COLUMN_DATE, "Period") .column(COUNT, "Occurrences") .column(COLUMN_AMOUNT, SUM, "totalAmount") .buildLookup()); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"11", "3.00", "1,443.75"}, {"12", "4.00", "2,520.88"}, {"1", "3.00", "2,324.20"}, {"2", "6.00", "2,885.57"}, {"3", "5.00", "1,012.55"}, {"4", "3.00", "1,061.06"}, {"5", "5.00", "2,503.34"}, {"6", "9.00", "4,113.87"}, {"7", "4.00", "2,354.04"}, {"8", "2.00", "452.25"}, {"9", "3.00", "693.35"}, {"10", "3.00", "1,366.40"} }, 0); }
@Test public void testEmptyIntervals() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_EMPTYINTERVALS_UUID) .group("DATE").fixed(MONTH, true).firstMonth(Month.JANUARY) .column("DATE", "Period") .column(COUNT, "Occurrences") .column("NUMBER", SUM, "total") .buildLookup()); // printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"1", "1.00", "1.00"}, {"2", "1.00", "1.00"}, {"3", "2.00", "2.00"}, {"4", "1.00", "1.00"}, {"5", "1.00", "1.00"}, {"6", "1.00", "1.00"}, {"7", "1.00", "1.00"}, {"8", "1.00", "1.00"}, {"9", "0.00", "0.00"}, {"10", "1.00", "1.00"}, {"11", "1.00", "1.00"}, {"12", "0.00", "0.00"} }, 0); }
@Test public void testGroupByMonthFirstMonthReverse() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DATE).fixed(MONTH, true).desc().firstMonth(Month.MARCH) .column(COLUMN_DATE, "Period") .column(COUNT, "Occurrences") .column(COLUMN_AMOUNT, SUM, "totalAmount") .buildLookup()); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"3", "5.00", "1,012.55"}, {"2", "6.00", "2,885.57"}, {"1", "3.00", "2,324.20"}, {"12", "4.00", "2,520.88"}, {"11", "3.00", "1,443.75"}, {"10", "3.00", "1,366.40"}, {"9", "3.00", "693.35"}, {"8", "2.00", "452.25"}, {"7", "4.00", "2,354.04"}, {"6", "9.00", "4,113.87"}, {"5", "5.00", "2,503.34"}, {"4", "3.00", "1,061.06"} }, 0); }