Search in sources :

Example 16 with DataAccessTabPane

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());
}
Also used : SearchRequest(org.netbeans.spi.quicksearch.SearchRequest) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) Tab(javafx.scene.control.Tab) DataAccessUtilities(au.gov.asd.tac.constellation.views.dataaccess.utilities.DataAccessUtilities) SearchResponse(org.netbeans.spi.quicksearch.SearchResponse) Test(org.testng.annotations.Test)

Example 17 with DataAccessTabPane

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);
}
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 18 with DataAccessTabPane

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();
}
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 19 with DataAccessTabPane

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

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