Search in sources :

Example 11 with DataAccessState

use of au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState in project constellation by constellation-app.

the class DataAccessUtilitiesNGTest method testsaveDataAccessState.

@Test
public void testsaveDataAccessState() throws Exception {
    System.out.println("testsaveDataAccessState");
    // mock Tab
    final Tab tab = mock(Tab.class);
    ObservableList<Tab> observableArrayList = FXCollections.observableArrayList(tab);
    // mock TabPane
    final TabPane tabPane = mock(TabPane.class);
    when(tabPane.getTabs()).thenReturn(observableArrayList);
    final ScrollPane scrollPane = mock(ScrollPane.class);
    final QueryPhasePane queryPhasePane = mock(QueryPhasePane.class);
    final GlobalParametersPane globalParametersPane = mock(GlobalParametersPane.class);
    final PluginParameters pluginParameters = mock(PluginParameters.class);
    final PluginParameter pluginParameter = mock(PluginParameter.class);
    when(tab.getContent()).thenReturn(scrollPane);
    when(scrollPane.getContent()).thenReturn(queryPhasePane);
    when(queryPhasePane.getGlobalParametersPane()).thenReturn(globalParametersPane);
    when(globalParametersPane.getParams()).thenReturn(pluginParameters);
    when(pluginParameter.getStringValue()).thenReturn("something");
    final String someKey = "someKey";
    final Map<String, PluginParameter<?>> map = Map.of(someKey, pluginParameter);
    when(pluginParameters.getParameters()).thenReturn(map);
    // mock graph
    final Graph graph = mock(Graph.class);
    final WritableGraph wGraph = mock(WritableGraph.class);
    when(graph.getWritableGraph("Update Data Access State", true)).thenReturn(wGraph);
    DataAccessUtilities.saveDataAccessState(tabPane, graph);
    final DataAccessState expectedTab = new DataAccessState();
    expectedTab.newTab();
    expectedTab.add("someKey", "something");
    assertEquals(expectedTab.getState().size(), 1);
    verify(wGraph).setObjectValue(0, 0, expectedTab);
}
Also used : TabPane(javafx.scene.control.TabPane) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) GlobalParametersPane(au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) Tab(javafx.scene.control.Tab) DataAccessState(au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState) ScrollPane(javafx.scene.control.ScrollPane) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Aggregations

DataAccessState (au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState)11 Test (org.testng.annotations.Test)7 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 Tab (javafx.scene.control.Tab)5 Graph (au.gov.asd.tac.constellation.graph.Graph)4 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)4 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)4 DataAccessTabPane (au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Map (java.util.Map)4 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)3 DataAccessPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane)3 HashMap (java.util.HashMap)3 TabPane (javafx.scene.control.TabPane)3 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)2 GlobalParametersPane (au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane)2 QueryPhasePane (au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane)2 FileInputStream (java.io.FileInputStream)2 Attribute (au.gov.asd.tac.constellation.graph.Attribute)1