Search in sources :

Example 6 with DefaultPluginInteraction

use of au.gov.asd.tac.constellation.graph.node.plugins.DefaultPluginInteraction 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 7 with DefaultPluginInteraction

use of au.gov.asd.tac.constellation.graph.node.plugins.DefaultPluginInteraction 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 8 with DefaultPluginInteraction

use of au.gov.asd.tac.constellation.graph.node.plugins.DefaultPluginInteraction in project constellation by constellation-app.

the class TestParametersPluginNGTest method testQueryException2.

/**
 * Test of query method, of class TestParametersPlugin. Tests throwing of
 * info pluginException
 */
@Test(expectedExceptions = PluginException.class)
public void testQueryException2() throws Exception {
    System.out.println("throw pluginexception2");
    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("Info");
    try {
        instance.query(recordStore, interaction, result);
    } catch (final PluginException ex) {
        assertEquals(ex.getNotificationLevel(), PluginNotificationLevel.INFO);
        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 9 with DefaultPluginInteraction

use of au.gov.asd.tac.constellation.graph.node.plugins.DefaultPluginInteraction in project constellation by constellation-app.

the class TestParametersPluginNGTest method testQueryCrash2.

/**
 * Test of query method, of class TestParametersPlugin. Tests throwing
 * runtime exception
 */
@Test(expectedExceptions = RuntimeException.class)
public void testQueryCrash2() throws Exception {
    System.out.println("test query crash2");
    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.CRASH_PARAMETER_ID).setBooleanValue(true);
    instance.query(recordStore, interaction, result);
}
Also used : 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)

Aggregations

DefaultPluginInteraction (au.gov.asd.tac.constellation.graph.node.plugins.DefaultPluginInteraction)9 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)9 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)9 Test (org.testng.annotations.Test)9 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)5 RecordStore (au.gov.asd.tac.constellation.graph.processing.RecordStore)1 DateTimeRange (au.gov.asd.tac.constellation.plugins.parameters.types.DateTimeRange)1 ZonedDateTime (java.time.ZonedDateTime)1