use of au.gov.asd.tac.constellation.views.dataaccess.DataAccessViewTopComponent 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.DataAccessViewTopComponent in project constellation by constellation-app.
the class DataAccessUtilitiesNGTest method testGetDataAccessPaneCalledByEventDispatchThread.
@Test
public void testGetDataAccessPaneCalledByEventDispatchThread() {
final WindowManager windowManager = mock(WindowManager.class);
final DataAccessViewTopComponent topComponent = mock(DataAccessViewTopComponent.class);
final DataAccessPane dataAccessPane = mock(DataAccessPane.class);
swingUtilitiesStaticMock.when(SwingUtilities::isEventDispatchThread).thenReturn(true);
windowManagerStaticMock.when(WindowManager::getDefault).thenReturn(windowManager);
when(windowManager.findTopComponent(DataAccessViewTopComponent.class.getSimpleName())).thenReturn(topComponent);
when(topComponent.isOpened()).thenReturn(false);
when(topComponent.getDataAccessPane()).thenReturn(dataAccessPane);
DataAccessPane actual = DataAccessUtilities.getDataAccessPane();
verify(topComponent, times(1)).open();
verify(topComponent, times(1)).requestVisible();
assertSame(actual, dataAccessPane);
}
use of au.gov.asd.tac.constellation.views.dataaccess.DataAccessViewTopComponent in project constellation by constellation-app.
the class DataAccessUtilitiesNGTest method testGetDataAccessPaneNotCalledByEventDispatchThread.
@Test
public void testGetDataAccessPaneNotCalledByEventDispatchThread() {
final WindowManager windowManager = mock(WindowManager.class);
final DataAccessViewTopComponent topComponent = mock(DataAccessViewTopComponent.class);
final DataAccessPane dataAccessPane = mock(DataAccessPane.class);
swingUtilitiesStaticMock.when(SwingUtilities::isEventDispatchThread).thenReturn(false);
swingUtilitiesStaticMock.when(() -> SwingUtilities.invokeAndWait(any(Runnable.class))).thenAnswer(invocation -> {
final Runnable r = invocation.getArgument(0);
r.run();
return null;
});
windowManagerStaticMock.when(WindowManager::getDefault).thenReturn(windowManager);
when(windowManager.findTopComponent(DataAccessViewTopComponent.class.getSimpleName())).thenReturn(topComponent);
when(topComponent.isOpened()).thenReturn(false);
when(topComponent.getDataAccessPane()).thenReturn(dataAccessPane);
DataAccessPane actual = DataAccessUtilities.getDataAccessPane();
assertSame(actual, dataAccessPane);
}
Aggregations