use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class DataAccessPaneNGTest method searchTextFieldListener.
/**
* I suspect this doesn't work because the action handler is initialized during
* the constructor and the spy is not applied until after the construction is
* complete.
*/
@Test(enabled = false)
public void searchTextFieldListener() {
final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
final QueryPhasePane queryPhasePane = mock(QueryPhasePane.class);
when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
when(dataAccessTabPane.getQueryPhasePaneOfCurrentTab()).thenReturn(queryPhasePane);
dataAccessPane.getSearchPluginTextField().setText("example");
verify(queryPhasePane).showMatchingPlugins("example");
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class DataAccessPaneNGTest method verifyUpdateWithGraphId.
/**
* Verifies the graph ID is set and the correct execute button setting is made.
*
* @param graphId the graph ID
* @param tabPaneValid
* @param queriesRunning true if the queries are running, false otherwise
* @param verification a function with verifications to make after the code is run
*/
private void verifyUpdateWithGraphId(final String graphId, final boolean disableExecuteButton, final boolean queriesRunning, final Consumer<Boolean> verification) {
final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
when(dataAccessPane.determineExecuteButtonDisableState(anyBoolean())).thenReturn(disableExecuteButton);
when(dataAccessTabPane.isTabPaneExecutable()).thenReturn(true);
DataAccessPaneState.setQueriesRunning(graphId, queriesRunning);
dataAccessPane.update(graphId);
verification.accept(disableExecuteButton);
verify(dataAccessTabPane).updateTabMenus();
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class DataAccessSearchProviderNGTest method testEvaluateSuccess.
/**
* Test of evaluate method, of class DataAccessSearchProvider.
*/
@Test
public void testEvaluateSuccess() {
System.out.println("evaluate success");
// 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 request to return the selected text
when(request.getText()).thenReturn("Select");
// Return a valid response when results are added that match the expected
when(response.addResult(Mockito.any(), Mockito.eq("Select Top N"))).thenReturn(true);
when(response.addResult(Mockito.any(), Mockito.eq("Select All"))).thenReturn(true);
DataAccessSearchProvider instance = new DataAccessSearchProvider();
instance.evaluate(request, response);
// Verify that addResult was called on the correct plugins
verify(response, times(1)).addResult(Mockito.any(), Mockito.eq("Select Top N"));
verify(response, times(1)).addResult(Mockito.any(), Mockito.eq("Select All"));
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane in project constellation by constellation-app.
the class DataAccessSearchProviderNGTest method testRun1.
// //////////////////////////////////////////////////////////////////////////
// ///////////////// Start of PluginDisplayer Tests ///////////////////////
// //////////////////////////////////////////////////////////////////////////
/**
* Test of run method, of class PluginDisplayer.
*/
@Test
public void testRun1() {
System.out.println("testRun1 testing query phase pane was successfully returned");
// Setting up mocks
daPane = mock(DataAccessPane.class);
datPane = mock(DataAccessTabPane.class);
qpPane = mock(QueryPhasePane.class);
// Do nothing when the plugin is called to expand
// May never get here with the code existing in the Platform thread.
doNothing().when(qpPane).expandPlugin(Mockito.eq("SelectTopN"));
// Mock the static method getQueryPhasePane to return the mocked QueryPhasePane
try (MockedStatic<DataAccessTabPane> mockedStatic = Mockito.mockStatic(DataAccessTabPane.class)) {
mockedStatic.when(() -> DataAccessTabPane.getQueryPhasePane(Mockito.any(Tab.class))).thenReturn(qpPane);
// Return a new tab when the DataAccessPane mock is prompted for getCurrentTab
when(daPane.getDataAccessTabPane()).thenReturn(datPane);
when(datPane.getCurrentTab()).thenReturn(new Tab());
// Mock the static method getDataAccessPane and return the mocked DataAccessPane
try (MockedStatic<DataAccessUtilities> mockedStatic2 = Mockito.mockStatic(DataAccessUtilities.class)) {
mockedStatic2.when(() -> DataAccessUtilities.getDataAccessPane()).thenReturn(daPane);
try {
ShowDataAccessPluginTask pd = new ShowDataAccessPluginTask("SelectTopN");
pd.run();
} catch (final IllegalStateException ex) {
// Catch the exception which happens when executing Platform thread in standalone tests
// Fail for any other exception
}
// Verify that getCurrentTab was succcessfully called.
verify(datPane, times(1)).getCurrentTab();
// Verify that getQueryPhasePane was succcessfully called.
mockedStatic.verify(() -> DataAccessTabPane.getQueryPhasePane(Mockito.any()));
}
}
}
use of au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane 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());
}
Aggregations