Search in sources :

Example 6 with DataAccessPane

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);
}
Also used : DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) InvocationTargetException(java.lang.reflect.InvocationTargetException) Test(org.testng.annotations.Test)

Example 7 with DataAccessPane

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);
}
Also used : DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) DataAccessViewTopComponent(au.gov.asd.tac.constellation.views.dataaccess.DataAccessViewTopComponent) WindowManager(org.openide.windows.WindowManager) Test(org.testng.annotations.Test)

Example 8 with 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();
    }
}
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) DataAccessState(au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState) Tab(javafx.scene.control.Tab) DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) Test(org.testng.annotations.Test)

Example 9 with DataAccessPane

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);
}
Also used : DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) DataAccessViewTopComponent(au.gov.asd.tac.constellation.views.dataaccess.DataAccessViewTopComponent) WindowManager(org.openide.windows.WindowManager) Test(org.testng.annotations.Test)

Example 10 with DataAccessPane

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())));
        });
    }
}
Also used : CoreGlobalParameters(au.gov.asd.tac.constellation.views.dataaccess.CoreGlobalParameters) JsonIO(au.gov.asd.tac.constellation.utilities.genericjsonio.JsonIO) Label(javafx.scene.control.Label) DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DataSourceTitledPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataSourceTitledPane) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) List(java.util.List) TabPane(javafx.scene.control.TabPane) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) Tab(javafx.scene.control.Tab) Optional(java.util.Optional) TypeReference(com.fasterxml.jackson.core.type.TypeReference) DataAccessUserPreferences(au.gov.asd.tac.constellation.views.dataaccess.api.DataAccessUserPreferences) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) ArrayList(java.util.ArrayList) List(java.util.List) DataAccessUserPreferences(au.gov.asd.tac.constellation.views.dataaccess.api.DataAccessUserPreferences)

Aggregations

DataAccessPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane)19 Test (org.testng.annotations.Test)15 Graph (au.gov.asd.tac.constellation.graph.Graph)8 DataAccessTabPane (au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane)8 Tab (javafx.scene.control.Tab)6 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)5 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)5 QueryPhasePane (au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane)5 DataAccessViewTopComponent (au.gov.asd.tac.constellation.views.dataaccess.DataAccessViewTopComponent)4 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)3 TabPane (javafx.scene.control.TabPane)3 WindowManager (org.openide.windows.WindowManager)3 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)2 JsonIO (au.gov.asd.tac.constellation.utilities.genericjsonio.JsonIO)2 DataAccessUserPreferences (au.gov.asd.tac.constellation.views.dataaccess.api.DataAccessUserPreferences)2 DataSourceTitledPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataSourceTitledPane)2 GlobalParametersPane (au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane)2 DataAccessState (au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState)2 QualityControlAutoVetter (au.gov.asd.tac.constellation.views.qualitycontrol.daemon.QualityControlAutoVetter)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2