Search in sources :

Example 16 with DataAccessPane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane in project constellation by constellation-app.

the class DataAccessUtilitiesNGTest method loadDataAccessState_no_tabs.

@Test
public void loadDataAccessState_no_tabs() {
    // mock graph
    final Graph graph = mock(Graph.class);
    // mock tab pane
    final DataAccessPane dataAccessPane = mock(DataAccessPane.class);
    final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
    when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
    when(dataAccessTabPane.getCurrentTab()).thenReturn(null);
    DataAccessUtilities.loadDataAccessState(dataAccessPane, graph);
    verifyNoInteractions(graph);
}
Also used : DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) Test(org.testng.annotations.Test)

Example 17 with DataAccessPane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane in project constellation by constellation-app.

the class DataAccessUtilitiesNGTest method loadDataAccessState_attribute_not_found.

@Test
public void loadDataAccessState_attribute_not_found() {
    // mock graph
    final Graph graph = mock(Graph.class);
    final ReadableGraph rGraph = mock(ReadableGraph.class);
    when(graph.getReadableGraph()).thenReturn(rGraph);
    // mock data access state attribute in graph
    when(rGraph.getAttribute(GraphElementType.META, "dataaccess_state")).thenReturn(Graph.NOT_FOUND);
    final DataAccessPane dataAccessPane = mock(DataAccessPane.class);
    final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
    final Tab currentTab = mock(Tab.class);
    when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
    when(dataAccessTabPane.getCurrentTab()).thenReturn(currentTab);
    DataAccessUtilities.loadDataAccessState(dataAccessPane, graph);
    verify(rGraph, never()).getObjectValue(anyInt(), anyInt());
    verify(rGraph).release();
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) Tab(javafx.scene.control.Tab) DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) Test(org.testng.annotations.Test)

Example 18 with DataAccessPane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane 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);
}
Also used : DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) DataAccessViewTopComponent(au.gov.asd.tac.constellation.views.dataaccess.DataAccessViewTopComponent) WindowManager(org.openide.windows.WindowManager) Test(org.testng.annotations.Test)

Example 19 with DataAccessPane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane in project constellation by constellation-app.

the class DataAccessUtilitiesNGTest method loadDataAccessState_null_state.

@Test
public void loadDataAccessState_null_state() {
    // mock graph
    final Graph graph = mock(Graph.class);
    final ReadableGraph rGraph = mock(ReadableGraph.class);
    when(graph.getReadableGraph()).thenReturn(rGraph);
    // mock data access state attribute in graph
    when(rGraph.getAttribute(GraphElementType.META, "dataaccess_state")).thenReturn(2);
    when(rGraph.getObjectValue(2, 0)).thenReturn(null);
    // mock tab pane
    final DataAccessPane dataAccessPane = mock(DataAccessPane.class);
    final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
    final Tab currentTab = mock(Tab.class);
    when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
    when(dataAccessTabPane.getCurrentTab()).thenReturn(currentTab);
    try (final MockedStatic<DataAccessTabPane> daTabPaneMockedStatic = Mockito.mockStatic(DataAccessTabPane.class)) {
        DataAccessUtilities.loadDataAccessState(dataAccessPane, graph);
        daTabPaneMockedStatic.verifyNoInteractions();
        verify(rGraph).release();
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) Tab(javafx.scene.control.Tab) DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) Test(org.testng.annotations.Test)

Aggregations

DataAccessPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane)19 Test (org.testng.annotations.Test)15 Graph (au.gov.asd.tac.constellation.graph.Graph)8 DataAccessTabPane (au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane)8 Tab (javafx.scene.control.Tab)6 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)5 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)5 QueryPhasePane (au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane)5 DataAccessViewTopComponent (au.gov.asd.tac.constellation.views.dataaccess.DataAccessViewTopComponent)4 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)3 TabPane (javafx.scene.control.TabPane)3 WindowManager (org.openide.windows.WindowManager)3 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)2 JsonIO (au.gov.asd.tac.constellation.utilities.genericjsonio.JsonIO)2 DataAccessUserPreferences (au.gov.asd.tac.constellation.views.dataaccess.api.DataAccessUserPreferences)2 DataSourceTitledPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataSourceTitledPane)2 GlobalParametersPane (au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane)2 DataAccessState (au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState)2 QualityControlAutoVetter (au.gov.asd.tac.constellation.views.qualitycontrol.daemon.QualityControlAutoVetter)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2