Search in sources :

Example 76 with PluginParameters

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.

the class RemoveUnusedAttributesPluginNGTest method testAllNullAttributes.

/**
 * Test of edit method, of class RemoveUnusedAttributesPlugin.
 *
 * @throws java.lang.Exception
 */
@Test
public void testAllNullAttributes() throws Exception {
    PluginInteraction interaction = null;
    PluginParameters parameters = null;
    RemoveUnusedAttributesPlugin instance = new RemoveUnusedAttributesPlugin();
    instance.edit(graph, interaction, parameters);
    assertEquals(graph.getAttribute(GraphElementType.VERTEX, "test1"), GraphConstants.NOT_FOUND);
    assertEquals(graph.getAttribute(GraphElementType.VERTEX, "test2"), GraphConstants.NOT_FOUND);
    assertEquals(graph.getAttribute(GraphElementType.VERTEX, "test3"), GraphConstants.NOT_FOUND);
    assertEquals(graph.getAttribute(GraphElementType.TRANSACTION, "test4"), GraphConstants.NOT_FOUND);
    assertEquals(graph.getAttribute(GraphElementType.TRANSACTION, "test5"), GraphConstants.NOT_FOUND);
    assertEquals(graph.getAttribute(GraphElementType.TRANSACTION, "test6"), GraphConstants.NOT_FOUND);
}
Also used : PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Test(org.testng.annotations.Test)

Example 77 with PluginParameters

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.

the class RemoveUnusedAttributesPluginNGTest method testSomeNullKeyAttributes.

@Test
public void testSomeNullKeyAttributes() throws Exception {
    // adding values to some attributes
    graph.setPrimaryKey(GraphElementType.VERTEX, vertexAttribute1);
    graph.setStringValue(vertexAttribute2, vertex2, "some words");
    graph.setStringValue(vertexAttribute3, vertex1, "some words");
    graph.setStringValue(transactionAttribute1, transaction1, "some words");
    PluginInteraction interaction = null;
    PluginParameters parameters = null;
    RemoveUnusedAttributesPlugin instance = new RemoveUnusedAttributesPlugin();
    instance.edit(graph, interaction, parameters);
    assertNotEquals(graph.getAttribute(GraphElementType.VERTEX, "test1"), GraphConstants.NOT_FOUND);
    assertNotEquals(graph.getAttribute(GraphElementType.VERTEX, "test2"), GraphConstants.NOT_FOUND);
    assertNotEquals(graph.getAttribute(GraphElementType.VERTEX, "test3"), GraphConstants.NOT_FOUND);
    assertNotEquals(graph.getAttribute(GraphElementType.TRANSACTION, "test4"), GraphConstants.NOT_FOUND);
    assertEquals(graph.getAttribute(GraphElementType.TRANSACTION, "test5"), GraphConstants.NOT_FOUND);
    assertEquals(graph.getAttribute(GraphElementType.TRANSACTION, "test6"), GraphConstants.NOT_FOUND);
}
Also used : PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Test(org.testng.annotations.Test)

Example 78 with PluginParameters

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.

the class TestParametersPluginNGTest method testQueryException5.

/**
 * Test of query method, of class TestParametersPlugin. Tests throwing of
 * fatal pluginException
 */
@Test(expectedExceptions = PluginException.class)
public void testQueryException5() throws Exception {
    System.out.println("throw pluginexception5");
    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("Fatal");
    try {
        instance.query(recordStore, interaction, result);
    } catch (final PluginException ex) {
        assertEquals(ex.getNotificationLevel(), PluginNotificationLevel.FATAL);
        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 79 with PluginParameters

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.

the class TestParametersPluginNGTest method testQueryException6.

/**
 * Test of query method, of class TestParametersPlugin. Tests not throwing
 * of pluginException
 */
@Test
public void testQueryException6() throws Exception {
    System.out.println("throw pluginexception6");
    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");
    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)

Example 80 with PluginParameters

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.

the class TestParametersPluginNGTest method testGraphElementType1.

/**
 * Test of query method, of class TestParametersPlugin. Tests throwing
 * runtime exception
 */
@Test
public void testGraphElementType1() throws Exception {
    System.out.println("test graph element type1");
    final TestParametersPlugin instance = new TestParametersPlugin();
    final PluginParameters result = instance.createParameters();
    // Set plugin query name here before execution
    result.getParameters().get(CoreGlobalParameters.QUERY_NAME_PARAMETER_ID).setStringValue("TESTPARAMETERSPLUGIN");
    // Set plugin parameters here before execution
    final GraphElementTypeParameterValue graphElementType = new GraphElementTypeParameterValue();
    assertTrue(graphElementType.set(GraphElementType.META));
    // return false when setting same attribute
    assertFalse(graphElementType.set(GraphElementType.META));
    assertTrue(graphElementType.setObjectValue(GraphElementType.VERTEX));
    // return false when setting same attribute
    assertFalse(graphElementType.setObjectValue(GraphElementType.VERTEX));
    for (final GraphElementType elementType : GraphElementType.values()) {
        graphElementType.setObjectValue(elementType);
        result.getParameters().get(TestParametersPlugin.ELEMENT_TYPE_PARAMETER_ID).setObjectValue(graphElementType);
        // Ensure it is still selected as the correct value
        assertEquals(SingleChoiceParameterType.getChoice((PluginParameter<SingleChoiceParameterType.SingleChoiceParameterValue>) result.getParameters().get(TestParametersPlugin.ELEMENT_TYPE_PARAMETER_ID)), elementType.getShortLabel());
    }
}
Also used : SingleChoiceParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType) GraphElementTypeParameterValue(au.gov.asd.tac.constellation.views.dataaccess.plugins.experimental.TestParametersPlugin.GraphElementTypeParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) 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