use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class ExecuteListenerNGTest method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
dataAccessViewTopComponent = mock(DataAccessViewTopComponent.class);
dataAccessPane = mock(DataAccessPane.class);
dataAccessTabPane = mock(DataAccessTabPane.class);
tabPane = mock(TabPane.class);
graphManager = mock(GraphManager.class);
activeGraph = mock(Graph.class);
when(dataAccessPane.getParentComponent()).thenReturn(dataAccessViewTopComponent);
when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
when(dataAccessTabPane.getTabPane()).thenReturn(tabPane);
when(dataAccessViewTopComponent.getExecutorService()).thenReturn(Executors.newSingleThreadExecutor());
executeListener = new ExecuteListener(dataAccessPane);
graphManagerMockedStatic.when(GraphManager::getDefault).thenReturn(graphManager);
when(graphManager.getActiveGraph()).thenReturn(activeGraph);
when(activeGraph.getId()).thenReturn(GRAPH_ID);
// Intercept the plugin execution run calls and run the plugins manually
// so that it executes within the same thread and sequentially for the test
pluginExecution = mock(PluginExecution.class);
pluginExecutionMockedStatic.when(() -> PluginExecution.withPlugin(any(SimplePlugin.class))).thenAnswer(iom -> {
final SimplePlugin plugin = iom.getArgument(0);
final PluginGraphs graphs = mock(PluginGraphs.class);
when(graphs.getGraph()).thenReturn(null);
final PluginInteraction pluginInteraction = mock(PluginInteraction.class);
final PluginParameters pluginParameters = mock(PluginParameters.class);
// This will call the execute method of the simple plugin
plugin.run(graphs, pluginInteraction, pluginParameters);
return pluginExecution;
});
// Intercept calls to start the wait for tasks so that they don't run
completableFutureMockedStatic.when(() -> CompletableFuture.runAsync(any(WaitForQueriesToCompleteTask.class), any(ExecutorService.class))).thenReturn(null);
notificationDisplayer = mock(NotificationDisplayer.class);
notificationDisplayerMockedStatic.when(NotificationDisplayer::getDefault).thenReturn(notificationDisplayer);
when(notificationDisplayer.notify(anyString(), any(Icon.class), anyString(), isNull())).thenReturn(null);
statusDisplayer = mock(StatusDisplayer.class);
statusDisplayerMockedStatic.when(StatusDisplayer::getDefault).thenReturn(statusDisplayer);
DataAccessPaneState.clearState();
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class DataAccessPaneNGTest method contextMenuEvent.
/**
* I suspect this doesn't work because the action handler is initialized during
* the constructor and the spy is not applied until after the construction is
* complete.
*/
@Test(enabled = false)
public void contextMenuEvent() {
final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
final Tab currentTab = mock(Tab.class);
final ContextMenu contextMenu = mock(ContextMenu.class);
final ContextMenuEvent contextMenuEvent = mock(ContextMenuEvent.class);
doNothing().when(contextMenu).show(any(Node.class), anyDouble(), anyDouble());
when(contextMenuEvent.getScreenX()).thenReturn(22.0);
when(contextMenuEvent.getScreenY()).thenReturn(11.0);
doReturn(dataAccessTabPane).when(dataAccessPane).getDataAccessTabPane();
when(dataAccessTabPane.getCurrentTab()).thenReturn(currentTab);
when(currentTab.getContextMenu()).thenReturn(contextMenu);
dataAccessPane.getOnContextMenuRequested().handle(contextMenuEvent);
verify(contextMenu).show(dataAccessPane, 22.0, 11.0);
verify(contextMenuEvent).consume();
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class DataAccessPaneNGTest method update_pass_non_null_graph.
@Test
public void update_pass_non_null_graph() {
final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
final Tab currentTab = mock(Tab.class);
final QueryPhasePane currentQueryPhasePane = mock(QueryPhasePane.class);
final DataSourceTitledPane dataSourceTitledPane = mock(DataSourceTitledPane.class);
final Plugin plugin = mock(Plugin.class);
final PluginParameters pluginParameters = mock(PluginParameters.class);
final Graph graph = mock(Graph.class);
when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
when(dataAccessTabPane.getCurrentTab()).thenReturn(currentTab);
when(dataAccessTabPane.getQueryPhasePaneOfCurrentTab()).thenReturn(currentQueryPhasePane);
when(currentQueryPhasePane.getDataAccessPanes()).thenReturn(List.of(dataSourceTitledPane));
when(dataSourceTitledPane.getPlugin()).thenReturn(plugin);
when(dataSourceTitledPane.getParameters()).thenReturn(pluginParameters);
when(graph.getId()).thenReturn("graphId");
dataAccessPane.update(graph);
verify(plugin).updateParameters(graph, pluginParameters);
verify(dataAccessPane).update("graphId");
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class ShowDataAccessPluginTaskNGTest method run.
@Test
public void run() {
final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
final Tab currentTab = mock(Tab.class);
final QueryPhasePane queryPhasePane = mock(QueryPhasePane.class);
when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
when(dataAccessTabPane.getCurrentTab()).thenReturn(currentTab);
dataAccessTabPaneMockedStatic.when(() -> DataAccessTabPane.getQueryPhasePane(currentTab)).thenReturn(queryPhasePane);
showDataAccessPluginTask.run();
verify(queryPhasePane).expandPlugin(PLUGIN_NAME);
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class ShowDataAccessPluginTaskNGTest method run_current_tab_null.
@Test
public void run_current_tab_null() {
final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
when(dataAccessTabPane.getCurrentTab()).thenReturn(null);
showDataAccessPluginTask.run();
verify(notificationDisplayer).notify("Data Access View", UserInterfaceIconProvider.WARNING.buildIcon(16, ConstellationColor.DARK_ORANGE.getJavaColor()), "Please create a step in the Data Access view.", null);
}
Aggregations