use of au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction in project constellation by constellation-app.
the class SelectTopNNGTest method testEditWithNoResults.
@Test
public void testEditWithNoResults() throws Exception {
final StoreGraph graph = new StoreGraph(SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema());
final int vertexLabelAttr = VisualConcept.VertexAttribute.LABEL.ensure(graph);
final int vertexSelectedAttr = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
final int vertexTypeAttr = AnalyticConcept.VertexAttribute.TYPE.ensure(graph);
final int transactionTypeAttr = AnalyticConcept.TransactionAttribute.TYPE.ensure(graph);
final int vx0 = graph.addVertex();
graph.setStringValue(vertexLabelAttr, vx0, "foo");
graph.setBooleanValue(vertexSelectedAttr, vx0, true);
final PluginInteraction interaction = new TextPluginInteraction();
final SelectTopNPlugin instance = new SelectTopNPlugin();
final PluginParameters parameters = instance.createParameters();
parameters.getParameters().get(SelectTopNPlugin.MODE_PARAMETER_ID).setStringValue(SelectTopNPlugin.NODE);
parameters.getParameters().get(SelectTopNPlugin.TYPE_CATEGORY_PARAMETER_ID).setStringValue(AnalyticConcept.VertexType.LOCATION.getName());
// TYPE_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> subTypeParameter = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(SelectTopNPlugin.TYPE_PARAMETER_ID);
final List<String> arrayList = new ArrayList<>();
arrayList.add(AnalyticConcept.VertexType.COUNTRY.getName());
MultiChoiceParameterType.setChoices(subTypeParameter, arrayList);
parameters.getParameters().get(SelectTopNPlugin.LIMIT_PARAMETER_ID).setIntegerValue(2);
instance.edit(graph, interaction, parameters);
assertEquals(1, graph.getVertexCount());
assertTrue(graph.getBooleanValue(vertexSelectedAttr, vx0));
}
use of au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction in project constellation by constellation-app.
the class SelectTopNNGTest method testEditWithTopTwoContactsAndEverythingIsCommunicationTransactions.
@Test
public void testEditWithTopTwoContactsAndEverythingIsCommunicationTransactions() throws Exception {
final StoreGraph graph = new StoreGraph(SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema());
final int vertexLabelAttr = VisualConcept.VertexAttribute.LABEL.ensure(graph);
final int vertexSelectedAttr = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
final int vertexTypeAttr = AnalyticConcept.VertexAttribute.TYPE.ensure(graph);
final int transactionTypeAttr = AnalyticConcept.TransactionAttribute.TYPE.ensure(graph);
final int sourceVxId = graph.addVertex();
graph.setStringValue(vertexLabelAttr, sourceVxId, "source");
graph.setBooleanValue(vertexSelectedAttr, sourceVxId, true);
// buildId the graph
for (int i = 0; i < 10; i++) {
final int desintationVxId = graph.addVertex();
graph.setStringValue(vertexLabelAttr, desintationVxId, String.format("destination %s", i));
for (int j = i; j < 10; j++) {
int txId = graph.addTransaction(sourceVxId, desintationVxId, true);
graph.setObjectValue(transactionTypeAttr, txId, AnalyticConcept.TransactionType.COMMUNICATION.getName());
}
}
final PluginInteraction interaction = new TextPluginInteraction();
final SelectTopNPlugin instance = new SelectTopNPlugin();
final PluginParameters parameters = instance.createParameters();
parameters.getParameters().get(SelectTopNPlugin.MODE_PARAMETER_ID).setStringValue(SelectTopNPlugin.TRANSACTION);
parameters.getParameters().get(SelectTopNPlugin.TYPE_CATEGORY_PARAMETER_ID).setStringValue(AnalyticConcept.TransactionType.COMMUNICATION.getName());
// TYPE_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> subTypeParameter = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(SelectTopNPlugin.TYPE_PARAMETER_ID);
final List<String> arrayList = new ArrayList<>();
arrayList.add(AnalyticConcept.TransactionType.COMMUNICATION.getName());
MultiChoiceParameterType.setChoices(subTypeParameter, arrayList);
parameters.getParameters().get(SelectTopNPlugin.LIMIT_PARAMETER_ID).setIntegerValue(2);
instance.edit(graph, interaction, parameters);
assertTrue(graph.getBooleanValue(vertexSelectedAttr, sourceVxId));
assertTrue(graph.getBooleanValue(vertexSelectedAttr, sourceVxId + 1));
assertTrue(graph.getBooleanValue(vertexSelectedAttr, sourceVxId + 2));
for (int i = 3; i < 10; i++) {
assertFalse(graph.getBooleanValue(vertexSelectedAttr, sourceVxId + i));
}
}
use of au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction in project constellation by constellation-app.
the class ExtractTypesFromTextPluginNGTest method testQuery.
/**
* Test of query method, of class ExtractTypesFromTextPlugin.
*
* @throws java.lang.Exception
*/
@Test
public void testQuery() throws Exception {
RecordStore query = new GraphRecordStore();
ExtractTypesFromTextPlugin instance = new ExtractTypesFromTextPlugin();
PluginInteraction interaction = new TextPluginInteraction();
PluginParameters parameters = instance.createParameters();
parameters.getParameters().get(ExtractTypesFromTextPlugin.TEXT_PARAMETER_ID).setStringValue("Email Person Communication");
RecordStore expResult = new GraphRecordStore();
RecordStore result = instance.query(query, interaction, parameters);
assertEquals(result, expResult);
}
use of au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction 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.text.TextPluginInteraction 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);
}
Aggregations