VariableHistoryPopup extends BaseModal { public ColumnSortEvent.ListHandler<ProcessVariableSummary> getSortHandler() { return sortHandler; } VariableHistoryPopup();  VariableHistoryPopup(DataGrid<ProcessVariableSummary> processVarListGrid,
                                Pagination pagination,
                                FormControlStatic variableNameTextBox); void init(); void show(final String variableId,
                     final List<ProcessVariableSummary> processVariableSummaries); void closePopup(); void refreshTable(); void loadVariableHistory(final List<ProcessVariableSummary> processVariableSummaries); ColumnSortEvent.ListHandler<ProcessVariableSummary> getSortHandler(); @UiField
    public FormControlStatic variableNameTextBox; @UiField
    public DataGrid<ProcessVariableSummary> processVarListGrid; @UiField
    public Pagination pagination; public SimplePager pager; }
@Test public void variableNewValueComparatorTest() { ProcessVariableSummary processVariableSummary1 = new ProcessVariableSummary(); ProcessVariableSummary processVariableSummary2 = new ProcessVariableSummary(); ProcessVariableSummary processVariableSummary3 = new ProcessVariableSummary(); processVariableSummary1.setNewValue("A"); processVariableSummary2.setNewValue("B"); processVariableSummary3.setNewValue("A"); Comparator varNewValueComparator = variableHistoryPopup.getSortHandler().getComparator(testDataGrid.getColumn(COLUMN_NEW_VALUE_POSITION)); assertEquals(-1, varNewValueComparator.compare(processVariableSummary1, processVariableSummary2)); assertEquals(1, varNewValueComparator.compare(processVariableSummary2, processVariableSummary1)); assertEquals(0, varNewValueComparator.compare(processVariableSummary1, processVariableSummary3)); processVariableSummary1.setNewValue(null); processVariableSummary2.setNewValue("B"); assertEquals(-1, varNewValueComparator.compare(processVariableSummary1, processVariableSummary2)); assertEquals(1, varNewValueComparator.compare(processVariableSummary2, processVariableSummary1)); processVariableSummary3.setNewValue(null); assertEquals(0, varNewValueComparator.compare(processVariableSummary1, processVariableSummary3)); assertEquals("", testDataGrid.getColumn(COLUMN_NEW_VALUE_POSITION).getValue(processVariableSummary3)); assertEquals("B", testDataGrid.getColumn(COLUMN_NEW_VALUE_POSITION).getValue(processVariableSummary2)); }
@Test public void variableOldValueComparatorTest() { ProcessVariableSummary processVariableSummary1 = new ProcessVariableSummary(); ProcessVariableSummary processVariableSummary2 = new ProcessVariableSummary(); ProcessVariableSummary processVariableSummary3 = new ProcessVariableSummary(); processVariableSummary1.setOldValue("A"); processVariableSummary2.setOldValue("B"); processVariableSummary3.setOldValue("A"); Comparator varOldValueComparator = variableHistoryPopup.getSortHandler().getComparator(testDataGrid.getColumn(COLUMN_OLD_VALUE_POSITION)); assertEquals(-1, varOldValueComparator.compare(processVariableSummary1, processVariableSummary2)); assertEquals(1, varOldValueComparator.compare(processVariableSummary2, processVariableSummary1)); assertEquals(0, varOldValueComparator.compare(processVariableSummary1, processVariableSummary3)); processVariableSummary1.setOldValue(null); processVariableSummary2.setOldValue("B"); assertEquals(-1, varOldValueComparator.compare(processVariableSummary1, processVariableSummary2)); assertEquals(1, varOldValueComparator.compare(processVariableSummary2, processVariableSummary1)); processVariableSummary3.setOldValue(null); assertEquals(0, varOldValueComparator.compare(processVariableSummary1, processVariableSummary3)); assertEquals("", testDataGrid.getColumn(COLUMN_OLD_VALUE_POSITION).getValue(processVariableSummary3)); assertEquals("B", testDataGrid.getColumn(COLUMN_OLD_VALUE_POSITION).getValue(processVariableSummary2)); }