Search in sources :

Example 71 with PluginParameter

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);
}
Also used : Schema(au.gov.asd.tac.constellation.graph.schema.Schema) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 72 with PluginParameter

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"));
}
Also used : PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Test(org.testng.annotations.Test)

Example 73 with PluginParameter

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));
    }
}
Also used : MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 74 with PluginParameter

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);
}
Also used : TabPane(javafx.scene.control.TabPane) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) GlobalParametersPane(au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) Tab(javafx.scene.control.Tab) DataAccessState(au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState) ScrollPane(javafx.scene.control.ScrollPane) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 75 with PluginParameter

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;
}
Also used : ParameterChange(au.gov.asd.tac.constellation.plugins.parameters.ParameterChange) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) ColorParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) HashMap(java.util.HashMap) Map(java.util.Map) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

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