Search in sources :

Example 1 with DataAccessTabPane

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();
}
Also used : TabPane(javafx.scene.control.TabPane) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) PluginExecution(au.gov.asd.tac.constellation.plugins.PluginExecution) GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) WaitForQueriesToCompleteTask(au.gov.asd.tac.constellation.views.dataaccess.tasks.WaitForQueriesToCompleteTask) StatusDisplayer(org.openide.awt.StatusDisplayer) DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) PluginGraphs(au.gov.asd.tac.constellation.plugins.PluginGraphs) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) Graph(au.gov.asd.tac.constellation.graph.Graph) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) ExecutorService(java.util.concurrent.ExecutorService) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin) NotificationDisplayer(org.openide.awt.NotificationDisplayer) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Icon(javax.swing.Icon) DataAccessViewTopComponent(au.gov.asd.tac.constellation.views.dataaccess.DataAccessViewTopComponent) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with DataAccessTabPane

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();
}
Also used : DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) Tab(javafx.scene.control.Tab) Node(javafx.scene.Node) ContextMenu(javafx.scene.control.ContextMenu) ContextMenuEvent(javafx.scene.input.ContextMenuEvent) Test(org.testng.annotations.Test)

Example 3 with DataAccessTabPane

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");
}
Also used : DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) Graph(au.gov.asd.tac.constellation.graph.Graph) Tab(javafx.scene.control.Tab) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 4 with DataAccessTabPane

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);
}
Also used : DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) Tab(javafx.scene.control.Tab) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) Test(org.testng.annotations.Test)

Example 5 with DataAccessTabPane

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);
}
Also used : DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) Test(org.testng.annotations.Test)

Aggregations

DataAccessTabPane (au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane)19 Test (org.testng.annotations.Test)17 Tab (javafx.scene.control.Tab)12 Graph (au.gov.asd.tac.constellation.graph.Graph)8 DataAccessPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane)7 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)5 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)5 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)5 DataAccessUtilities (au.gov.asd.tac.constellation.views.dataaccess.utilities.DataAccessUtilities)4 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)3 QueryPhasePane (au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane)3 SearchRequest (org.netbeans.spi.quicksearch.SearchRequest)3 SearchResponse (org.netbeans.spi.quicksearch.SearchResponse)3 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)2 GlobalParametersPane (au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane)2 DataAccessState (au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState)2 TabPane (javafx.scene.control.TabPane)2 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)1 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)1 PluginGraphs (au.gov.asd.tac.constellation.plugins.PluginGraphs)1