@Override public Void answer(InvocationOnMock invocation) throws Throwable { final DataSet dataSet = mock(DataSet.class); when(dataSet.getRowCount()).thenReturn(0); ((DataSetReadyCallback) invocation.getArguments()[1]).callback(dataSet); return null; } }).when(dataSetClientServices).lookupDataSet(any(DataSetLookup.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { final DataSet dataSet = mock(DataSet.class); when(dataSet.getRowCount()).thenReturn(1); when(dataSet.getValueAt(0, VALUE_COLUMN_ID)).thenReturn(columnValue); when(dataSet.getValueAt(0, TEXT_COLUMN_ID)).thenReturn(columnText); ((DataSetReadyCallback) invocation.getArguments()[1]).callback(dataSet); return null; } }).when(dataSetClientServices).lookupDataSet(any(DataSetLookup.class),
public void callback(DataSet ds) { try { dataSet = ds; afterDataSetLookup(dataSet); callback.callback(dataSet.getRowCount()); } catch (Exception e) { showError(new ClientRuntimeError(e)); } } public void notFound() {
public void onCategorySelected(String columnId, int row) { Integer maxSelections = displayerSettings.isFilterSelfApplyEnabled() ? null : dataSet.getRowCount(); filterUpdate(columnId, row, maxSelections); // Update the displayer in order to reflect the current selection // (only if not has already been redrawn as part of the drill-down processing in the above filterUpdate() call) if (!displayerSettings.isFilterSelfApplyEnabled()) { updateVisualization(); } } }
@Test public void testTrim() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .rowNumber(10) .buildLookup()); assertThat(result.getColumns().size()).isEqualTo(6); assertThat(result.getRowCount()).isEqualTo(10); }
@Test public void testFilterPropagations() { displayerCoordinator.drawAll(); // Click on the "Engineering" slice reset(listener); deptPieChart.filterUpdate(COLUMN_DEPARTMENT, 0); // Check the allRowsTable receives the filter request DataSet dataSet = allRowsTable.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 19); verify(listener).onDataLookup(allRowsTable); verify(listener).onRedraw(allRowsTable); }
@Test public void testSelectAuthorAndWeekOfDay() throws Exception { authorSelectorDisplayer.filterUpdate(COLUMN_AUTHOR, 1); // "user" selected DataSet dataSet = allCommitsDisplayer.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 1); dayOfWeekSelectorDisplayer.filterUpdate(COLUMN_DATE, 2); // "Tuesday" selected dataSet = allCommitsDisplayer.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 1); } }
@Test public void testSelectRepo() throws Exception { repositorySelectorDisplayer.filterUpdate(COLUMN_REPO, 1); // "repo1" selected DataSet dataSet = allCommitsDisplayer.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 2); }
@Test public void testANDExpression() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .filter(COLUMN_AMOUNT, AND(greaterThan(100), lowerThan(150))) .sort(COLUMN_ID, SortOrder.ASCENDING) .buildLookup()); //printDataSet(result); assertThat(result.getRowCount()).isEqualTo(1); assertDataSetValue(result, 0, 0, "1.00"); }
@Test public void testGroupByMonthDynamicNonEmpty() throws Exception { DataSet result = lookupGroupByMonthDynamic(false); //printDataSet(result); assertThat(result.getRowCount()).isEqualTo(37); assertThat(result.getValueAt(0, 0)).isEqualTo("2012-01"); }
@Test public void testSelectWeekOfDay() throws Exception { AbstractDisplayer displayer = (AbstractDisplayer) presenter.getCommitsByDayOfWeekDisplayer(); displayer.filterUpdate(COLUMN_DATE, 2); // "Tuesday" selected DataSet dataSet = presenter.getAllCommitsDisplayer().getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 2); }
@Test public void testMultipleFilter() { displayerCoordinator.drawAll(); // Click on the "2014" slice yearBarChart.filterUpdate(COLUMN_DATE, 2); // Click on the "Sales" slice deptPieChart.filterUpdate(COLUMN_DEPARTMENT, 1); // Check the allRowsTable receives all the filter requests DataSet dataSet = allRowsTable.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 2); }
@Test public void testTrim() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS) .rowNumber(10) .buildLookup()); assertThat(result.getColumns().size()).isEqualTo(6); assertThat(result.getRowCount()).isEqualTo(10); }
@Test public void testLookup() throws Exception { DataSetLookup lookup = DataSetLookupFactory .newDataSetLookupBuilder().dataset("test") .buildLookup(); DataSet dataSet = dataSetManager.lookupDataSet(lookup); verify(customProvider).lookupDataSet(customDef, lookup); assertEquals(dataSet.getRowCount(), 2); assertEquals(dataSet.getValueAt(0, 0), "david"); assertEquals(dataSet.getValueAt(1, 0), "maciejs"); } }
@Test public void testLookup() throws Exception { DataSetLookup lookup = DataSetLookupFactory .newDataSetLookupBuilder().dataset("test") .buildLookup(); DataSet dataSet = dataSetManager.lookupDataSet(lookup); verify(customProvider).lookupDataSet(customDef, lookup); assertEquals(dataSet.getRowCount(), 2); assertEquals(dataSet.getValueAt(0, 0), "david"); assertEquals(dataSet.getValueAt(1, 0), "maciejs"); } }
@Test public void testFilterByStringWithPreProcessor() throws Exception { DataSet result = dataSetManager.lookupDataSet( DataSetLookupFactory.newDataSetLookupBuilder() .dataset(EXPENSE_REPORTS + "2") .filter(COLUMN_CITY, equalsTo("Barcelona")) .buildLookup()); //printDataSet(result); assertThat(result.getRowCount()).isEqualTo(0); }
@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 dataSetCreated_whenCsvDataValid() throws Exception { final String CSV_DATA = "'Name','Weight','Date of birth'\n'Jan','75.64','1950-01-20'"; CSVFileStorage mockStorage = new MockCSVFileStorage(CSV_DATA); CSVParser testedParser = new CSVParser(csvDataSet, mockStorage); DataSet dset = testedParser.load(); assertEquals(1, dset.getRowCount()); assertEquals(ColumnType.LABEL, dset.getColumnById("Name").getColumnType()); assertEquals(ColumnType.NUMBER, dset.getColumnById("Weight").getColumnType()); assertEquals(ColumnType.DATE, dset.getColumnById("Date of birth").getColumnType()); }