This is an automated email from the ASF dual-hosted git repository.
bamaer 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 3a5ae47b1f Issue #2865 : Keep PROJECT_HOME when importing Kettle into
a folder (#8313)
3a5ae47b1f is described below
commit 3a5ae47b1f0a476bdaa116d4102a708878982700
Author: Matt Casters <[email protected]>
AuthorDate: Fri Sep 11 19:32:55 2026 +0200
Issue #2865 : Keep PROJECT_HOME when importing Kettle into a folder (#8313)
* Issue #2865 : Keep PROJECT_HOME when importing Kettle into a folder
Folder import created "Hop Import Project" and applied it to the live GUI
variable space, so PROJECT_HOME pointed at the destination while the
toolbar still showed the original project. Register the import project
without activating it, write connections through a local metadata
provider, and refresh metadata/explorer after import.
* Issue #2865 : Address review on import GUI refresh and empty config
filename
Drop notifyGuiAfterImport: MetadataChanged and ProjectUpdated only refresh
the active project, so they do nothing for folder import. Treat an empty
defaultProjectConfigFile like ProjectConfig already does, and pin that
value in the test fixture so it does not depend on the host hop-config.
---
.../xp/HopImportCreateProjectIfNotExists.java | 58 +++++---
.../hop/projects/xp/HopImportDbConnections.java | 52 ++++---
.../xp/HopImportCreateProjectIfNotExistsTest.java | 155 +++++++++++++++++++++
.../projects/xp/HopImportDbConnectionsTest.java | 137 ++++++++++++++++++
4 files changed, 362 insertions(+), 40 deletions(-)
diff --git
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopImportCreateProjectIfNotExists.java
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopImportCreateProjectIfNotExists.java
index b7294c30da..5e2f9a2721 100644
---
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopImportCreateProjectIfNotExists.java
+++
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopImportCreateProjectIfNotExists.java
@@ -17,7 +17,8 @@
package org.apache.hop.projects.xp;
-import java.util.Collections;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.vfs2.FileObject;
import org.apache.hop.core.config.HopConfig;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.extension.ExtensionPoint;
@@ -25,11 +26,11 @@ import org.apache.hop.core.extension.IExtensionPoint;
import org.apache.hop.core.logging.ILogChannel;
import org.apache.hop.core.util.StringUtil;
import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.core.vfs.HopVfs;
import org.apache.hop.projects.config.ProjectsConfig;
import org.apache.hop.projects.config.ProjectsConfigSingleton;
import org.apache.hop.projects.project.Project;
import org.apache.hop.projects.project.ProjectConfig;
-import org.apache.hop.ui.hopgui.HopGui;
@ExtensionPoint(
id = "HopImportCreateProject",
@@ -37,29 +38,52 @@ import org.apache.hop.ui.hopgui.HopGui;
extensionPointId = "HopImportCreateProject")
public class HopImportCreateProjectIfNotExists implements
IExtensionPoint<String> {
+ static final String IMPORT_PROJECT_NAME = "Hop Import Project";
+
@Override
public void callExtensionPoint(ILogChannel iLogChannel, IVariables
variables, String projectPath)
throws HopException {
+ createImportProject(variables, projectPath, true);
+ }
- String projectName = "Hop Import Project";
- String envName = "Hop Import Environment";
+ /**
+ * Register a project at {@code projectPath} without applying it to {@code
variables}.
+ *
+ * <p>Folder import must not overwrite the GUI {@code PROJECT_HOME} (issue
#2865). The new project
+ * is registered, not activated.
+ *
+ * @param persistHopConfig when false, skip writing hop-config.json (tests)
+ * @return the registered project config, or {@code null} when {@code
projectPath} is empty
+ */
+ static ProjectConfig createImportProject(
+ IVariables variables, String projectPath, boolean persistHopConfig)
throws HopException {
+ if (StringUtil.isEmpty(projectPath)) {
+ return null;
+ }
- HopGui hopGui = HopGui.getInstance();
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
+ String defaultProjectConfigFilename =
variables.resolve(config.getDefaultProjectConfigFile());
+ if (StringUtils.isEmpty(defaultProjectConfigFilename)) {
+ defaultProjectConfigFilename =
ProjectsConfig.DEFAULT_PROJECT_CONFIG_FILENAME;
+ }
+ ProjectConfig projectConfig =
+ new ProjectConfig(IMPORT_PROJECT_NAME, projectPath,
defaultProjectConfigFilename);
+ Project project = new Project();
+ project.getDescribedVariables().clear();
+
+ try (FileObject projectHome = HopVfs.getFileObject(projectPath)) {
+ FileObject configFile =
projectHome.resolveFile(defaultProjectConfigFilename);
+ project.setConfigFilename(configFile.getName().getURI());
+ } catch (Exception e) {
+ throw new HopException(
+ "Error resolving project configuration file for import folder '" +
projectPath + "'", e);
+ }
- // create new project
- if (!StringUtil.isEmpty(projectPath)) {
- String defaultProjectConfigFilename =
variables.resolve(config.getDefaultProjectConfigFile());
- ProjectConfig projectConfig =
- new ProjectConfig(projectName, projectPath,
defaultProjectConfigFilename);
- Project project = new Project();
- project.getDescribedVariables().clear();
- project.modifyVariables(variables, projectConfig,
Collections.emptyList(), null);
- project.setConfigFilename(
- projectPath + System.getProperty("file.separator") +
"project-config.json");
- config.addProjectConfig(projectConfig);
+ config.addProjectConfig(projectConfig);
+ if (persistHopConfig) {
HopConfig.getInstance().saveToFile();
- project.saveToFile();
}
+ project.saveToFile();
+ return projectConfig;
}
}
diff --git
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopImportDbConnections.java
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopImportDbConnections.java
index 9e282cc57e..dd4ff597ea 100644
---
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopImportDbConnections.java
+++
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopImportDbConnections.java
@@ -17,29 +17,29 @@
package org.apache.hop.projects.xp;
-import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.apache.commons.vfs2.FileObject;
import org.apache.hop.core.database.DatabaseMeta;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.extension.ExtensionPoint;
import org.apache.hop.core.extension.IExtensionPoint;
import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.logging.LogChannel;
import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.core.variables.Variables;
import org.apache.hop.core.vfs.HopVfs;
import org.apache.hop.metadata.api.IHopMetadataProvider;
import org.apache.hop.metadata.api.IHopMetadataSerializer;
+import org.apache.hop.metadata.util.HopMetadataUtil;
import org.apache.hop.projects.config.ProjectsConfig;
import org.apache.hop.projects.config.ProjectsConfigSingleton;
import org.apache.hop.projects.project.Project;
import org.apache.hop.projects.project.ProjectConfig;
-import org.apache.hop.projects.util.ProjectsUtil;
-import org.apache.hop.ui.hopgui.HopGui;
@ExtensionPoint(
id = "HopImportConnections",
@@ -55,23 +55,27 @@ public class HopImportDbConnections implements
IExtensionPoint<Object[]> {
List<DatabaseMeta> connectionList = (List<DatabaseMeta>)
connectionObject[1];
TreeMap<String, String> connectionFileMap = (TreeMap<String, String>)
connectionObject[2];
- HopGui hopGui = HopGui.getInstance();
- ILogChannel log = hopGui.getLog();
+ ILogChannel log = iLogChannel != null ? iLogChannel : LogChannel.GENERAL;
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
-
ProjectConfig projectConfig = config.findProjectConfig(projectName);
- Project project = projectConfig.loadProject(hopGui.getVariables());
- ProjectsUtil.enableProject(
- hopGui.getLog(), projectName, project, variables,
Collections.emptyList(), null, hopGui);
- IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
+ if (projectConfig == null) {
+ throw new HopException("Unable to find project '" + projectName + "'");
+ }
+
+ // Apply the target project on a throwaway variable space so import does
not switch the GUI
+ // session (PROJECT_HOME, metadata provider, namespace). See issue #2865.
+ IVariables importVars = new Variables();
+ importVars.initializeFrom(variables);
+ Project project = projectConfig.loadProject(importVars);
+ project.modifyVariables(importVars, projectConfig,
Collections.emptyList(), null);
+
+ IHopMetadataProvider metadataProvider =
+ HopMetadataUtil.getStandardHopMetadataProvider(importVars);
IHopMetadataSerializer<DatabaseMeta> databaseSerializer =
metadataProvider.getSerializer(DatabaseMeta.class);
- projectConfig.getProjectHome();
- Iterator<DatabaseMeta> connectionIterator = connectionList.iterator();
- while (connectionIterator.hasNext()) {
- DatabaseMeta databaseMeta = connectionIterator.next();
+ for (DatabaseMeta databaseMeta : connectionList) {
try {
if (databaseSerializer.exists(databaseMeta.getName())) {
log.logBasic(
@@ -85,22 +89,24 @@ public class HopImportDbConnections implements
IExtensionPoint<Object[]> {
}
}
- String eol = System.getProperty("line.separator");
+ if (connectionList.isEmpty()) {
+ return;
+ }
- // only create connections csv if we have connections
- if (!connectionList.isEmpty()) {
- String connectionsFileName =
- projectConfig.getProjectHome() +
System.getProperty("file.separator") + "connections.csv";
- try (OutputStream outputStream =
HopVfs.getOutputStream(connectionsFileName, false)) {
+ String eol = System.getProperty("line.separator");
+ String projectHome = importVars.resolve(projectConfig.getProjectHome());
+ try (FileObject home = HopVfs.getFileObject(projectHome)) {
+ FileObject connectionsFile = home.resolveFile("connections.csv");
+ try (OutputStream outputStream = HopVfs.getOutputStream(connectionsFile,
false)) {
for (Map.Entry<String, String> entry : connectionFileMap.entrySet()) {
outputStream.write(entry.getKey().getBytes(StandardCharsets.UTF_8));
outputStream.write(",".getBytes(StandardCharsets.UTF_8));
outputStream.write(entry.getValue().getBytes(StandardCharsets.UTF_8));
outputStream.write(eol.getBytes(StandardCharsets.UTF_8));
}
- } catch (IOException e) {
- throw new HopException("Error writing connections file to project " +
projectName, e);
}
+ } catch (Exception e) {
+ throw new HopException("Error writing connections file to project " +
projectName, e);
}
}
}
diff --git
a/plugins/misc/projects/src/test/java/org/apache/hop/projects/xp/HopImportCreateProjectIfNotExistsTest.java
b/plugins/misc/projects/src/test/java/org/apache/hop/projects/xp/HopImportCreateProjectIfNotExistsTest.java
new file mode 100644
index 0000000000..55ed6e5dbb
--- /dev/null
+++
b/plugins/misc/projects/src/test/java/org/apache/hop/projects/xp/HopImportCreateProjectIfNotExistsTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.xp;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Comparator;
+import java.util.stream.Stream;
+import org.apache.hop.core.Const;
+import org.apache.hop.core.config.HopConfig;
+import org.apache.hop.core.logging.HopLogStore;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.core.variables.Variables;
+import org.apache.hop.projects.config.ProjectsConfig;
+import org.apache.hop.projects.config.ProjectsConfigSingleton;
+import org.apache.hop.projects.project.ProjectConfig;
+import org.apache.hop.projects.util.Defaults;
+import org.apache.hop.projects.util.ProjectsUtil;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class HopImportCreateProjectIfNotExistsTest {
+
+ private Path tempRoot;
+ private ProjectConfig previousImportProject;
+ private String previousDefaultProjectConfigFile;
+
+ @BeforeAll
+ static void beforeAll() {
+ HopLogStore.init();
+ }
+
+ @BeforeEach
+ void setUp() throws Exception {
+ tempRoot = Files.createTempDirectory("hop-import-create-project");
+ HopConfig.setInMemoryMode(true);
+ ProjectsConfig config = ProjectsConfigSingleton.getConfig();
+ previousDefaultProjectConfigFile = config.getDefaultProjectConfigFile();
+
config.setDefaultProjectConfigFile(ProjectsConfig.DEFAULT_PROJECT_CONFIG_FILENAME);
+ previousImportProject =
+
copyOf(config.findProjectConfig(HopImportCreateProjectIfNotExists.IMPORT_PROJECT_NAME));
+ }
+
+ @AfterEach
+ void tearDown() throws Exception {
+ ProjectsConfig config = ProjectsConfigSingleton.getConfig();
+
config.removeProjectConfig(HopImportCreateProjectIfNotExists.IMPORT_PROJECT_NAME);
+ if (previousImportProject != null) {
+ config.addProjectConfig(previousImportProject);
+ }
+ config.setDefaultProjectConfigFile(previousDefaultProjectConfigFile);
+ HopConfig.setInMemoryMode(false);
+ if (tempRoot != null && Files.exists(tempRoot)) {
+ try (Stream<Path> walk = Files.walk(tempRoot)) {
+
walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
+ }
+ tempRoot = null;
+ }
+ }
+
+ @Test
+ void creatingAnImportProjectDoesNotChangeCallerProjectHome() throws
Exception {
+ Path originalHome = tempRoot.resolve("original-home");
+ Path importHome = tempRoot.resolve("import-dest");
+ Files.createDirectories(originalHome);
+ Files.createDirectories(importHome);
+
+ IVariables variables = new Variables();
+ variables.setVariable(ProjectsUtil.VARIABLE_PROJECT_HOME,
originalHome.toString());
+ variables.setVariable(Defaults.VARIABLE_HOP_PROJECT_NAME, "original");
+ variables.setVariable(ProjectsUtil.VARIABLE_PARENT_PROJECT_HOME,
"/parent");
+ variables.setVariable(Const.HOP_METADATA_FOLDER, originalHome +
"/metadata");
+
+ ProjectConfig created =
+ HopImportCreateProjectIfNotExists.createImportProject(
+ variables, importHome.toString(), false);
+
+ assertEquals(
+ originalHome.toString(),
variables.getVariable(ProjectsUtil.VARIABLE_PROJECT_HOME));
+ assertEquals("original",
variables.getVariable(Defaults.VARIABLE_HOP_PROJECT_NAME));
+ assertEquals("/parent",
variables.getVariable(ProjectsUtil.VARIABLE_PARENT_PROJECT_HOME));
+ assertEquals(originalHome + "/metadata",
variables.getVariable(Const.HOP_METADATA_FOLDER));
+
+ assertNotNull(created);
+ assertEquals(HopImportCreateProjectIfNotExists.IMPORT_PROJECT_NAME,
created.getProjectName());
+ assertEquals(importHome.toString(), created.getProjectHome());
+ assertTrue(
+
Files.isRegularFile(importHome.resolve(ProjectsConfig.DEFAULT_PROJECT_CONFIG_FILENAME)));
+ assertNotNull(
+ ProjectsConfigSingleton.getConfig()
+
.findProjectConfig(HopImportCreateProjectIfNotExists.IMPORT_PROJECT_NAME));
+ }
+
+ @Test
+ void emptyDefaultProjectConfigFileFallsBackToProjectConfigJson() throws
Exception {
+ Path importHome = tempRoot.resolve("empty-config-name");
+ Files.createDirectories(importHome);
+ ProjectsConfigSingleton.getConfig().setDefaultProjectConfigFile("");
+
+ ProjectConfig created =
+ HopImportCreateProjectIfNotExists.createImportProject(
+ new Variables(), importHome.toString(), false);
+
+ assertNotNull(created);
+ assertEquals(ProjectsConfig.DEFAULT_PROJECT_CONFIG_FILENAME,
created.getConfigFilename());
+ assertTrue(
+
Files.isRegularFile(importHome.resolve(ProjectsConfig.DEFAULT_PROJECT_CONFIG_FILENAME)));
+ }
+
+ @Test
+ void emptyProjectPathIsANoOp() throws Exception {
+ IVariables variables = new Variables();
+ variables.setVariable(ProjectsUtil.VARIABLE_PROJECT_HOME,
"/original-home");
+
+
assertNull(HopImportCreateProjectIfNotExists.createImportProject(variables, "",
false));
+
assertNull(HopImportCreateProjectIfNotExists.createImportProject(variables,
null, false));
+ assertEquals("/original-home",
variables.getVariable(ProjectsUtil.VARIABLE_PROJECT_HOME));
+ }
+
+ private static ProjectConfig copyOf(ProjectConfig source) {
+ if (source == null) {
+ return null;
+ }
+ ProjectConfig copy =
+ new ProjectConfig(
+ source.getProjectName(), source.getProjectHome(),
source.getConfigFilename());
+ copy.setReadOnly(source.isReadOnly());
+ copy.setGroup(source.getGroup());
+ copy.setTags(source.getTags());
+ return copy;
+ }
+}
diff --git
a/plugins/misc/projects/src/test/java/org/apache/hop/projects/xp/HopImportDbConnectionsTest.java
b/plugins/misc/projects/src/test/java/org/apache/hop/projects/xp/HopImportDbConnectionsTest.java
new file mode 100644
index 0000000000..4d45226ef0
--- /dev/null
+++
b/plugins/misc/projects/src/test/java/org/apache/hop/projects/xp/HopImportDbConnectionsTest.java
@@ -0,0 +1,137 @@
+/*
+ * 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.xp;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.TreeMap;
+import java.util.stream.Stream;
+import org.apache.hop.core.Const;
+import org.apache.hop.core.HopClientEnvironment;
+import org.apache.hop.core.config.HopConfig;
+import org.apache.hop.core.database.DatabaseMeta;
+import org.apache.hop.core.logging.HopLogStore;
+import org.apache.hop.core.logging.LogChannel;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.core.variables.Variables;
+import org.apache.hop.metadata.serializer.multi.MultiMetadataProvider;
+import org.apache.hop.metadata.util.HopMetadataInstance;
+import org.apache.hop.projects.config.ProjectsConfig;
+import org.apache.hop.projects.config.ProjectsConfigSingleton;
+import org.apache.hop.projects.project.ProjectConfig;
+import org.apache.hop.projects.util.Defaults;
+import org.apache.hop.projects.util.ProjectsUtil;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class HopImportDbConnectionsTest {
+
+ private static final String PROJECT_NAME = "import-connections-target";
+
+ private Path tempRoot;
+ private MultiMetadataProvider previousMetadataProvider;
+
+ @BeforeAll
+ static void beforeAll() throws Exception {
+ HopLogStore.init();
+ HopClientEnvironment.init();
+ }
+
+ @BeforeEach
+ void setUp() throws Exception {
+ tempRoot = Files.createTempDirectory("hop-import-db-connections");
+ HopConfig.setInMemoryMode(true);
+ previousMetadataProvider = HopMetadataInstance.getMetadataProvider();
+ }
+
+ @AfterEach
+ void tearDown() throws Exception {
+ ProjectsConfigSingleton.getConfig().removeProjectConfig(PROJECT_NAME);
+ HopMetadataInstance.setMetadataProvider(previousMetadataProvider);
+ HopConfig.setInMemoryMode(false);
+ if (tempRoot != null && Files.exists(tempRoot)) {
+ try (Stream<Path> walk = Files.walk(tempRoot)) {
+
walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
+ }
+ tempRoot = null;
+ }
+ }
+
+ @Test
+ void importingConnectionsDoesNotActivateTheTargetProject() throws Exception {
+ Path originalHome = tempRoot.resolve("original-home");
+ Path targetHome = tempRoot.resolve("target-home");
+ Files.createDirectories(originalHome);
+ Files.createDirectories(targetHome);
+ Files.writeString(
+ targetHome.resolve(ProjectsConfig.DEFAULT_PROJECT_CONFIG_FILENAME),
+ "{\n"
+ + " \"metadataBaseFolder\" : \"${PROJECT_HOME}/metadata\",\n"
+ + " \"unitTestsBasePath\" : \"${PROJECT_HOME}\",\n"
+ + " \"dataSetsCsvFolder\" : \"${PROJECT_HOME}/datasets\",\n"
+ + " \"enforcingExecutionInHome\" : true,\n"
+ + " \"config\" : { \"variables\" : [ ] }\n"
+ + "}\n",
+ StandardCharsets.UTF_8);
+
+ ProjectsConfigSingleton.getConfig()
+ .addProjectConfig(
+ new ProjectConfig(
+ PROJECT_NAME,
+ targetHome.toString(),
+ ProjectsConfig.DEFAULT_PROJECT_CONFIG_FILENAME));
+
+ IVariables variables = new Variables();
+ variables.setVariable(ProjectsUtil.VARIABLE_PROJECT_HOME,
originalHome.toString());
+ variables.setVariable(Defaults.VARIABLE_HOP_PROJECT_NAME, "original");
+ variables.setVariable(Const.HOP_METADATA_FOLDER, originalHome +
"/metadata");
+
+ DatabaseMeta databaseMeta = new DatabaseMeta();
+ databaseMeta.setName("imported-db");
+ databaseMeta.setDatabaseType("NONE");
+ List<DatabaseMeta> connections = new ArrayList<>();
+ connections.add(databaseMeta);
+ TreeMap<String, String> connectionFileMap = new TreeMap<>();
+ connectionFileMap.put("source.ktr", "imported-db");
+
+ new HopImportDbConnections()
+ .callExtensionPoint(
+ LogChannel.GENERAL,
+ variables,
+ new Object[] {PROJECT_NAME, connections, connectionFileMap});
+
+ assertEquals(
+ originalHome.toString(),
variables.getVariable(ProjectsUtil.VARIABLE_PROJECT_HOME));
+ assertEquals("original",
variables.getVariable(Defaults.VARIABLE_HOP_PROJECT_NAME));
+ assertEquals(originalHome + "/metadata",
variables.getVariable(Const.HOP_METADATA_FOLDER));
+ assertTrue(Files.isRegularFile(targetHome.resolve("connections.csv")));
+ assertTrue(
+ Files.isRegularFile(
+
targetHome.resolve("metadata").resolve("rdbms").resolve("imported-db.json")));
+ }
+}