use of au.gov.asd.tac.constellation.views.tableview.panes.TablePane in project constellation by constellation-app.
the class TableViewTopComponentNGTest method handleGraphClosed.
@Test
public void handleGraphClosed() throws InterruptedException {
final TableViewTopComponent tableViewTopComponent = mock(TableViewTopComponent.class);
final TablePane tablePane = mock(TablePane.class);
final ActiveTableReference activeTableReference = mock(ActiveTableReference.class);
final Pagination pagination = mock(Pagination.class);
final UserTablePreferences userTablePreferences = new UserTablePreferences();
userTablePreferences.setMaxRowsPerPage(42);
when(tableViewTopComponent.getTablePane()).thenReturn(tablePane);
when(tablePane.getActiveTableReference()).thenReturn(activeTableReference);
when(activeTableReference.getUserTablePreferences()).thenReturn(userTablePreferences);
when(activeTableReference.getPagination()).thenReturn(pagination);
doCallRealMethod().when(tableViewTopComponent).handleGraphClosed(any(Graph.class));
tableViewTopComponent.handleGraphClosed(mock(Graph.class));
verify(activeTableReference).updatePagination(42, null, tablePane);
}
use of au.gov.asd.tac.constellation.views.tableview.panes.TablePane in project constellation by constellation-app.
the class TableViewTopComponentNGTest method showSelected.
@Test
public void showSelected() {
final TableViewTopComponent tableViewTopComponent = mock(TableViewTopComponent.class);
final TableViewState currentState = new TableViewState();
final Graph currentGraph = mock(Graph.class);
final TableViewState expectedNewState = new TableViewState();
expectedNewState.setElementType(GraphElementType.META);
expectedNewState.setSelectedOnly(true);
final TablePane tablePane = mock(TablePane.class);
final Table table = mock(Table.class);
doCallRealMethod().when(tableViewTopComponent).showSelected(any(GraphElementType.class), anyInt());
when(tableViewTopComponent.getCurrentState()).thenReturn(currentState);
when(tableViewTopComponent.getCurrentGraph()).thenReturn(currentGraph);
when(tableViewTopComponent.getTablePane()).thenReturn(tablePane);
when(tableViewTopComponent.getExecutorService()).thenReturn(Executors.newSingleThreadExecutor());
when(tablePane.getTable()).thenReturn(table);
try (final MockedStatic<PluginExecution> pluginExecutionMockedStatic = Mockito.mockStatic(PluginExecution.class)) {
final PluginExecution pluginExecution = mock(PluginExecution.class);
when(pluginExecution.executeLater(any(Graph.class))).thenReturn(CompletableFuture.completedFuture(null));
pluginExecutionMockedStatic.when(() -> PluginExecution.withPlugin(any(UpdateStatePlugin.class))).thenAnswer(mockitoInvocation -> {
final UpdateStatePlugin plugin = (UpdateStatePlugin) mockitoInvocation.getArgument(0);
assertEquals(expectedNewState, plugin.getTableViewState());
// Change the mock now that the "Update Plugin" has run
when(tableViewTopComponent.getCurrentState()).thenReturn(expectedNewState);
return pluginExecution;
});
final Future<?> updateTask = tableViewTopComponent.showSelected(GraphElementType.META, 42);
// Ensure that the update selection task is completed
try {
updateTask.get(5, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
fail("The submitted task in show selected did not complete in the " + "allowed time. Something is probably wrong.");
}
verify(pluginExecution).executeLater(currentGraph);
verify(table).updateSelection(currentGraph, expectedNewState);
}
}
use of au.gov.asd.tac.constellation.views.tableview.panes.TablePane in project constellation by constellation-app.
the class ActiveTableReferenceNGTest method updatePaginationNoNewRowList.
@Test
public void updatePaginationNoNewRowList() {
final Pagination pagination = mock(Pagination.class);
final TablePane tablePane = mock(TablePane.class);
doReturn(pagination).when(activeTableReference).updatePagination(eq(22), same(sortedRowList), same(tablePane));
assertSame(pagination, activeTableReference.updatePagination(22, tablePane));
}
use of au.gov.asd.tac.constellation.views.tableview.panes.TablePane in project constellation by constellation-app.
the class ActiveTableReferenceNGTest method updatePaginationNewRowListNull.
@Test
public void updatePaginationNewRowListNull() throws InterruptedException {
final List<ObservableList<String>> newRowList = null;
final TablePane tablePane = mock(TablePane.class);
final Pagination pagination = activeTableReference.updatePagination(22, newRowList, tablePane);
assertEquals(1, pagination.getPageCount());
assertSame(pageFactory, pagination.getPageFactory());
verify(pageFactory).update(same(newRowList), eq(22));
// This verification is dependent on code completing in the UI thread so
// the following ensures that the verification does not occur until
// the required code is run.
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> latch.countDown());
latch.await();
verify(tablePane).setCenter(same(pagination));
}
use of au.gov.asd.tac.constellation.views.tableview.panes.TablePane in project constellation by constellation-app.
the class ActiveTableReferenceNGTest method updatePaginationNewRowListEmpty.
@Test
public void updatePaginationNewRowListEmpty() throws InterruptedException {
final List<ObservableList<String>> newRowList = new ArrayList<>();
final TablePane tablePane = mock(TablePane.class);
final Pagination pagination = activeTableReference.updatePagination(22, newRowList, tablePane);
assertEquals(1, pagination.getPageCount());
assertSame(pageFactory, pagination.getPageFactory());
verify(pageFactory).update(same(newRowList), eq(22));
// This verification is dependent on code completing in the UI thread so
// the following ensures that the verification does not occur until
// the required code is run.
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> latch.countDown());
latch.await();
verify(tablePane).setCenter(same(pagination));
}
Aggregations