use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class TestParametersPluginNGTest method testQueryException4.
/**
* Test of query method, of class TestParametersPlugin. Tests throwing of
* error pluginException
*/
@Test(expectedExceptions = PluginException.class)
public void testQueryException4() throws Exception {
System.out.println("throw pluginexception4");
final TestParametersPlugin instance = new TestParametersPlugin();
final PluginParameters result = instance.createParameters();
final GraphRecordStore recordStore = new GraphRecordStore();
final DefaultPluginInteraction interaction = new DefaultPluginInteraction(null, null);
// Set plugin query name here before execution
result.getParameters().get(CoreGlobalParameters.QUERY_NAME_PARAMETER_ID).setStringValue("TESTPARAMETERSPLUGIN");
// Set plugin parameters here before execution
result.getParameters().get(TestParametersPlugin.LEVEL_PARAMETER_ID).setStringValue("Error");
try {
instance.query(recordStore, interaction, result);
} catch (final PluginException ex) {
assertEquals(ex.getNotificationLevel(), PluginNotificationLevel.ERROR);
throw ex;
}
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class ExtractTypesFromTextPluginNGTest method testRegexQuery.
/**
* Test of query method in class ExtractTypesFromTextPlugin using a string
* where a detection regex is picked up
*
* @throws Exception
*/
@Test
public void testRegexQuery() 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("abc@def.ghi");
RecordStore result = instance.query(query, interaction, parameters);
RecordStore expResult = new GraphRecordStore();
expResult.add();
expResult.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "abc@def.ghi");
expResult.set(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.TYPE, AnalyticConcept.VertexType.EMAIL_ADDRESS);
expResult.set(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.SEED, "true");
assertEquals(result, expResult);
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class ExtractWordsFromTextPluginNGTest method testUpdateParameters.
/**
* Test updateParameters
*/
@Test
public void testUpdateParameters() {
ExtractWordsFromTextPlugin instance = new ExtractWordsFromTextPlugin();
PluginParameters parameters = new PluginParameters();
final PluginParameter<SingleChoiceParameterValue> attributeType = SingleChoiceParameterType.build(ATTRIBUTE_PARAMETER_ID);
parameters.addParameter(attributeType);
final PluginParameter<StringParameterValue> textParameter = StringParameterType.build(WORDS_PARAMETER_ID);
textParameter.setStringValue("text");
parameters.addParameter(textParameter);
final PluginParameter<BooleanParameterValue> useRegexParameter = BooleanParameterType.build(USE_REGEX_PARAMETER_ID);
useRegexParameter.setBooleanValue(true);
parameters.addParameter(useRegexParameter);
Graph graph1 = new DualGraph(graph.getSchema(), graph);
instance.updateParameters(graph1, parameters);
assertEquals(parameters.getParameters().size(), 3);
assertTrue(parameters.hasParameter(ExtractWordsFromTextPlugin.ATTRIBUTE_PARAMETER_ID));
assertEquals(parameters.getParameters().get(ExtractWordsFromTextPlugin.WORDS_PARAMETER_ID).getStringValue(), "text");
assertEquals(parameters.getParameters().get(ExtractWordsFromTextPlugin.USE_REGEX_PARAMETER_ID).getBooleanValue(), true);
assertFalse(parameters.hasParameter(ExtractWordsFromTextPlugin.SELECTED_ONLY_PARAMETER_ID));
parameters = instance.createParameters();
instance.updateParameters(graph1, parameters);
assertEquals(parameters.getParameters().size(), 11);
assertTrue(parameters.hasParameter(ExtractWordsFromTextPlugin.SELECTED_ONLY_PARAMETER_ID));
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class QueryNameValidatorNGTest method testValidatePreQueryWhenNotBlank.
/**
* Test of validatePreQuery method, of class QueryNameValidator.
*/
@Test
public void testValidatePreQueryWhenNotBlank() throws Exception {
System.out.println("testValidatePreQueryWhenNotBlank");
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("my query name");
instance.validatePreQuery(plugin, recordStore, interaction, parameters);
verify(parameters, times(1)).getStringValue(CoreGlobalParameters.QUERY_NAME_PARAMETER_ID);
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class RecordStoreDropperNGTest method testRecordStoreDropperToGraphPlugin.
@Test
public void testRecordStoreDropperToGraphPlugin() 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 RecordStoreDropperToGraphPlugin plugin = new RecordStoreDropperToGraphPlugin(recordStore);
final RecordStore expResult = plugin.query(recordStore, interaction, parameters);
assertEquals(recordStore, expResult);
}
Aggregations