Search in sources :

Example 6 with DataAccessUtilities

use of au.gov.asd.tac.constellation.views.dataaccess.utilities.DataAccessUtilities in project constellation by constellation-app.

the class DataAccessSearchProviderNGTest method testEvaluateFail.

/**
 * Test of evaluate method, of class DataAccessSearchProvider. Pass in an
 * unmatchable search string
 */
@Test
public void testEvaluateFail() {
    System.out.println("evaluate fail");
    // Creating mocks
    daPane = mock(DataAccessPane.class);
    datPane = mock(DataAccessTabPane.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 an unmatchable string
    when(request.getText()).thenReturn("nothignshouldmatchthisstring");
    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 7 with DataAccessUtilities

use of au.gov.asd.tac.constellation.views.dataaccess.utilities.DataAccessUtilities 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)

Aggregations

DataAccessUtilities (au.gov.asd.tac.constellation.views.dataaccess.utilities.DataAccessUtilities)7 Test (org.testng.annotations.Test)7 DataAccessTabPane (au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane)5 Tab (javafx.scene.control.Tab)4 ShowDataAccessPluginTask (au.gov.asd.tac.constellation.views.dataaccess.tasks.ShowDataAccessPluginTask)3 SearchRequest (org.netbeans.spi.quicksearch.SearchRequest)3 SearchResponse (org.netbeans.spi.quicksearch.SearchResponse)3 Notification (org.openide.awt.Notification)2 NotificationDisplayer (org.openide.awt.NotificationDisplayer)2 Graph (au.gov.asd.tac.constellation.graph.Graph)1 DataAccessPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane)1 Platform (javafx.application.Platform)1