Search in sources :

Example 31 with GraphWriteMethods

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);
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 32 with GraphWriteMethods

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), "");
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) JsonFactory(com.fasterxml.jackson.core.JsonFactory) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 33 with GraphWriteMethods

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);
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 34 with GraphWriteMethods

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());
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) ObservableList(javafx.collections.ObservableList) HashMap(java.util.HashMap) TableView(javafx.scene.control.TableView) Test(org.testng.annotations.Test)

Example 35 with GraphWriteMethods

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());
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) TableViewState(au.gov.asd.tac.constellation.views.tableview.state.TableViewState) Test(org.testng.annotations.Test)

Aggregations

GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)40 Test (org.testng.annotations.Test)26 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)16 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)15 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)10 HashMap (java.util.HashMap)9 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)8 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Map (java.util.Map)8 Attribute (au.gov.asd.tac.constellation.graph.Attribute)7 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)7 ArrayList (java.util.ArrayList)7 AnalyticConcept (au.gov.asd.tac.constellation.graph.schema.analytic.concept.AnalyticConcept)6 SimpleEditPlugin (au.gov.asd.tac.constellation.plugins.templates.SimpleEditPlugin)6 List (java.util.List)6 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)5 PluginInfo (au.gov.asd.tac.constellation.plugins.PluginInfo)5 PluginType (au.gov.asd.tac.constellation.plugins.PluginType)5