@Test(expected = RuntimeException.class) public void testSortingWithNonDefinedColumn() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_CUSTOM_COLUMNS2_UUID) .sort(ExpenseReportsData.COLUMN_DEPARTMENT, SortOrder.DESCENDING) .buildLookup()); }
@Test(expected = RuntimeException.class) public void testSortingWithNonExistingColumn() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .sort("mycolumn", SortOrder.DESCENDING) .buildLookup()); }
/** * ********************************************************************************************************************************************************************************************** * LOOKUP TESTING. * ********************************************************************************************************************************************************************************************** */ @Test(expected = RuntimeException.class) public void testSortingWithNonExstingColumn() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_CUSTOM_COLUMNS_UUID) .sort("mycolumn", SortOrder.DESCENDING) .buildLookup()); }
/** * Test columns as this dataset defintion contains custom definitions. * An exception must be thrown due to cannot change employee column type to label, as it's an anaylzed string in the EL index mapping. */ @Test(expected = RuntimeException.class) public void testColumnsBadDefined() throws Exception { dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_BAD_COLUMNS_UUID) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); } }
@Test(expected = RuntimeException.class) public void testFilterByNonExistingColumn() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .filter("myfield", greaterOrEqualsTo(1000)) .buildLookup()); }
@Test(expected = RuntimeException.class) public void testFilterLikeToByStringNotAnalyzedAndCaseUnSensitive() throws Exception { // Case un-sensitive DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .filter(ExpenseReportsData.COLUMN_DEPARTMENT, likeTo(ExpenseReportsData.COLUMN_DEPARTMENT, "Sal%", false)) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); }
@Test public void testSortByNumber() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .sort(COLUMN_AMOUNT, ASCENDING) .buildLookup()); //printDataSet(result); assertDataSetValue(result, 0, 0, "23.00"); assertDataSetValue(result, 49, 0, "2.00"); }
@Test public void testLoadDataSet() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .buildLookup()); //printDataSet(result); assertThat(result.getRowCount()).isEqualTo(50); assertThat(result.getColumns().size()).isEqualTo(6); }
/** * No operations. */ @Test public void testBasicLookup() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(50); }
@Test public void testSortByDate() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .sort(COLUMN_DATE, ASCENDING) .buildLookup()); //printDataSet(result); assertDataSetValue(result, 0, 0, "50.00"); assertDataSetValue(result, 49, 0, "1.00"); }
@Test(expected = RuntimeException.class) public void testAggregationFunctionByNonExistingColumn() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .group(ExpenseReportsData.COLUMN_DEPARTMENT) .column(ExpenseReportsData.COLUMN_DEPARTMENT, "Department") .column(COUNT, "Occurrences") .column("mycolumn", MIN, "min") .buildLookup()); }
@Test public void testGroupByQuarter() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .group(COLUMN_DATE).fixed(QUARTER, true).select("1") .buildLookup()); //printDataSet(result); assertThat(result.getRowCount()).isEqualTo(14); }
@Test public void testFilterLikeToByStringNotAnalyzedAndCaseSensitive() throws Exception { // Case sensitive DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .filter(ExpenseReportsData.COLUMN_DEPARTMENT, likeTo(ExpenseReportsData.COLUMN_DEPARTMENT, "Sal%", true)) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(8); }
@Test public void testFilterEqualsByStringAnalyzed() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .filter(ExpenseReportsData.COLUMN_EMPLOYEE, equalsTo(EL_EXAMPLE_EMP_NITA)) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(4); assertDataSetValue(result, 0, 0, "9.00"); assertDataSetValue(result, 3, 0, "12.00"); }
@Test public void testANDExpression() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .filter(ExpenseReportsData.COLUMN_AMOUNT, AND(greaterThan(100), lowerThan(150))) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(1); assertDataSetValue(result, 0, 0, "1.00"); }
@Test public void testFilterMultiple2() throws Exception { // The order of the filter criteria does not alter the result. DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .filter(ExpenseReportsData.COLUMN_CITY, notEqualsTo(EL_EXAMPLE_CITY_BARCELONA)) .filter(ExpenseReportsData.COLUMN_AMOUNT, greaterOrEqualsTo(1000)) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(1); assertDataSetValue(result, 0, 0, "15.00"); }
@Test public void testAggregationAndFilterByNonAnalyzedField() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .column(COUNT, "#items") .filter(ExpenseReportsData.COLUMN_DEPARTMENT, equalsTo(EL_EXAMPLE_DEPT_ENGINEERING)) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(1); assertThat(result.getValueAt(0, 0)).isEqualTo(19d); }
@Test public void testGroupSelectionFilter() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .filter(COLUMN_AMOUNT, FilterFactory.greaterThan(500)) .group(COLUMN_DEPARTMENT).select("Engineering") .group(COLUMN_CITY).select("Westford") .buildLookup()); //printDataSet(result); assertThat(result.getRowCount()).isEqualTo(1); assertDataSetValue(result, 0, 0, "26.00"); }
/** * Most basic test. Apply descendent sorting. */ @Test public void testDefaultLookupWithSorting() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.DESCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(50); assertThat(result.getValueAt(0, 0)).isEqualTo(50d); assertThat(result.getValueAt(49, 0)).isEqualTo(1d); }
@Test public void testCombinedExpression() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetFactory.newDataSetLookupBuilder() .dataset(EL_DATASET_UUID) .filter(ExpenseReportsData.COLUMN_AMOUNT, AND( equalsTo(ExpenseReportsData.COLUMN_DEPARTMENT, EL_EXAMPLE_DEPT_SALES), OR(NOT(lowerThan(300)), equalsTo(ExpenseReportsData.COLUMN_CITY, EL_EXAMPLE_CITY_MADRID)))) .sort(ExpenseReportsData.COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); assertThat(result.getRowCount()).isEqualTo(7); assertDataSetValue(result, 0, 0, "9.00"); assertDataSetValue(result, 6, 0, "28.00"); }