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