use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class DataAccessSearchProviderNGTest method testEvaluateNull.
/**
* Test of evaluate method, of class DataAccessSearchProvider. Pass in an
* unmatchable search string
*/
@Test
public void testEvaluateNull() {
System.out.println("evaluate null");
// Creating mocks
daPane = mock(DataAccessPane.class);
qpPane = mock(QueryPhasePane.class);
request = mock(SearchRequest.class);
response = mock(SearchResponse.class);
// Create mock of DataAccessPane to return the query phase pane mock
try (MockedStatic<DataAccessTabPane> mockedStatic = Mockito.mockStatic(DataAccessTabPane.class)) {
mockedStatic.when(() -> DataAccessTabPane.getQueryPhasePane(Mockito.any(Tab.class))).thenReturn(qpPane);
}
// Mock of DataAccessPane will return a blank new tab when called
try (MockedStatic<DataAccessUtilities> mockedStatic2 = Mockito.mockStatic(DataAccessUtilities.class)) {
when(daPane.getDataAccessTabPane()).thenReturn(datPane);
when(datPane.getCurrentTab()).thenReturn(new Tab());
mockedStatic2.when(() -> DataAccessUtilities.getDataAccessPane()).thenReturn(daPane);
}
// Mock the request text to be null
when(request.getText()).thenReturn(null);
when(response.addResult(Mockito.any(), Mockito.anyString())).thenReturn(true);
DataAccessSearchProvider instance = new DataAccessSearchProvider();
instance.evaluate(request, response);
// Verify that addResult was never called.
// This should mean that no plugin name matched the input
verify(response, never()).addResult(Mockito.any(), Mockito.anyString());
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane 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.components.DataAccessTabPane 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.components.DataAccessTabPane 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