Search in sources :

Example 36 with PluginInteraction

use of au.gov.asd.tac.constellation.plugins.PluginInteraction in project constellation by constellation-app.

the class ExtractTypesFromTextPluginNGTest method testNullQuery.

/**
 * Test of query method in class ExtractTypesFromTextPlugin using a null
 * string
 *
 * @throws Exception
 */
@Test(expectedExceptions = PluginException.class)
public void testNullQuery() throws Exception {
    RecordStore query = new GraphRecordStore();
    ExtractTypesFromTextPlugin instance = new ExtractTypesFromTextPlugin();
    PluginInteraction interaction = new TextPluginInteraction();
    PluginParameters parameters = instance.createParameters();
    RecordStore result = instance.query(query, interaction, parameters);
}
Also used : PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) Test(org.testng.annotations.Test)

Example 37 with PluginInteraction

use of au.gov.asd.tac.constellation.plugins.PluginInteraction in project constellation by constellation-app.

the class TSVDropperNGTest method testTSVDropperToGraphPlugin.

@Test
public void testTSVDropperToGraphPlugin() throws InterruptedException, PluginException {
    final PluginInteraction interaction = mock(PluginInteraction.class);
    final PluginParameters parameters = mock(PluginParameters.class);
    final StoreGraph graph = new StoreGraph(new AnalyticSchemaFactory().createSchema());
    VisualConcept.VertexAttribute.X.ensure(graph);
    VisualConcept.VertexAttribute.Y.ensure(graph);
    VisualConcept.VertexAttribute.Z.ensure(graph);
    final RecordStore recordStore = new GraphRecordStore();
    recordStore.add();
    recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "foo");
    recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.IDENTIFIER, "bar");
    final File file = new File(TSVDropperNGTest.class.getResource("./resources/sample.tsv").getFile());
    final List<File> files = new ArrayList<>();
    files.add(file);
    final TSVDropperToGraphPlugin plugin = new TSVDropperToGraphPlugin(recordStore, files);
    final RecordStore expResult = plugin.query(recordStore, interaction, parameters);
    assertEquals(recordStore, expResult);
}
Also used : PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) AnalyticSchemaFactory(au.gov.asd.tac.constellation.graph.schema.analytic.AnalyticSchemaFactory) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) ArrayList(java.util.ArrayList) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) TSVDropperToGraphPlugin(au.gov.asd.tac.constellation.views.dataaccess.templates.TSVDropper.TSVDropperToGraphPlugin) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) File(java.io.File) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 38 with PluginInteraction

use of au.gov.asd.tac.constellation.plugins.PluginInteraction in project constellation by constellation-app.

the class WorkflowQueryPluginNGTest method testExecute.

/**
 * Test of execute method, of class WorkflowQueryPlugin.
 */
@Test
public void testExecute() throws Exception {
    System.out.println("execute");
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    final DualGraph graph = new DualGraph(schema);
    // mock PluginGraphs
    final PluginGraphs pluginGraphs = mock(PluginGraphs.class);
    when(pluginGraphs.getGraph()).thenReturn(graph);
    final PluginInteraction interaction = new TextPluginInteraction();
    final WorkflowQueryPlugin instance = new WorkflowQueryPluginImpl();
    final PluginParameters parameters = instance.createParameters();
    instance.execute(pluginGraphs, interaction, parameters);
}
Also used : PluginGraphs(au.gov.asd.tac.constellation.plugins.PluginGraphs) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) Test(org.testng.annotations.Test)

Example 39 with PluginInteraction

use of au.gov.asd.tac.constellation.plugins.PluginInteraction in project constellation by constellation-app.

the class MergeNodesPluginNGTest method edit.

