This is an automated email from the ASF dual-hosted git repository.
mattcasters pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 97497c4cfe cleanup some dead code around environment filtering, fixes
#5382 (#8553)
97497c4cfe is described below
commit 97497c4cfe3acf8472470b303b0dbe95fe6b507b
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Thu Sep 24 12:52:07 2026 +0200
cleanup some dead code around environment filtering, fixes #5382 (#8553)
* cleanup some dead code around environment filtering, fixes #5382
* fix remarks
---
.../ROOT/pages/projects/projects-environments.adoc | 1 +
.../apache/hop/projects/config/ProjectsConfig.java | 17 +---
.../config/ProjectsConfigOptionPlugin.java | 40 ++++----
.../apache/hop/projects/gui/ProjectsGuiPlugin.java | 17 ----
.../config/messages/messages_de_DE.properties | 1 -
.../config/messages/messages_en_US.properties | 1 -
.../config/messages/messages_fr_FR.properties | 1 -
.../config/messages/messages_it_IT.properties | 1 -
.../config/messages/messages_pt_BR.properties | 1 -
.../config/messages/messages_zh_CN.properties | 1 -
.../config/ProjectsConfigOptionPluginTest.java | 113 +++++++++++++++++++++
11 files changed, 132 insertions(+), 62 deletions(-)
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/projects/projects-environments.adoc
b/docs/hop-user-manual/modules/ROOT/pages/projects/projects-environments.adoc
index 3f1de23497..a0e001764b 100644
---
a/docs/hop-user-manual/modules/ROOT/pages/projects/projects-environments.adoc
+++
b/docs/hop-user-manual/modules/ROOT/pages/projects/projects-environments.adoc
@@ -218,6 +218,7 @@ Click the project indicator at the bottom left and choose a
recent project from
image:hop-gui/environment/switch-project-list.png[Switch project]
After switching to a project, click the environment indicator (cube icon) next
to the project name and choose an environment from the menu.
+The menu only lists the environments of the active project, plus environments
that are not linked to any project.
All open files will be restored, including their zoom level and other UI
settings.
image:hop-gui/environment/switch-environment-list.png[Switch environment]
diff --git
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/config/ProjectsConfig.java
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/config/ProjectsConfig.java
index 0f0cf6c6bc..1d2d53899f 100644
---
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/config/ProjectsConfig.java
+++
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/config/ProjectsConfig.java
@@ -30,7 +30,7 @@ import org.apache.hop.projects.project.ProjectConfig;
@Getter
@Setter
-@JsonIgnoreProperties(value = {"openingLastProjectAtStartup"})
+@JsonIgnoreProperties(value = {"openingLastProjectAtStartup",
"environmentsForActiveProject"})
public class ProjectsConfig {
public static final String HOP_CONFIG_PROJECTS_CONFIG_KEY = "projectsConfig";
@@ -40,7 +40,6 @@ public class ProjectsConfig {
private boolean projectMandatory;
private boolean environmentMandatory;
- private boolean environmentsForActiveProject;
private boolean sortByNameLastUsedProjects;
private boolean clearingDbCacheWhenSwitching;
private String defaultProject;
@@ -75,7 +74,6 @@ public class ProjectsConfig {
standardParentProject = config.standardParentProject;
standardProjectsFolder = config.standardProjectsFolder;
defaultProjectConfigFile = config.defaultProjectConfigFile;
- environmentsForActiveProject = config.environmentsForActiveProject;
clearingDbCacheWhenSwitching = config.clearingDbCacheWhenSwitching;
sortByNameLastUsedProjects = config.sortByNameLastUsedProjects;
}
@@ -222,19 +220,6 @@ public class ProjectsConfig {
return names;
}
- public List<String> listEnvironmentNamesForProject(String projectName) {
- List<String> names = new ArrayList<>();
- lifecycleEnvironments.forEach(
- env -> {
- if (env.getProjectName().equals(projectName)) {
- names.add(env.getName());
- }
- });
-
- Collections.sort(names);
- return names;
- }
-
public int indexOfEnvironment(String environmentName) {
return lifecycleEnvironments.indexOf(
new LifecycleEnvironment(
diff --git
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/config/ProjectsConfigOptionPlugin.java
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/config/ProjectsConfigOptionPlugin.java
index ba8379970f..e73a161b3b 100644
---
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/config/ProjectsConfigOptionPlugin.java
+++
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/config/ProjectsConfigOptionPlugin.java
@@ -67,8 +67,6 @@ public class ProjectsConfigOptionPlugin
private static final String WIDGET_ID_DEFAULT_ENVIRONMENT =
"10040-default-environment";
private static final String WIDGET_ID_STANDARD_PARENT_PROJECT =
"10050-standard-parent-project";
private static final String WIDGET_ID_STANDARD_PROJECTS_FOLDER =
"10060-standard-projects-folder";
- private static final String
WIDGET_ID_RESTRICT_ENVIRONMENTS_TO_ACTIVE_PROJECT =
- "10070-restrict-environments-to-active-project";
private static final String WIDGET_ID_CLEAR_DB_CACHE =
"10080-clear-db-cache";
private static final String WIDGET_ID_DEFAULT_PROJECT_CONFIG_FILENAME =
"10070-default-project-config-filename";
@@ -163,15 +161,15 @@ public class ProjectsConfigOptionPlugin
description = "The project configuration filename for new projects")
private String defaultProjectConfigFile;
- @GuiWidgetElement(
- id = WIDGET_ID_RESTRICT_ENVIRONMENTS_TO_ACTIVE_PROJECT,
- parentId = ConfigPluginOptionsTab.GUI_WIDGETS_PARENT_ID,
- type = GuiElementType.CHECKBOX,
- variables = false,
- label = "i18n::ProjectConfig.RestrictEnvsToActiveProject.Message")
+ /**
+ * No longer has any effect: since 2.17 the environment menu in the status
bar always lists the
+ * environments of the active project, plus the environments that are not
linked to any project.
+ * The option is still accepted so that existing hop-conf scripts keep
working.
+ */
@CommandLine.Option(
names = {"-eap", "--environments-for-active-project"},
- description = "Restrict environment list to active project")
+ hidden = true,
+ description = "Deprecated, no longer has any effect")
private Boolean environmentsForActiveProject;
@GuiWidgetElement(
@@ -212,7 +210,6 @@ public class ProjectsConfigOptionPlugin
instance.standardParentProject = config.getStandardParentProject();
instance.standardProjectsFolder = config.getStandardProjectsFolder();
instance.defaultProjectConfigFile = config.getDefaultProjectConfigFile();
- instance.environmentsForActiveProject =
config.isEnvironmentsForActiveProject();
instance.sortByNameLastUsedProjects =
config.isSortByNameLastUsedProjects();
instance.clearingDbCacheWhenSwitching =
config.isClearingDbCacheWhenSwitching();
return instance;
@@ -286,14 +283,16 @@ public class ProjectsConfigOptionPlugin
+ "'");
changed = true;
}
+ // Handled, so a script passing only this option does not get the usage
printed, but
+ // nothing to save: there is no setting behind it any more.
+ //
+ boolean handled = false;
if (environmentsForActiveProject != null) {
- config.setEnvironmentsForActiveProject(environmentsForActiveProject);
- if (environmentsForActiveProject) {
- log.logBasic("Only listing environments for the active project");
- } else {
- log.logBasic("Listing all environments, regardless of the active
project");
- }
- changed = true;
+ log.logBasic(
+ "Option --environments-for-active-project is deprecated and has no
effect: the"
+ + " environment menu always lists the environments of the
active project, plus"
+ + " the environments that are not linked to any project");
+ handled = true;
}
if (clearingDbCacheWhenSwitching != null) {
config.setClearingDbCacheWhenSwitching(clearingDbCacheWhenSwitching);
@@ -311,7 +310,7 @@ public class ProjectsConfigOptionPlugin
if (changed) {
ProjectsConfigSingleton.saveConfig();
}
- return changed;
+ return changed || handled;
} catch (Exception e) {
throw new HopException("Error handling projects plugin configuration
options", e);
}
@@ -404,11 +403,6 @@ public class ProjectsConfigOptionPlugin
defaultProjectConfigFile = ((TextVar) control).getText();
ProjectsConfigSingleton.getConfig().setDefaultProjectConfigFile(defaultProjectConfigFile);
break;
- case WIDGET_ID_RESTRICT_ENVIRONMENTS_TO_ACTIVE_PROJECT:
- environmentsForActiveProject = ((Button) control).getSelection();
- ProjectsConfigSingleton.getConfig()
- .setEnvironmentsForActiveProject(environmentsForActiveProject);
- break;
case WIDGET_ID_SORT_BY_NAME_LAST_USED_PROJECTS:
sortByNameLastUsedProjects = ((Button) control).getSelection();
ProjectsConfigSingleton.getConfig()
diff --git
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
index 3a85c5db70..01a0278824 100644
---
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
+++
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
@@ -996,13 +996,6 @@ public class ProjectsGuiPlugin {
HopGui hopGui = HopGui.getInstance();
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
- if (config.isEnvironmentsForActiveProject() &&
StringUtils.isEmpty(projectName)) {
- // list all environments and select the first one if we don't have a
project selected
- List<String> allEnvironments = config.listEnvironmentNames();
- updateEnvironmentToolItem(allEnvironments.getFirst());
- return;
- }
-
ProjectConfig projectConfig = config.findProjectConfig(projectName);
if (projectConfig == null) {
return;
@@ -1681,16 +1674,6 @@ public class ProjectsGuiPlugin {
return names;
}
- /**
- * Called by the environment menu in the toolbar
- *
- * @param log
- * @param metadataProvider
- */
- public List<String> getEnvironmentsList(ILogChannel log,
IHopMetadataProvider metadataProvider) {
- return ProjectsConfigSingleton.getConfig().listEnvironmentNames();
- }
-
// Add a "Navigate to project home" button to the file dialog browser toolbar
//
@GuiToolbarElement(
diff --git
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_de_DE.properties
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_de_DE.properties
index ea0798fc98..436a613d29 100644
---
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_de_DE.properties
+++
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_de_DE.properties
@@ -28,7 +28,6 @@ ProjectConfig.ProjectMandatory.Message=Die Verwendung eines
Projekts ist notwend
ProjectConfig.ProjectNotExists.DefaultProject.Error.Message=Das Projekt
''{0}'' kann nicht verwendet werden, da es nicht existiert!
ProjectConfig.ProjectNotExists.Error.Header=Das Projekt existiert nicht!
ProjectConfig.ProjectNotExists.StandardProject.Error.Message=Das Projekt
''{0}'' kann nicht verwendet werden, da es nicht existiert!
-ProjectConfig.RestrictEnvsToActiveProject.Message=begrenze Umgebungsliste auf
aktives Projekt
ProjectConfig.SavingOption.ErrorDialog.Header=Fehler
ProjectConfig.SavingOption.ErrorDialog.Message=Fehler beim Speichern der Option
ProjectConfig.StdProjectFilename.Message=Der Konfigurationsdateiname f\u00FCr
neue Projekte
diff --git
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_en_US.properties
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_en_US.properties
index 8ddda360c3..0e4d4feb05 100644
---
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_en_US.properties
+++
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_en_US.properties
@@ -27,7 +27,6 @@ ProjectConfig.ProjectMandatory.Message=Use of a project is
mandatory
ProjectConfig.ProjectNotExists.DefaultProject.Error.Message=Project ''{0}''
cannot be set as suggested default project because it does not exist!
ProjectConfig.ProjectNotExists.Error.Header=Project doesn''t exists!
ProjectConfig.ProjectNotExists.StandardProject.Error.Message=Project ''{0}''
cannot be set as suggested parent project because it does not exist!
-ProjectConfig.RestrictEnvsToActiveProject.Message=Restrict environment list to
active project
ProjectConfig.SavingOption.ErrorDialog.Header=Error
ProjectConfig.SavingOption.ErrorDialog.Message=Error saving option
ProjectConfig.SortByNameLastUsedProjects.Message=Sort the last used projects
alphabetically
diff --git
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_fr_FR.properties
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_fr_FR.properties
index 956109fea3..3ddd93ff98 100644
---
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_fr_FR.properties
+++
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_fr_FR.properties
@@ -28,7 +28,6 @@ ProjectConfig.ProjectMandatory.Message=Utiliser un projet est
obligatoire
ProjectConfig.ProjectNotExists.DefaultProject.Error.Message=Le projet ''{0}''
ne peut pas \u00EAtre d\u00E9fini comme projet par d\u00E9faut \u00E0
sugg\u00E9rer car il n''existe pas\u00A0!
ProjectConfig.ProjectNotExists.Error.Header=Le projet n''existe pas\u00A0!
ProjectConfig.ProjectNotExists.StandardProject.Error.Message=Le projet ''{0}''
ne peut pas \u00EAtre d\u00E9fini comme projet par d\u00E9faut \u00E0
sugg\u00E9rer car il n''existe pas\u00A0!
-ProjectConfig.RestrictEnvsToActiveProject.Message=Restreindre la liste
d''environnements au projet actif
ProjectConfig.SavingOption.ErrorDialog.Header=Erreur
ProjectConfig.SavingOption.ErrorDialog.Message=Erreur lors de la sauvegarde de
l''option
ProjectConfig.StdProjectFilename.Message=Le nom du fichier de configuration du
projet pour les nouveau projets
diff --git
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_it_IT.properties
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_it_IT.properties
index f732a81f44..ce91075461 100644
---
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_it_IT.properties
+++
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_it_IT.properties
@@ -27,7 +27,6 @@ ProjectConfig.ProjectMandatory.Message=L''uso di un progetto
\u00E8 obbligatorio
ProjectConfig.ProjectNotExists.DefaultProject.Error.Message=Il progetto
''{0}'' non pu\u00F2 essere suggerito come progetto di default perch\u00E8 non
esiste!
ProjectConfig.ProjectNotExists.Error.Header=Progetto non esiste!
ProjectConfig.ProjectNotExists.StandardProject.Error.Message=Il progetto
''{0}'' non pu\u00F2 essere suggerito come progetto padre perch\u00E8 non
esiste!
-ProjectConfig.RestrictEnvsToActiveProject.Message=Limita la lista degli
ambienti al progetto attivo
ProjectConfig.SavingOption.ErrorDialog.Header=Errore
ProjectConfig.SavingOption.ErrorDialog.Message=Si \u00E8 verificato un errore
salvando l''opzione
ProjectConfig.StdProjectFilename.Message=Nome di default per il file di
configurazione dei progetti
diff --git
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_pt_BR.properties
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_pt_BR.properties
index 60ed8e9ca4..9b9cca21ab 100644
---
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_pt_BR.properties
+++
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_pt_BR.properties
@@ -28,7 +28,6 @@ ProjectConfig.ProjectMandatory.Message=O uso de um projeto
\u00E9 obrigat\u00F3r
ProjectConfig.ProjectNotExists.DefaultProject.Error.Message=Projeto ''{0}''
n\u00E3o pode ser definido como projeto padr\u00E3o sugerido porque n\u00E3o
existe!
ProjectConfig.ProjectNotExists.Error.Header=Projeto n\u00E3o existe!
ProjectConfig.ProjectNotExists.StandardProject.Error.Message=Projeto ''{0}''
n\u00E3o pode ser definido como projeto padr\u00E3o sugerido porque n\u00E3o
existe!
-ProjectConfig.RestrictEnvsToActiveProject.Message=Restringir lista de
ambientes ao projeto ativo
ProjectConfig.SavingOption.ErrorDialog.Header=Erro
ProjectConfig.SavingOption.ErrorDialog.Message=Erro ao salvar op\u00E7\u00E3o
ProjectConfig.StdProjectFilename.Message=O nome do arquivo de
configura\u00E7\u00E3o do projeto para novos projetos
diff --git
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_zh_CN.properties
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_zh_CN.properties
index 5f9c95bca8..86df0892ad 100644
---
a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_zh_CN.properties
+++
b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/config/messages/messages_zh_CN.properties
@@ -28,7 +28,6 @@
ProjectConfig.ProjectMandatory.Message=\u9879\u76EE\u7684\u4F7F\u7528\u662F\u5F3
ProjectConfig.ProjectNotExists.DefaultProject.Error.Message=\u65E0\u6CD5\u5C06\u9879\u76EE
\u201C{0}\u201D \u8BBE\u7F6E\u4E3A\u5EFA\u8BAE\u7684\u9ED8\u8BA4\u9879\u76EE,
\u56E0\u4E3A\u5B83\u4E0D\u5B58\u5728!
ProjectConfig.ProjectNotExists.Error.Header=\u9879\u76EE\u4E0D\u5B58\u5728!
ProjectConfig.ProjectNotExists.StandardProject.Error.Message=\u65E0\u6CD5\u5C06\u9879\u76EE
\u201C{0}\u201D \u8BBE\u7F6E\u4E3A\u5EFA\u8BAE\u7684\u7236\u9879\u76EE,
\u56E0\u4E3A\u5B83\u4E0D\u5B58\u5728!
-ProjectConfig.RestrictEnvsToActiveProject.Message=\u5C06\u73AF\u5883\u5217\u8868\u9650\u5236\u4E3A\u6D3B\u52A8\u9879\u76EE
ProjectConfig.SavingOption.ErrorDialog.Header=\u9519\u8BEF
ProjectConfig.SavingOption.ErrorDialog.Message=\u4FDD\u5B58\u9009\u9879\u65F6\u51FA\u9519
ProjectConfig.StdProjectFilename.Message=\u65B0\u9879\u76EE\u7684\u9879\u76EE\u914D\u7F6E\u6587\u4EF6\u540D
diff --git
a/plugins/misc/projects/src/test/java/org/apache/hop/projects/config/ProjectsConfigOptionPluginTest.java
b/plugins/misc/projects/src/test/java/org/apache/hop/projects/config/ProjectsConfigOptionPluginTest.java
new file mode 100644
index 0000000000..629fb08da3
--- /dev/null
+++
b/plugins/misc/projects/src/test/java/org/apache/hop/projects/config/ProjectsConfigOptionPluginTest.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.projects.config;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.apache.hop.core.config.HopConfig;
+import org.apache.hop.core.json.HopJson;
+import org.apache.hop.core.logging.HopLogStore;
+import org.apache.hop.core.logging.LogChannel;
+import org.apache.hop.core.variables.Variables;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import picocli.CommandLine;
+
+class ProjectsConfigOptionPluginTest {
+
+ @BeforeAll
+ static void beforeAll() {
+ HopLogStore.init();
+ }
+
+ /**
+ * The restrict-environments option has no effect since 2.17 (#5382), but
existing hop-conf
+ * scripts still pass it: it must keep parsing instead of failing with
"Unknown option".
+ */
+ @Test
+ void deprecatedEnvironmentsForActiveProjectOptionIsStillAccepted() {
+ ProjectsConfigOptionPlugin plugin = new ProjectsConfigOptionPlugin();
+ CommandLine cmd = new CommandLine(plugin);
+
+ cmd.parseArgs("-eap");
+ assertEquals(Boolean.TRUE, plugin.getEnvironmentsForActiveProject());
+
+ plugin = new ProjectsConfigOptionPlugin();
+ new
CommandLine(plugin).parseArgs("--environments-for-active-project=false");
+ assertEquals(Boolean.FALSE, plugin.getEnvironmentsForActiveProject());
+ }
+
+ /**
+ * On its own the option still counts as handled, or hop-conf would print
its usage as if the
+ * option were not understood. Nothing is saved for it.
+ */
+ @Test
+ void
deprecatedEnvironmentsForActiveProjectOptionIsHandledWithoutBeingSaved() throws
Exception {
+ HopConfig.setInMemoryMode(true);
+ try {
+ ProjectsConfigOptionPlugin plugin = new ProjectsConfigOptionPlugin();
+ new CommandLine(plugin).parseArgs("-eap");
+
+ assertTrue(plugin.handleOption(LogChannel.GENERAL, null, new
Variables()));
+
+ String saved =
HopJson.newMapper().writeValueAsString(ProjectsConfigSingleton.getConfig());
+ assertFalse(saved.contains("environmentsForActiveProject"), saved);
+ } finally {
+ HopConfig.setInMemoryMode(false);
+ }
+ }
+
+ /** The options after it in the same invocation are still applied. */
+ @Test
+ void deprecatedEnvironmentsForActiveProjectOptionDoesNotStopTheOthers()
throws Exception {
+ HopConfig.setInMemoryMode(true);
+ ProjectsConfig config = ProjectsConfigSingleton.getConfig();
+ boolean clearing = config.isClearingDbCacheWhenSwitching();
+ try {
+ ProjectsConfigOptionPlugin plugin = new ProjectsConfigOptionPlugin();
+ new CommandLine(plugin).parseArgs("-eap", "-cdb=" + !clearing);
+
+ assertTrue(plugin.handleOption(LogChannel.GENERAL, null, new
Variables()));
+ assertEquals(!clearing, config.isClearingDbCacheWhenSwitching());
+ } finally {
+ config.setClearingDbCacheWhenSwitching(clearing);
+ HopConfig.setInMemoryMode(false);
+ }
+ }
+
+ @Test
+ void deprecatedEnvironmentsForActiveProjectOptionIsHiddenFromUsage() {
+ String usage = new CommandLine(new
ProjectsConfigOptionPlugin()).getUsageMessage();
+ assertFalse(usage.contains("environments-for-active-project"), usage);
+ assertTrue(usage.contains("--projects-enabled"), usage);
+ }
+
+ @Test
+ void legacyConfigWithEnvironmentsForActiveProjectStillLoads() throws
Exception {
+ String json =
+
"{\"enabled\":true,\"environmentsForActiveProject\":true,\"defaultProject\":\"default\"}";
+ ProjectsConfig config = HopJson.newMapper().readValue(json,
ProjectsConfig.class);
+ assertTrue(config.isEnabled());
+ assertEquals("default", config.getDefaultProject());
+
+ String written = HopJson.newMapper().writeValueAsString(config);
+ assertFalse(written.contains("environmentsForActiveProject"), written);
+ }
+}