use of au.gov.asd.tac.constellation.graph.GraphWriteMethods in project constellation by constellation-app.
the class DefaultPluginEnvironmentNGTest method testExecuteEditPluginNowThrowsPluginException.
@Test(expectedExceptions = PluginException.class)
public void testExecuteEditPluginNowThrowsPluginException() throws Exception {
System.out.println("executeEditPluginNow");
GraphWriteMethods graph = mock(GraphWriteMethods.class);
Plugin plugin = mock(Plugin.class);
PluginException pluginException = mock(PluginException.class);
PluginParameters parameters = mock(PluginParameters.class);
boolean interactive = false;
doThrow(pluginException).when(plugin).run(any(GraphWriteMethods.class), any(PluginInteraction.class), any(PluginParameters.class));
when(pluginException.getNotificationLevel()).thenReturn(PluginNotificationLevel.FATAL);
DefaultPluginEnvironment instance = new DefaultPluginEnvironment();
instance.executeEditPluginNow(graph, plugin, parameters, interactive);
}
use of au.gov.asd.tac.constellation.graph.GraphWriteMethods in project constellation by constellation-app.
the class TableViewStateIoProviderNGTest method writeObjectIsDefaultValue.
@Test
public void writeObjectIsDefaultValue() throws IOException {
final Attribute attribute = mock(Attribute.class);
when(attribute.getId()).thenReturn(ATTRIBUTE_ID);
when(attribute.getName()).thenReturn("ATTR NAME");
final GraphWriteMethods graph = mock(GraphWriteMethods.class);
when(graph.isDefaultValue(ATTRIBUTE_ID, ELEMENT_ID)).thenReturn(true);
final JsonFactory factory = new JsonFactory();
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final JsonGenerator jsonGenerator = factory.createGenerator(output);
tableViewStateIoProvider.writeObject(attribute, ELEMENT_ID, jsonGenerator, graph, null, false);
jsonGenerator.flush();
assertEquals(new String(output.toByteArray(), StandardCharsets.UTF_8), "");
}
use of au.gov.asd.tac.constellation.graph.GraphWriteMethods in project constellation by constellation-app.
the class TableViewStateIoProviderNGTest method readObjectNullJson.
@Test
public void readObjectNullJson() throws IOException {
final ObjectMapper objectMapper = new ObjectMapper();
JsonNode root = objectMapper.readTree("null");
final GraphWriteMethods graph = mock(GraphWriteMethods.class);
tableViewStateIoProvider.readObject(ATTRIBUTE_ID, ELEMENT_ID, root, graph, null, null, null, null);
verifyNoInteractions(graph);
}
use of au.gov.asd.tac.constellation.graph.GraphWriteMethods in project constellation by constellation-app.
the class SelectionToGraphPluginNGTest method selectionToGraph.
@Test
public void selectionToGraph() throws InterruptedException, PluginException {
final ObservableList<String> row1 = FXCollections.observableList(List.of("row1Column1", "row1Column2"));
final ObservableList<String> row2 = FXCollections.observableList(List.of("row2Column1", "row2Column2"));
final TableView<ObservableList<String>> table = mock(TableView.class);
final TableView.TableViewSelectionModel<ObservableList<String>> selectionModel = mock(TableView.TableViewSelectionModel.class);
final GraphWriteMethods graph = mock(GraphWriteMethods.class);
final Map<ObservableList<String>, Integer> index = new HashMap<>();
index.put(row1, 1);
index.put(row2, 2);
// Two rows. Row 1 is selected
when(table.getItems()).thenReturn(FXCollections.observableList(List.of(row1, row2)));
when(table.getSelectionModel()).thenReturn(selectionModel);
when(selectionModel.getSelectedItems()).thenReturn(FXCollections.observableList(List.of(row1)));
final SelectionToGraphPlugin selectionToGraph = new SelectionToGraphPlugin(table, index, GraphElementType.VERTEX);
selectionToGraph.edit(graph, null, null);
verify(graph).setBooleanValue(0, 1, true);
verify(graph).setBooleanValue(0, 2, false);
assertEquals("Table View: Select on Graph", selectionToGraph.getName());
}
use of au.gov.asd.tac.constellation.graph.GraphWriteMethods in project constellation by constellation-app.
the class UpdateStatePluginNGTest method updateStatePlugin.
@Test
public void updateStatePlugin() throws InterruptedException, PluginException {
final GraphWriteMethods graph = mock(GraphWriteMethods.class);
final TableViewState tableViewState = new TableViewState();
tableViewState.setElementType(GraphElementType.META);
final UpdateStatePlugin updateStatePlugin = new UpdateStatePlugin(tableViewState);
updateStatePlugin.edit(graph, null, null);
final ArgumentCaptor<TableViewState> captor = ArgumentCaptor.forClass(TableViewState.class);
verify(graph).setObjectValue(eq(0), eq(0), captor.capture());
assertEquals(tableViewState, captor.getValue());
assertNotSame(tableViewState, captor.getValue());
assertEquals("Table View: Update State", updateStatePlugin.getName());
}
Aggregations