use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.
the class SplitNodesPluginNGTest method testUpdateParameters.
/**
* Test of createParameters method, of class SplitNodesPlugin.
*/
@Test
public void testUpdateParameters() {
final SplitNodesPlugin instance = new SplitNodesPlugin();
final PluginParameters params = instance.createParameters();
final PluginParameter<SingleChoiceParameterValue> transactionTypeParam = (PluginParameter<SingleChoiceParameterValue>) params.getParameters().get(SplitNodesPlugin.TRANSACTION_TYPE_PARAMETER_ID);
assertTrue(SingleChoiceParameterType.getOptions(transactionTypeParam).isEmpty());
final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
instance.updateParameters(new DualGraph(schema, graph), params);
// 9 is the number of transaction types in the analytic schema
assertEquals(SingleChoiceParameterType.getOptions(transactionTypeParam).size(), 9);
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.
the class GlobalParametersPaneNGTest method getParamLabels.
@Test
public void getParamLabels() {
final PluginParameter param1 = mock(PluginParameter.class);
final PluginParameter param2 = mock(PluginParameter.class);
when(parameters.getParameters()).thenReturn(Map.of("hello", param1, "world", param2));
assertEquals(globalParametersPane.getParamLabels(), Set.of("hello", "world"));
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.
the class SelectTopNNGTest method testEditWithTopTwoLocationsContainingDifferentTransactionTypes.
@Test
public void testEditWithTopTwoLocationsContainingDifferentTransactionTypes() throws Exception {
final StoreGraph graph = new StoreGraph(SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema());
final int vertexLabelAttr = VisualConcept.VertexAttribute.LABEL.ensure(graph);
final int vertexSelectedAttr = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
final int vertexTypeAttr = AnalyticConcept.VertexAttribute.TYPE.ensure(graph);
final int transactionTypeAttr = AnalyticConcept.TransactionAttribute.TYPE.ensure(graph);
final int sourceVxId = graph.addVertex();
graph.setStringValue(vertexLabelAttr, sourceVxId, "source");
graph.setBooleanValue(vertexSelectedAttr, sourceVxId, true);
// buildId the graph
for (int i = 0; i < 2; i++) {
final int desintationVxId = graph.addVertex();
graph.setStringValue(vertexLabelAttr, desintationVxId, String.format("destination %s", i));
for (int j = i; j < 10; j++) {
int txId = graph.addTransaction(sourceVxId, desintationVxId, true);
graph.setObjectValue(transactionTypeAttr, txId, AnalyticConcept.TransactionType.COMMUNICATION.getName());
}
}
for (int i = 3; i < 10; i++) {
final int desintationVxId = graph.addVertex();
graph.setStringValue(vertexLabelAttr, desintationVxId, String.format("destination %s", i));
for (int j = i; j < 10; j++) {
int txId = graph.addTransaction(sourceVxId, desintationVxId, true);
graph.setObjectValue(transactionTypeAttr, txId, AnalyticConcept.TransactionType.NETWORK);
}
}
final PluginInteraction interaction = new TextPluginInteraction();
final SelectTopNPlugin instance = new SelectTopNPlugin();
final PluginParameters parameters = instance.createParameters();
parameters.getParameters().get(SelectTopNPlugin.MODE_PARAMETER_ID).setStringValue(SelectTopNPlugin.TRANSACTION);
parameters.getParameters().get(SelectTopNPlugin.TYPE_CATEGORY_PARAMETER_ID).setStringValue(AnalyticConcept.TransactionType.COMMUNICATION.getName());
// TYPE_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> subTypeParameter = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(SelectTopNPlugin.TYPE_PARAMETER_ID);
final List<String> arrayList = new ArrayList<>();
arrayList.add(AnalyticConcept.TransactionType.COMMUNICATION.getName());
MultiChoiceParameterType.setChoices(subTypeParameter, arrayList);
parameters.getParameters().get(SelectTopNPlugin.LIMIT_PARAMETER_ID).setIntegerValue(2);
instance.edit(graph, interaction, parameters);
assertTrue(graph.getBooleanValue(vertexSelectedAttr, sourceVxId));
assertTrue(graph.getBooleanValue(vertexSelectedAttr, sourceVxId + 1));
assertTrue(graph.getBooleanValue(vertexSelectedAttr, sourceVxId + 2));
for (int i = 3; i < 10; i++) {
assertFalse(graph.getBooleanValue(vertexSelectedAttr, sourceVxId + i));
}
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.
the class DataAccessUtilitiesNGTest method testsaveDataAccessState.
@Test
public void testsaveDataAccessState() throws Exception {
System.out.println("testsaveDataAccessState");
// mock Tab
final Tab tab = mock(Tab.class);
ObservableList<Tab> observableArrayList = FXCollections.observableArrayList(tab);
// mock TabPane
final TabPane tabPane = mock(TabPane.class);
when(tabPane.getTabs()).thenReturn(observableArrayList);
final ScrollPane scrollPane = mock(ScrollPane.class);
final QueryPhasePane queryPhasePane = mock(QueryPhasePane.class);
final GlobalParametersPane globalParametersPane = mock(GlobalParametersPane.class);
final PluginParameters pluginParameters = mock(PluginParameters.class);
final PluginParameter pluginParameter = mock(PluginParameter.class);
when(tab.getContent()).thenReturn(scrollPane);
when(scrollPane.getContent()).thenReturn(queryPhasePane);
when(queryPhasePane.getGlobalParametersPane()).thenReturn(globalParametersPane);
when(globalParametersPane.getParams()).thenReturn(pluginParameters);
when(pluginParameter.getStringValue()).thenReturn("something");
final String someKey = "someKey";
final Map<String, PluginParameter<?>> map = Map.of(someKey, pluginParameter);
when(pluginParameters.getParameters()).thenReturn(map);
// mock graph
final Graph graph = mock(Graph.class);
final WritableGraph wGraph = mock(WritableGraph.class);
when(graph.getWritableGraph("Update Data Access State", true)).thenReturn(wGraph);
DataAccessUtilities.saveDataAccessState(tabPane, graph);
final DataAccessState expectedTab = new DataAccessState();
expectedTab.newTab();
expectedTab.add("someKey", "something");
assertEquals(expectedTab.getState().size(), 1);
verify(wGraph).setObjectValue(0, 0, expectedTab);
}
use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameter in project constellation by constellation-app.
the class CompareGraphPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters parameters = new PluginParameters();
final PluginParameter<SingleChoiceParameterValue> originalGraph = SingleChoiceParameterType.build(ORIGINAL_GRAPH_PARAMETER_ID);
originalGraph.setName("Original Graph");
originalGraph.setDescription("The graph used as the starting point for the comparison");
parameters.addParameter(originalGraph);
// Controller listens for value change so that the compare graph cannot be compared against itself
parameters.addController(ORIGINAL_GRAPH_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> params, ParameterChange change) -> {
// When value has changed, remove choice from the comparison graph dialog
if (change == ParameterChange.VALUE) {
final String originalGraphName = params.get(ORIGINAL_GRAPH_PARAMETER_ID).getStringValue();
if (originalGraphName != null) {
final List<String> graphNames = new ArrayList<>();
final Map<String, Graph> allGraphs = GraphNode.getAllGraphs();
if (allGraphs != null) {
for (final String graphId : allGraphs.keySet()) {
graphNames.add(GraphNode.getGraphNode(graphId).getDisplayName());
}
}
// remove the current original graph selection from the list of graphs allowed to compare with
graphNames.remove(originalGraphName);
// sort drop down list
graphNames.sort(String::compareTo);
// COMPARE_GRAPH_PARAMETER_ID will always be of type SingleChoiceParameterValue
@SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> compareParamter = (PluginParameter<SingleChoiceParameterValue>) params.get(COMPARE_GRAPH_PARAMETER_ID);
SingleChoiceParameterType.setOptions(compareParamter, graphNames);
}
}
});
final PluginParameter<SingleChoiceParameterValue> compareGraph = SingleChoiceParameterType.build(COMPARE_GRAPH_PARAMETER_ID);
compareGraph.setName("Compare With Graph");
compareGraph.setDescription("The graph used to compare against the original graph");
parameters.addParameter(compareGraph);
final PluginParameter<MultiChoiceParameterValue> ignoreVertexAttributes = MultiChoiceParameterType.build(IGNORE_VERTEX_ATTRIBUTES_PARAMETER_ID);
ignoreVertexAttributes.setName("Ignore Node Attributes");
ignoreVertexAttributes.setDescription("Ignore these attributes when comparing nodes");
parameters.addParameter(ignoreVertexAttributes);
final PluginParameter<MultiChoiceParameterValue> ignoreTransactionAttributes = MultiChoiceParameterType.build(IGNORE_TRANSACTION_ATTRIBUTES_PARAMETER_ID);
ignoreTransactionAttributes.setName("Ignore Transaction Attributes");
ignoreTransactionAttributes.setDescription("Ignore these attributes when comparing transactions");
parameters.addParameter(ignoreTransactionAttributes);
final PluginParameter<ColorParameterValue> addedColour = ColorParameterType.build(ADDED_COLOUR_PARAMETER_ID);
addedColour.setName("Added Color");
addedColour.setDescription("The colour to indicate a node/transaction addition");
addedColour.setColorValue(ConstellationColor.GREEN);
parameters.addParameter(addedColour);
final PluginParameter<ColorParameterValue> removedColour = ColorParameterType.build(REMOVED_COLOUR_PARAMETER_ID);
removedColour.setName("Removed Color");
removedColour.setDescription("The colour to indicate a node/transaction removal");
removedColour.setColorValue(ConstellationColor.RED);
parameters.addParameter(removedColour);
final PluginParameter<ColorParameterValue> changedColour = ColorParameterType.build(CHANGED_COLOUR_PARAMETER_ID);
changedColour.setName("Changed Color");
changedColour.setDescription("The colour to indicate a node/transaction change");
changedColour.setColorValue(ConstellationColor.YELLOW);
parameters.addParameter(changedColour);
final PluginParameter<ColorParameterValue> unchangedColour = ColorParameterType.build(UNCHANGED_COLOUR_PARAMETER_ID);
unchangedColour.setName("Unchanged Color");
unchangedColour.setDescription("The colour to indicate no node/transaction change");
unchangedColour.setColorValue(ConstellationColor.GREY);
parameters.addParameter(unchangedColour);
return parameters;
}
Aggregations