use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class MergeNodesByPrefixNGTest method testUpdateParameters.
/**
* Test of updateParameters method.
*/
@Test
public void testUpdateParameters() {
System.out.println("testUpdateParameters");
final PluginParameters pluginParameters = new PluginParameters();
pluginParameters.addParameter(BooleanParameterType.build(MERGE_TYPE_PARAMETER_ID));
pluginParameters.addParameter(IntegerParameterType.build(THRESHOLD_PARAMETER_ID));
pluginParameters.addParameter(BooleanParameterType.build(MERGER_PARAMETER_ID));
pluginParameters.addParameter(BooleanParameterType.build(LEAD_PARAMETER_ID));
pluginParameters.addParameter(BooleanParameterType.build(SELECTED_PARAMETER_ID));
final Map<String, PluginParameter<?>> parameters = pluginParameters.getParameters();
final MergeNodesByPrefix instance = new MergeNodesByPrefix();
instance.updateParameters(parameters);
assertTrue(parameters.get(MERGE_TYPE_PARAMETER_ID).isEnabled());
assertEquals(parameters.get(THRESHOLD_PARAMETER_ID).getDescription(), "The prefix length to consider");
assertEquals(parameters.get(THRESHOLD_PARAMETER_ID).getIntegerValue(), 9);
assertTrue(parameters.get(THRESHOLD_PARAMETER_ID).isEnabled());
assertTrue(parameters.get(MERGER_PARAMETER_ID).isEnabled());
assertTrue(parameters.get(LEAD_PARAMETER_ID).isEnabled());
assertTrue(parameters.get(SELECTED_PARAMETER_ID).isEnabled());
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class MergeNodesByTypeNGTest method testUpdateParameters.
/**
* Test of updateParameters method, of class MergeNodesByType.
*/
@Test
public void testUpdateParameters() {
System.out.println("testUpdateParameters");
final MergeNodesByType instance = new MergeNodesByType();
final PluginParameters parameters = new PluginParameters();
final PluginParameter<BooleanParameterType.BooleanParameterValue> mergeTypeParameter = BooleanParameterType.build(MERGE_TYPE_PARAMETER_ID);
mergeTypeParameter.setBooleanValue(false);
parameters.addParameter(mergeTypeParameter);
final PluginParameter<IntegerParameterType.IntegerParameterValue> thresholdParameter = IntegerParameterType.build(THRESHOLD_PARAMETER_ID);
thresholdParameter.setIntegerValue(0);
parameters.addParameter(thresholdParameter);
final PluginParameter<BooleanParameterType.BooleanParameterValue> mergeParameter = BooleanParameterType.build(MERGER_PARAMETER_ID);
mergeParameter.setBooleanValue(false);
parameters.addParameter(mergeParameter);
final PluginParameter<BooleanParameterType.BooleanParameterValue> leadParameter = BooleanParameterType.build(LEAD_PARAMETER_ID);
leadParameter.setBooleanValue(false);
parameters.addParameter(leadParameter);
final PluginParameter<BooleanParameterType.BooleanParameterValue> selectedParameter = BooleanParameterType.build(SELECTED_PARAMETER_ID);
selectedParameter.setBooleanValue(false);
parameters.addParameter(selectedParameter);
final Map<String, PluginParameter<?>> parametersMap = parameters.getParameters();
instance.updateParameters(parametersMap);
assertEquals(parametersMap.size(), 5);
assertTrue(parametersMap.get(MERGE_TYPE_PARAMETER_ID).isEnabled());
assertFalse(parametersMap.get(THRESHOLD_PARAMETER_ID).isEnabled());
assertTrue(parametersMap.get(MERGER_PARAMETER_ID).isEnabled());
assertFalse(parametersMap.get(LEAD_PARAMETER_ID).isEnabled());
assertTrue(parametersMap.get(SELECTED_PARAMETER_ID).isEnabled());
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class MergeNodesPluginNGTest method editMergeError.
@Test(expectedExceptions = PluginException.class)
public void editMergeError() throws InterruptedException, PluginException, MergeNodeType.MergeException {
final GraphWriteMethods graph = mock(GraphWriteMethods.class);
final PluginInteraction interaction = mock(PluginInteraction.class);
final PluginParameters parameters = mock(PluginParameters.class);
final PluginParameter mergeTypeParameter = mock(PluginParameter.class);
final PluginParameter thresholdParameter = mock(PluginParameter.class);
final PluginParameter mergerParameter = mock(PluginParameter.class);
final PluginParameter leadParameter = mock(PluginParameter.class);
final PluginParameter selectedParameter = mock(PluginParameter.class);
final Map<String, PluginParameter<?>> pluginParameters = Map.of("MergeNodesPlugin.merge_type", mergeTypeParameter, "MergeNodesPlugin.threshold", thresholdParameter, "MergeNodesPlugin.merger", mergerParameter, "MergeNodesPlugin.lead", leadParameter, "MergeNodesPlugin.selected", selectedParameter);
when(parameters.getParameters()).thenReturn(pluginParameters);
when(mergeTypeParameter.getStringValue()).thenReturn(TestMergeType.NAME);
when(thresholdParameter.getIntegerValue()).thenReturn(TestMergeType.MERGE_EXCEPTION_THRESHOLD);
when(mergerParameter.getStringValue()).thenReturn("Retain lead vertex attributes if present");
when(leadParameter.getStringValue()).thenReturn("Longest Value");
when(selectedParameter.getBooleanValue()).thenReturn(true);
mergeNodesPlugin.edit(graph, interaction, parameters);
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class MergeNodesPluginNGTest method editNoMergeOptionSelected.
@Test(expectedExceptions = PluginException.class)
public void editNoMergeOptionSelected() throws InterruptedException, PluginException {
final GraphWriteMethods graph = mock(GraphWriteMethods.class);
final PluginInteraction interaction = mock(PluginInteraction.class);
final PluginParameters parameters = mock(PluginParameters.class);
final PluginParameter pluginParameter = mock(PluginParameter.class);
final Map<String, PluginParameter<?>> pluginParameters = Map.of("MergeNodesPlugin.merge_type", pluginParameter);
when(parameters.getParameters()).thenReturn(pluginParameters);
when(pluginParameter.getStringValue()).thenReturn(null);
mergeNodesPlugin.edit(graph, interaction, parameters);
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameters in project constellation by constellation-app.
the class MergeNodesPluginNGTest method createParameters.
@Test
public void createParameters() {
final PluginParameters actual = mergeNodesPlugin.createParameters();
final Map<String, PluginParameter<?>> parameters = actual.getParameters();
assertEquals(parameters.keySet(), Set.of("MergeNodesPlugin.merge_type", "MergeNodesPlugin.threshold", "MergeNodesPlugin.merger", "MergeNodesPlugin.lead", "MergeNodesPlugin.selected"));
final PluginParameter<SingleChoiceParameterValue> mergeTypeParameter = (PluginParameter<SingleChoiceParameterValue>) parameters.get("MergeNodesPlugin.merge_type");
assertEquals(mergeTypeParameter.getName(), "Merge By");
assertEquals(mergeTypeParameter.getDescription(), "Nodes will be merged based on this");
assertEquals(mergeTypeParameter.getParameterValue().getOptions(), List.of(TestMergeType.NAME, "Geospatial Distance", "Identifier Prefix Length", "Identifier Suffix Length", "Supported Type"));
assertEquals(mergeTypeParameter.getProperty("choices").getClass(), Object.class);
final PluginParameter<IntegerParameterValue> thresholdParameter = (PluginParameter<IntegerParameterValue>) parameters.get("MergeNodesPlugin.threshold");
assertEquals(thresholdParameter.getName(), "Threshold");
assertEquals(thresholdParameter.getDescription(), "The maximum nodes to merge");
assertFalse(thresholdParameter.isEnabled());
final PluginParameter<SingleChoiceParameterValue> mergingRuleParameter = (PluginParameter<SingleChoiceParameterValue>) parameters.get("MergeNodesPlugin.merger");
assertEquals(mergingRuleParameter.getName(), "Merging Rule");
assertEquals(mergingRuleParameter.getDescription(), "The rule deciding how attributes are merged");
assertEquals(mergingRuleParameter.getParameterValue().getOptions(), List.of("Retain lead vertex attributes if present", "Retain lead vertex attributes always", "Copy merged vertex attributes if present", "Copy merged vertex attributes always"));
assertEquals(mergingRuleParameter.getProperty("choices").getClass(), Object.class);
assertEquals(mergingRuleParameter.getParameterValue().getChoice(), "Retain lead vertex attributes if present");
assertFalse(mergingRuleParameter.isEnabled());
final PluginParameter<SingleChoiceParameterValue> leadNodeParameter = (PluginParameter<SingleChoiceParameterValue>) parameters.get("MergeNodesPlugin.lead");
assertEquals(leadNodeParameter.getName(), "Lead Node");
assertEquals(leadNodeParameter.getDescription(), "The rule deciding how to choose the lead node");
assertEquals(leadNodeParameter.getParameterValue().getOptions(), List.of("Longest Value", "Shortest Value", "Ask Me"));
assertEquals(leadNodeParameter.getProperty("choices").getClass(), Object.class);
assertEquals(leadNodeParameter.getParameterValue().getChoice(), "Longest Value");
assertFalse(leadNodeParameter.isEnabled());
final PluginParameter<BooleanParameterValue> selectedOnlyParameter = (PluginParameter<BooleanParameterValue>) parameters.get("MergeNodesPlugin.selected");
assertEquals(selectedOnlyParameter.getName(), "Selected Only");
assertEquals(selectedOnlyParameter.getDescription(), "Merge Only Selected Nodes");
assertTrue(selectedOnlyParameter.getBooleanValue());
assertFalse(selectedOnlyParameter.isEnabled());
final Map<String, PluginParameterController> controllers = actual.getControllers();
assertEquals(controllers.keySet(), Set.of("MergeNodesPlugin.merge_type"));
}
Aggregations