@Test public void testRetrieveColumnSubset() throws Exception { URL fileURL = Thread.currentThread().getContextClassLoader().getResource("salesYear2014.dset"); String json = IOUtils.toString(fileURL, StandardCharsets.UTF_8); DataSetDef def = jsonMarshaller.fromJson(json); dataSetDefRegistry.registerDataSetDef(def); DataSet result = dataSetManager.getDataSet("salesYear2014"); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][] { {"JANUARY", "3,000.00"}, {"FEBRUARY", "2,000.00"}, {"MARCH", "1,400.00"}, {"APRIL", "1,500.00"}, {"MAY", "1,600.00"}, {"JUNE", "1,500.00"}, {"JULY", "3,000.00"}, {"AUGUST", "3,200.00"}, {"SEPTEMBER", "3,000.00"}, {"OCTOBER", "3,100.00"}, {"NOVEMBER", "3,100.00"}, {"DECEMBER", "4,200.00"} }, 0); }
@Test public void testGenerateDataSet() throws Exception { URL fileURL = Thread.currentThread().getContextClassLoader().getResource("salesPerYear.dset"); String json = IOUtils.toString(fileURL); DataSetDef def = jsonMarshaller.fromJson(json); dataSetDefRegistry.registerDataSetDef(def); DataSet result = dataSetManager.getDataSet("salesPerYear"); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"JANUARY", "1,000.00", "2,000.00", "3,000.00"}, {"FEBRUARY", "1,400.00", "2,300.00", "2,000.00"}, {"MARCH", "1,300.00", "2,000.00", "1,400.00"}, {"APRIL", "900.00", "2,100.00", "1,500.00"}, {"MAY", "1,300.00", "2,300.00", "1,600.00"}, {"JUNE", "1,010.00", "2,000.00", "1,500.00"}, {"JULY", "1,050.00", "2,400.00", "3,000.00"}, {"AUGUST", "2,300.00", "2,000.00", "3,200.00"}, {"SEPTEMBER", "1,900.00", "2,700.00", "3,000.00"}, {"OCTOBER", "1,200.00", "2,200.00", "3,100.00"}, {"NOVEMBER", "1,400.00", "2,100.00", "3,100.00"}, {"DECEMBER", "1,100.00", "2,100.00", "4,200.00"} }, 0); }
@Test public void testGenerateDataSetAdjusted() throws Exception { URL fileURL = Thread.currentThread().getContextClassLoader().getResource("salesPerYearAdjusted.dset"); String json = IOUtils.toString(fileURL); DataSetDef def = jsonMarshaller.fromJson(json); dataSetDefRegistry.registerDataSetDef(def); DataSet result = dataSetManager.getDataSet("salesPerYearAdjusted"); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][] { {"JANUARY", "900.00", "1,800.00", "2,700.00"}, {"FEBRUARY", "1,260.00", "2,070.00", "1,800.00"}, {"MARCH", "1,170.00", "1,800.00", "1,260.00"}, {"APRIL", "810.00", "1,890.00", "1,350.00"}, {"MAY", "1,170.00", "2,070.00", "1,440.00"}, {"JUNE", "909.00", "1,800.00", "1,350.00"}, {"JULY", "945.00", "2,160.00", "2,700.00"}, {"AUGUST", "2,070.00", "1,800.00", "2,880.00"}, {"SEPTEMBER", "1,710.00", "2,430.00", "2,700.00"}, {"OCTOBER", "1,080.00", "1,980.00", "2,790.00"}, {"NOVEMBER", "1,260.00", "1,890.00", "2,790.00"}, {"DECEMBER", "990.00", "1,890.00", "3,780.00"} }, 0); }
@Test public void testGenerateDataSet() throws Exception { URL fileURL = Thread.currentThread().getContextClassLoader().getResource("salesPerYear.dset"); String json = IOUtils.toString(fileURL, StandardCharsets.UTF_8); DataSetDef def = jsonMarshaller.fromJson(json); dataSetDefRegistry.registerDataSetDef(def); DataSet result = dataSetManager.getDataSet("salesPerYear"); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"JANUARY", "1,000.00", "2,000.00", "3,000.00"}, {"FEBRUARY", "1,400.00", "2,300.00", "2,000.00"}, {"MARCH", "1,300.00", "2,000.00", "1,400.00"}, {"APRIL", "900.00", "2,100.00", "1,500.00"}, {"MAY", "1,300.00", "2,300.00", "1,600.00"}, {"JUNE", "1,010.00", "2,000.00", "1,500.00"}, {"JULY", "1,050.00", "2,400.00", "3,000.00"}, {"AUGUST", "2,300.00", "2,000.00", "3,200.00"}, {"SEPTEMBER", "1,900.00", "2,700.00", "3,000.00"}, {"OCTOBER", "1,200.00", "2,200.00", "3,100.00"}, {"NOVEMBER", "1,400.00", "2,100.00", "3,100.00"}, {"DECEMBER", "1,100.00", "2,100.00", "4,200.00"} }, 0); }
@Test public void testRetrieveColumnSubset() throws Exception { URL fileURL = Thread.currentThread().getContextClassLoader().getResource("salesYear2014.dset"); String json = IOUtils.toString(fileURL); DataSetDef def = jsonMarshaller.fromJson(json); dataSetDefRegistry.registerDataSetDef(def); DataSet result = dataSetManager.getDataSet("salesYear2014"); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][] { {"JANUARY", "3,000.00"}, {"FEBRUARY", "2,000.00"}, {"MARCH", "1,400.00"}, {"APRIL", "1,500.00"}, {"MAY", "1,600.00"}, {"JUNE", "1,500.00"}, {"JULY", "3,000.00"}, {"AUGUST", "3,200.00"}, {"SEPTEMBER", "3,000.00"}, {"OCTOBER", "3,100.00"}, {"NOVEMBER", "3,100.00"}, {"DECEMBER", "4,200.00"} }, 0); }
@Test public void testGenerateDataSetAdjusted() throws Exception { URL fileURL = Thread.currentThread().getContextClassLoader().getResource("salesPerYearAdjusted.dset"); String json = IOUtils.toString(fileURL, StandardCharsets.UTF_8); DataSetDef def = jsonMarshaller.fromJson(json); dataSetDefRegistry.registerDataSetDef(def); DataSet result = dataSetManager.getDataSet("salesPerYearAdjusted"); //printDataSet(result); assertDataSetValues(result, dataSetFormatter, new String[][] { {"JANUARY", "900.00", "1,800.00", "2,700.00"}, {"FEBRUARY", "1,260.00", "2,070.00", "1,800.00"}, {"MARCH", "1,170.00", "1,800.00", "1,260.00"}, {"APRIL", "810.00", "1,890.00", "1,350.00"}, {"MAY", "1,170.00", "2,070.00", "1,440.00"}, {"JUNE", "909.00", "1,800.00", "1,350.00"}, {"JULY", "945.00", "2,160.00", "2,700.00"}, {"AUGUST", "2,070.00", "1,800.00", "2,880.00"}, {"SEPTEMBER", "1,710.00", "2,430.00", "2,700.00"}, {"OCTOBER", "1,080.00", "1,980.00", "2,790.00"}, {"NOVEMBER", "1,260.00", "1,890.00", "2,790.00"}, {"DECEMBER", "990.00", "1,890.00", "3,780.00"} }, 0); }
@Test public void testFilterWithNullEntries() throws Exception { // Insert a null entry into the dataset DataSet expensesDataSet = dataSetManager.getDataSet(EXPENSE_REPORTS); int column = expensesDataSet.getColumnIndex(expensesDataSet.getColumnById(COLUMN_DEPARTMENT)); expensesDataSet.setValueAt(0, column, null); // Group by department in order to force the indexing of the result DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DEPARTMENT) .column(COLUMN_DEPARTMENT) .column(COLUMN_AMOUNT, SUM) .sort(COLUMN_DEPARTMENT, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(6); result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DEPARTMENT).select("Engineering") .sort(COLUMN_DEPARTMENT, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(18); }
public void testEmptyArguments() throws Exception { DataSet expensesDataSet = dataSetManager.getDataSet(EXPENSE_REPORTS); expensesDataSet.addValuesAt(0, null, null, null, null, null, null);
@Test public void testFilterWithNullEntries() throws Exception { // Insert a null entry into the dataset DataSet expensesDataSet = dataSetManager.getDataSet(EXPENSE_REPORTS); int column = expensesDataSet.getColumnIndex(expensesDataSet.getColumnById(COLUMN_DEPARTMENT)); expensesDataSet.setValueAt(0, column, null); // Group by department in order to force the indexing of the result DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DEPARTMENT) .column(COLUMN_DEPARTMENT) .column(COLUMN_AMOUNT, SUM) .sort(COLUMN_DEPARTMENT, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(6); result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DEPARTMENT).select("Engineering") .sort(COLUMN_DEPARTMENT, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(18); }
public void testEmptyArguments() throws Exception { DataSet expensesDataSet = dataSetManager.getDataSet(EXPENSE_REPORTS); expensesDataSet.addValuesAt(0, null, null, null, null, null, null);