Search in sources :

Example 21 with GraphRecordStore

use of au.gov.asd.tac.constellation.graph.processing.GraphRecordStore in project constellation by constellation-app.

the class TestParametersPluginNGTest method testQueryException1.

/**
 * Test of query method, of class TestParametersPlugin. Tests throwing of
 * debug pluginException
 */
@Test(expectedExceptions = PluginException.class)
public void testQueryException1() throws Exception {
    System.out.println("throw pluginexception1");
    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("Debug");
    try {
        instance.query(recordStore, interaction, result);
    } catch (final PluginException ex) {
        assertEquals(ex.getNotificationLevel(), PluginNotificationLevel.DEBUG);
        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 22 with GraphRecordStore

use of au.gov.asd.tac.constellation.graph.processing.GraphRecordStore in project constellation by constellation-app.

the class TestParametersPluginNGTest method testQueryResults.

/**
 * Test of query method, of class TestParametersPlugin. Tests querying
 * results from graph
 */
@Test
public void testQueryResults() throws Exception {
    System.out.println("Test Query Results");
    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("None");
    final RecordStore queryResults = instance.query(recordStore, interaction, result);
    // Test the amount of entries in the RecordStore
    assertEquals(queryResults.size(), 1);
    final DateTimeRange dtr = result.getDateTimeRangeValue(CoreGlobalParameters.DATETIME_RANGE_PARAMETER_ID);
    final ZonedDateTime[] dtrStartEnd = dtr.getZonedStartEnd();
    // Test the values entered
    assertEquals(queryResults.get(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.RAW), "name1@domain1.com");
    assertEquals(queryResults.get(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.TYPE), "Email");
    assertEquals(queryResults.get(GraphRecordStoreUtilities.SOURCE + AnalyticConcept.VertexAttribute.COMMENT), "TESTPARAMETERSPLUGIN");
    assertEquals(queryResults.get(GraphRecordStoreUtilities.SOURCE + TemporalConcept.VertexAttribute.LAST_SEEN), DateTimeFormatter.ISO_INSTANT.format(dtrStartEnd[0]).replace("Z", ".000Z"));
    assertEquals(queryResults.get(GraphRecordStoreUtilities.DESTINATION + AnalyticConcept.VertexAttribute.RAW), "name2@domain2.com");
    assertEquals(queryResults.get(GraphRecordStoreUtilities.DESTINATION + AnalyticConcept.VertexAttribute.TYPE), "Email");
    assertEquals(queryResults.get(GraphRecordStoreUtilities.DESTINATION + AnalyticConcept.VertexAttribute.COMMENT), "TESTPARAMETERSPLUGIN");
    assertEquals(queryResults.get(GraphRecordStoreUtilities.DESTINATION + TemporalConcept.VertexAttribute.LAST_SEEN), DateTimeFormatter.ISO_INSTANT.format(dtrStartEnd[1]).replace("Z", ".000Z"));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) 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) DefaultPluginInteraction(au.gov.asd.tac.constellation.graph.node.plugins.DefaultPluginInteraction) DateTimeRange(au.gov.asd.tac.constellation.plugins.parameters.types.DateTimeRange) Test(org.testng.annotations.Test)

Example 23 with GraphRecordStore

use of au.gov.asd.tac.constellation.graph.processing.GraphRecordStore in project constellation by constellation-app.

the class TestParametersPluginNGTest method testQueryException3.

/**
 * Test of query method, of class TestParametersPlugin. Tests throwing of
 * warning pluginException
 */
@Test(expectedExceptions = PluginException.class)
public void testQueryException3() throws Exception {
    System.out.println("throw pluginexception3");
    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("Warning");
    try {
        instance.query(recordStore, interaction, result);
    } catch (final PluginException ex) {
        assertEquals(ex.getNotificationLevel(), PluginNotificationLevel.WARNING);
        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 24 with GraphRecordStore

use of au.gov.asd.tac.constellation.graph.processing.GraphRecordStore 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);
}
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 25 with GraphRecordStore

use of au.gov.asd.tac.constellation.graph.processing.GraphRecordStore 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);
}
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)

Aggregations

GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)47 Test (org.testng.annotations.Test)33 ArrayList (java.util.ArrayList)24 RecordStore (au.gov.asd.tac.constellation.graph.processing.RecordStore)19 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)19 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)15 Graph (au.gov.asd.tac.constellation.graph.Graph)12 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)11 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)10 HashSet (java.util.HashSet)10 DefaultPluginInteraction (au.gov.asd.tac.constellation.graph.node.plugins.DefaultPluginInteraction)9 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)8 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)8 HashMap (java.util.HashMap)8 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)7 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)7 IOException (java.io.IOException)5 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)3 TextPluginInteraction (au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction)3 File (java.io.File)3