Search in sources :

Example 1 with PluginParameterType

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

the class DataAccessUserPreferencesNGTest method initWithPane.

@Test
public void initWithPane() {
    final QueryPhasePane tab = mock(QueryPhasePane.class);
    final GlobalParametersPane globalParametersPane = mock(GlobalParametersPane.class);
    when(tab.getGlobalParametersPane()).thenReturn(globalParametersPane);
    final Plugin plugin1 = mock(Plugin.class);
    final DataSourceTitledPane dataSourceTitledPane1 = mock(DataSourceTitledPane.class);
    when(dataSourceTitledPane1.getPlugin()).thenReturn(plugin1);
    when(dataSourceTitledPane1.isQueryEnabled()).thenReturn(true);
    final DataSourceTitledPane dataSourceTitledPane2 = mock(DataSourceTitledPane.class);
    when(dataSourceTitledPane2.isQueryEnabled()).thenReturn(false);
    when(tab.getDataAccessPanes()).thenReturn(List.of(dataSourceTitledPane1, dataSourceTitledPane2));
    final PluginParameterType passwordType = mock(PluginParameterType.class);
    when(passwordType.getId()).thenReturn("password");
    final PluginParameterType stringType = mock(PluginParameterType.class);
    when(stringType.getId()).thenReturn("string");
    // Plugin params will be in global and plugin but because it is in global
    // it should not be included in the plugin section
    final PluginParameter pluginParameter1 = mock(PluginParameter.class);
    when(pluginParameter1.getId()).thenReturn("param1");
    when(pluginParameter1.getStringValue()).thenReturn("value1");
    when(pluginParameter1.getType()).thenReturn(stringType);
    final PluginParameter pluginParameter2 = mock(PluginParameter.class);
    when(pluginParameter2.getId()).thenReturn("param2");
    when(pluginParameter2.getStringValue()).thenReturn("value2");
    when(pluginParameter2.getType()).thenReturn(stringType);
    final PluginParameter pluginParameter3 = mock(PluginParameter.class);
    when(pluginParameter3.getId()).thenReturn("param3");
    when(pluginParameter3.getStringValue()).thenReturn("value3");
    when(pluginParameter3.getType()).thenReturn(stringType);
    // Param 4 is of password type and should not be added
    final PluginParameter pluginParameter4 = mock(PluginParameter.class);
    when(pluginParameter4.getId()).thenReturn("param4");
    when(pluginParameter4.getStringValue()).thenReturn("value4");
    when(pluginParameter4.getType()).thenReturn(passwordType);
    // Set the global parameters
    final PluginParameters globalPluginParameters1 = new PluginParameters();
    globalPluginParameters1.addParameter(pluginParameter1);
    globalPluginParameters1.addParameter(pluginParameter2);
    // Set the parameters for plugin1
    final PluginParameters plugin1Parameters = new PluginParameters();
    plugin1Parameters.addParameter(pluginParameter1);
    plugin1Parameters.addParameter(pluginParameter3);
    plugin1Parameters.addParameter(pluginParameter4);
    when(globalParametersPane.getParams()).thenReturn(globalPluginParameters1);
    when(dataSourceTitledPane1.getParameters()).thenReturn(plugin1Parameters);
    final DataAccessUserPreferences preferences = new DataAccessUserPreferences(tab);
    final DataAccessUserPreferences expectedPreferences = new DataAccessUserPreferences();
    expectedPreferences.setGlobalParameters(Map.of("param1", "value1", "param2", "value2"));
    final Map<String, Map<String, String>> examplePluginParameters = new HashMap<>();
    examplePluginParameters.put(plugin1.getClass().getSimpleName(), Map.of(plugin1.getClass().getSimpleName() + "." + "__is_enabled__", "true", "param3", "value3"));
    expectedPreferences.setPluginParameters(examplePluginParameters);
    assertEquals(preferences, expectedPreferences);
}
Also used : DataSourceTitledPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataSourceTitledPane) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) HashMap(java.util.HashMap) PluginParameterType(au.gov.asd.tac.constellation.plugins.parameters.PluginParameterType) GlobalParametersPane(au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane) 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) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Aggregations

Plugin (au.gov.asd.tac.constellation.plugins.Plugin)1 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)1 PluginParameterType (au.gov.asd.tac.constellation.plugins.parameters.PluginParameterType)1 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)1 DataSourceTitledPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataSourceTitledPane)1 GlobalParametersPane (au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane)1 QueryPhasePane (au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.testng.annotations.Test)1