Search in sources :

Example 31 with PluginParameter

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

the class BooleanParameterTypeNGTest method testBuild_String_BooleanParameterTypeBooleanParameterValue.

/**
 * Test of build method, of class BooleanParameterType.
 */
@Test
public void testBuild_String_BooleanParameterTypeBooleanParameterValue() {
    System.out.println("build_string_parametertype");
    String id = "booleanParameter";
    BooleanParameterValue parameterValue = new BooleanParameterValue();
    PluginParameter result = BooleanParameterType.build(id, parameterValue);
    assertEquals(result.getId(), id);
    assertTrue(result.getType() instanceof BooleanParameterType);
    assertEquals(result.getParameterValue(), parameterValue);
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 32 with PluginParameter

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

the class IntegerParameterTypeNGTest method testValidateString.

/**
 * Test of validateString method, of class IntegerParameterType.
 */
@Test
public void testValidateString() {
    System.out.println("validateString");
    String id = "validate string";
    IntegerParameterType instance = new IntegerParameterType();
    PluginParameter<IntegerParameterType.IntegerParameterValue> parameter = new PluginParameter<>(new IntegerParameterValue(), INSTANCE, id);
    IntegerParameterType.setMaximum(parameter, 5);
    IntegerParameterType.setMinimum(parameter, 0);
    // test valid integer in min-max range
    // should return null
    String passingValue = "2";
    String result = instance.validateString(parameter, passingValue);
    assertEquals(result, null);
    // test invalid integer under min range
    // should return value too small
    passingValue = "-1";
    result = instance.validateString(parameter, passingValue);
    assertEquals(result, "Value too small");
    // test invalid integer over max range
    // should return value too small
    passingValue = "6";
    result = instance.validateString(parameter, passingValue);
    assertEquals(result, "Value too large");
    // test invalid integer
    // should return Not a valid integer
    passingValue = "This is a Test";
    result = instance.validateString(parameter, passingValue);
    assertEquals(result, "Not a valid integer");
    // test a 0
    // should return null
    passingValue = "0";
    result = instance.validateString(parameter, passingValue);
    assertEquals(result, null);
}
Also used : IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 33 with PluginParameter

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

the class PasswordParameterTypeNGTest method testBuild_String.

/**
 * Test of build method, of class PasswordParameterType.
 */
@Test
public void testBuild_String() {
    System.out.println("build");
    String id = "password parameter";
    PluginParameter result = PasswordParameterType.build(id);
    PasswordParameterValue expResult = new PasswordParameterValue();
    System.out.println(expResult.toString());
    assertEquals(result.getId(), id);
    assertTrue(result.getType() instanceof PasswordParameterType);
    assertEquals(result.getParameterValue(), expResult);
}
Also used : PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 34 with PluginParameter

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

the class StringParameterTypeNGTest method testGetLines.

/**
 * Test of getLines method, of class StringParameterType.
 */
@Test
public void testGetLines() {
    System.out.println("getLines");
    PluginParameter instance = StringParameterType.build("stringParameter");
    // check the expected result and result equal when postivie integers
    Integer expResult = 5;
    instance.setProperty(StringParameterType.LINES, expResult);
    Integer result = StringParameterType.getLines(instance);
    assertEquals(result, expResult);
    // check the expected result and result equal when 0
    expResult = 0;
    instance.setProperty(StringParameterType.LINES, expResult);
    result = StringParameterType.getLines(instance);
    assertEquals(result, expResult);
    // check the expected result and result equal when negative integers
    expResult = -1;
    instance.setProperty(StringParameterType.LINES, expResult);
    result = StringParameterType.getLines(instance);
    assertEquals(result, expResult);
    // check the expected result and result equal when null
    expResult = null;
    instance.setProperty(StringParameterType.LINES, expResult);
    result = StringParameterType.getLines(instance);
    assertEquals(result, expResult);
}
Also used : PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 35 with PluginParameter

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

the class StringParameterTypeNGTest method testBuild_String_StringParameterValue.

/**
 * Test of build method, of class StringParameterType.
 */
@Test
public void testBuild_String_StringParameterValue() {
    System.out.println("build_string_parametertype");
    String id = "stringParameter";
    StringParameterValue parameterValue = new StringParameterValue();
    PluginParameter result = StringParameterType.build(id, parameterValue);
    assertEquals(result.getId(), id);
    assertTrue(result.getType() instanceof StringParameterType);
    assertEquals(result.getParameterValue(), parameterValue);
}
Also used : PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Aggregations

PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)93 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)53 Test (org.testng.annotations.Test)52 ArrayList (java.util.ArrayList)36 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)25 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)21 Map (java.util.Map)16 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)15 IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)13 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)12 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)11 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)11 Graph (au.gov.asd.tac.constellation.graph.Graph)10 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)10 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)10 HashMap (java.util.HashMap)10 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)9 List (java.util.List)9 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)8 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)8