Search in sources :

Example 81 with PluginParameters

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

Example 82 with PluginParameters

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);
}
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 83 with PluginParameters

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));
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 84 with PluginParameters

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

Example 85 with PluginParameters

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);
}
Also used : RecordStoreDropperToGraphPlugin(au.gov.asd.tac.constellation.views.dataaccess.templates.RecordStoreDropper.RecordStoreDropperToGraphPlugin) 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) GraphRecordStore(au.gov.asd.tac.constellation.graph.processing.GraphRecordStore) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Aggregations

PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)377 Test (org.testng.annotations.Test)185 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)60 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)60 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)58 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)58 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)52 IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)48 ArrayList (java.util.ArrayList)47 Graph (au.gov.asd.tac.constellation.graph.Graph)37 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)34 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)32 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)24 List (java.util.List)20 Map (java.util.Map)20 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)19 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)19 ObjectParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ObjectParameterType.ObjectParameterValue)19 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)17 IOException (java.io.IOException)17