@Test
public void edit() throws InterruptedException, PluginException, MergeNodeType.MergeException {
    final GraphWriteMethods graph = mock(GraphWriteMethods.class);
    final PluginInteraction interaction = mock(PluginInteraction.class);
    final PluginParameters parameters = mock(PluginParameters.class);
    final PluginExecution pluginExecution = mock(PluginExecution.class);
    final PluginParameter mergeTypeParameter = mock(PluginParameter.class);
    final PluginParameter thresholdParameter = mock(PluginParameter.class);
    final PluginParameter mergerParameter = mock(PluginParameter.class);
    final PluginParameter leadParameter = mock(PluginParameter.class);
    final PluginParameter selectedParameter = mock(PluginParameter.class);
    final Map<String, PluginParameter<?>> pluginParameters = Map.of("MergeNodesPlugin.merge_type", mergeTypeParameter, "MergeNodesPlugin.threshold", thresholdParameter, "MergeNodesPlugin.merger", mergerParameter, "MergeNodesPlugin.lead", leadParameter, "MergeNodesPlugin.selected", selectedParameter);
    when(parameters.getParameters()).thenReturn(pluginParameters);
    when(mergeTypeParameter.getStringValue()).thenReturn(TestMergeType.NAME);
    when(thresholdParameter.getIntegerValue()).thenReturn(TestMergeType.MERGE_SUCCESS_THRESHOLD);
    when(mergerParameter.getStringValue()).thenReturn("Retain lead vertex attributes if present");
    when(leadParameter.getStringValue()).thenReturn("Longest Value");
    when(selectedParameter.getBooleanValue()).thenReturn(true);
    doReturn(null).when(pluginExecution).executeNow(graph);
    try (MockedStatic<PluginExecution> pluginExecutionMockedStatic = Mockito.mockStatic(PluginExecution.class)) {
        pluginExecutionMockedStatic.when(() -> PluginExecution.withPlugin(VisualSchemaPluginRegistry.COMPLETE_SCHEMA)).thenReturn(pluginExecution);
        mergeNodesPlugin.edit(graph, interaction, parameters);
        verify(pluginExecution).executeNow(graph);
        verify(interaction).setProgress(1, 0, "Merged 2 nodes.", true);
    // Due to accessibility issues the call to mergeVerticies and its follow
    // on logic cannot be verified without tying this test to the logic of
    // one of the concrete implementations of GraphElementMerger.
    }
}
Also used : PluginExecution(au.gov.asd.tac.constellation.plugins.PluginExecution) GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 40 with PluginInteraction

use of au.gov.asd.tac.constellation.plugins.PluginInteraction in project constellation by constellation-app.

the class QueryNameValidatorNGTest method testValidatePreQueryWhenBlank.

/**
 * Test of validatePreQuery method, of class QueryNameValidator.
 */
@Test(expectedExceptions = PluginException.class)
public void testValidatePreQueryWhenBlank() throws Exception {
    System.out.println("testValidatePreQueryWhenBlank");
    final RecordStoreQueryPlugin plugin = mock(RecordStoreQueryPlugin.class);
    final RecordStore recordStore = mock(RecordStore.class);
    final PluginInteraction interaction = mock(PluginInteraction.class);
    final PluginParameters parameters = mock(PluginParameters.class);
    final QueryNameValidator instance = new QueryNameValidator();
    when(parameters.getStringValue(CoreGlobalParameters.QUERY_NAME_PARAMETER_ID)).thenReturn("");
    instance.validatePreQuery(plugin, recordStore, interaction, parameters);
}
Also used : PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Test(org.testng.annotations.Test)

Aggregations

PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)51 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)44 Test (org.testng.annotations.Test)33 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)16 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)15 ArrayList (java.util.ArrayList)15 TextPluginInteraction (au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction)14 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)13 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)12 PluginGraphs (au.gov.asd.tac.constellation.plugins.PluginGraphs)10 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)9 Graph (au.gov.asd.tac.constellation.graph.Graph)8 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)8 RecordStore (au.gov.asd.tac.constellation.graph.processing.RecordStore)8 List (java.util.List)8 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)7 PluginInfo (au.gov.asd.tac.constellation.plugins.PluginInfo)7 PluginTags (au.gov.asd.tac.constellation.plugins.templates.PluginTags)7 SimpleEditPlugin (au.gov.asd.tac.constellation.plugins.templates.SimpleEditPlugin)7 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)6