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