Search in sources :

Example 1 with TextPluginInteraction

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

the class MergeTransactionsPluginNGTest method testEditNullTypeName.

/**
 * Test of edit method with a null merge transaction type name
 *
 * @throws Exception
 */
@Test(expectedExceptions = PluginException.class)
public void testEditNullTypeName() throws Exception {
    MergeTransactionsPlugin instance = new MergeTransactionsPlugin();
    PluginInteraction interaction = new TextPluginInteraction();
    PluginParameters parameters = instance.createParameters();
    instance.edit(graph, interaction, parameters);
}
Also used : PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) Test(org.testng.annotations.Test)

Example 2 with TextPluginInteraction

use of au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction 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 3 with TextPluginInteraction

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

the class SelectTopNNGTest method testEditWithTopTwoLocationsContainingDifferentTypes.

@Test
public void testEditWithTopTwoLocationsContainingDifferentTypes() 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);
    graph.setObjectValue(vertexTypeAttr, sourceVxId, AnalyticConcept.VertexType.COUNTRY);
    // buildId the graph
    for (int i = 0; i < 2; i++) {
        final int desintationVxId = graph.addVertex();
        graph.setStringValue(vertexLabelAttr, desintationVxId, String.format("destination %s", i));
        graph.setObjectValue(vertexTypeAttr, desintationVxId, AnalyticConcept.VertexType.COUNTRY);
        for (int j = i; j < 10; j++) {
            graph.addTransaction(sourceVxId, desintationVxId, true);
        }
    }
    for (int i = 3; i < 10; i++) {
        final int desintationVxId = graph.addVertex();
        graph.setStringValue(vertexLabelAttr, desintationVxId, String.format("destination %s", i));
        graph.setObjectValue(vertexTypeAttr, desintationVxId, AnalyticConcept.VertexType.DOCUMENT);
        for (int j = i; j < 10; j++) {
            graph.addTransaction(sourceVxId, desintationVxId, 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);
    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));
    }
}
Also used : MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 4 with TextPluginInteraction

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

the class SelectTopNNGTest method testEditWithTopTwoLocationsAndEverythingIsGci.

@Test
public void testEditWithTopTwoLocationsAndEverythingIsGci() 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);
    graph.setObjectValue(vertexTypeAttr, sourceVxId, AnalyticConcept.VertexType.COUNTRY);
    // buildId the graph
    for (int i = 0; i < 10; i++) {
        final int desintationVxId = graph.addVertex();
        graph.setStringValue(vertexLabelAttr, desintationVxId, String.format("destination %s", i));
        graph.setObjectValue(vertexTypeAttr, desintationVxId, AnalyticConcept.VertexType.COUNTRY);
        for (int j = i; j < 10; j++) {
            graph.addTransaction(sourceVxId, desintationVxId, 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);
    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));
    }
}
Also used : MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 5 with TextPluginInteraction

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

the class SelectTopNNGTest method testEditWithTopFiveLocationsWithEqualCounts.

@Test
public void testEditWithTopFiveLocationsWithEqualCounts() 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);
    graph.setObjectValue(vertexTypeAttr, sourceVxId, AnalyticConcept.VertexType.COUNTRY);
    // buildId the graph
    for (int i = 0; i < 5; i++) {
        final int desintationVxId = graph.addVertex();
        graph.setStringValue(vertexLabelAttr, desintationVxId, String.format("destination %s", i));
        graph.setObjectValue(vertexTypeAttr, desintationVxId, AnalyticConcept.VertexType.COUNTRY);
        for (int j = 0; j < 5; j++) {
            graph.addTransaction(sourceVxId, desintationVxId, 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(5);
    instance.edit(graph, interaction, parameters);
    for (int i = 0; i < 5; i++) {
        assertTrue(graph.getBooleanValue(vertexSelectedAttr, i));
    }
}
Also used : MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Aggregations

PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)14 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)14 TextPluginInteraction (au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction)14 Test (org.testng.annotations.Test)14 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)7 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)6 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)6 ArrayList (java.util.ArrayList)6 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)3 RecordStore (au.gov.asd.tac.constellation.graph.processing.RecordStore)3 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)1 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)1 PluginGraphs (au.gov.asd.tac.constellation.plugins.PluginGraphs)1