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);
}
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();
}
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);
}
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();
}
}
Aggregations