use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane in project constellation by constellation-app.
the class DataAccessUtilitiesNGTest method testGetDataAccessPaneNotCalledByEventDispatchThreadError.
@Test
public void testGetDataAccessPaneNotCalledByEventDispatchThreadError() {
swingUtilitiesStaticMock.when(SwingUtilities::isEventDispatchThread).thenReturn(false);
swingUtilitiesStaticMock.when(() -> SwingUtilities.invokeAndWait(any(Runnable.class))).thenThrow(new InvocationTargetException(new RuntimeException("Something Bad")));
final DataAccessPane actual = DataAccessUtilities.getDataAccessPane();
assertNull(actual);
}
use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane in project constellation by constellation-app.
the class DataAccessUtilitiesNGTest method testGetDataAccessPaneCalledByEventDispatchThread.
@Test
public void testGetDataAccessPaneCalledByEventDispatchThread() {
final WindowManager windowManager = mock(WindowManager.class);
final DataAccessViewTopComponent topComponent = mock(DataAccessViewTopComponent.class);
final DataAccessPane dataAccessPane = mock(DataAccessPane.class);
swingUtilitiesStaticMock.when(SwingUtilities::isEventDispatchThread).thenReturn(true);
windowManagerStaticMock.when(WindowManager::getDefault).thenReturn(windowManager);
when(windowManager.findTopComponent(DataAccessViewTopComponent.class.getSimpleName())).thenReturn(topComponent);
when(topComponent.isOpened()).thenReturn(false);
when(topComponent.getDataAccessPane()).thenReturn(dataAccessPane);
DataAccessPane actual = DataAccessUtilities.getDataAccessPane();
verify(topComponent, times(1)).open();
verify(topComponent, times(1)).requestVisible();
assertSame(actual, dataAccessPane);
}
use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane in project constellation by constellation-app.
the class DataAccessUtilitiesNGTest method loadDataAccessState_empty_state.
@Test
public void loadDataAccessState_empty_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(new DataAccessState());
// 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();
}
}
use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane in project constellation by constellation-app.
the class DataAccessUtilitiesNGTest method testGetDataAccessPaneCalledByEventDispatchThreadTopComponentNull.
@Test
public void testGetDataAccessPaneCalledByEventDispatchThreadTopComponentNull() {
final WindowManager windowManager = mock(WindowManager.class);
swingUtilitiesStaticMock.when(SwingUtilities::isEventDispatchThread).thenReturn(true);
windowManagerStaticMock.when(WindowManager::getDefault).thenReturn(windowManager);
when(windowManager.findTopComponent(DataAccessViewTopComponent.class.getSimpleName())).thenReturn(null);
DataAccessPane actual = DataAccessUtilities.getDataAccessPane();
assertNull(actual);
}
use of au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane in project constellation by constellation-app.
the class DataAccessParametersIoProvider method loadParameters.
/**
* Loads global and plugin parameters from a JSON file into the passed {@link DataAccessPane}.
* If the JSON is loaded then all existing tabs will be removed and then new tabs added
* for each entry in the loaded JSON array.
*
* @param dataAccessPane the pane to load the JSON parameter file into
* @see JsonIO#loadJsonPreferences(Optional, TypeReference)
*/
public static void loadParameters(final DataAccessPane dataAccessPane) {
final List<DataAccessUserPreferences> loadedParameters = JsonIO.loadJsonPreferences(Optional.of(DATA_ACCESS_DIR), new TypeReference<List<DataAccessUserPreferences>>() {
});
if (loadedParameters != null) {
dataAccessPane.getDataAccessTabPane().removeTabs();
loadedParameters.forEach(loadedParameter -> {
final QueryPhasePane pluginPane = dataAccessPane.getDataAccessTabPane().newTab(loadedParameter.getStepCaption());
// If an existing global parameter is in the JSON then update it,
// otherwise ignore it
pluginPane.getGlobalParametersPane().getParams().getParameters().entrySet().stream().filter(param -> loadedParameter.getGlobalParameters().containsKey(param.getKey())).forEach(param -> param.getValue().setStringValue(loadedParameter.getGlobalParameters().get(param.getKey())));
// Groups all the parameters in to the plugin groups. Common parameters
// are based on the plugin name that is before the first '.' in the key values
pluginPane.getDataAccessPanes().stream().filter(pane -> loadedParameter.getPluginParameters().containsKey(pane.getPlugin().getClass().getSimpleName()) && loadedParameter.getPluginParameters().get(pane.getPlugin().getClass().getSimpleName()).containsKey(getEnabledPluginKey(pane)) && Boolean.valueOf(loadedParameter.getPluginParameters().get(pane.getPlugin().getClass().getSimpleName()).get(getEnabledPluginKey(pane)))).forEach(pane -> pane.setParameterValues(loadedParameter.getPluginParameters().get(pane.getPlugin().getClass().getSimpleName())));
});
}
}
Aggregations