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