|
/** |
|
* Test the correct folder creation |
|
* |
|
* @throws Exception test fails |
|
*/ |
|
@Test |
|
@Ignore // TODO: re-enable when upgrader was implemented, see: https://github.com/devonfw/cobigen/issues/1595 |
|
public void testTemplateSetUpgrade() throws Exception { |
|
|
|
FileUtils.copyDirectory(new File(testFileRootPath + "valid-2.1"), this.currentHome.toFile()); |
|
this.templateLocation = this.currentHome.resolve(ConfigurationConstants.TEMPLATES_FOLDER) |
|
.resolve(ConfigurationConstants.COBIGEN_TEMPLATES); |
|
|
|
withEnvironmentVariable(ConfigurationConstants.CONFIG_ENV_HOME, this.currentHome.toString()).execute(() -> { |
|
TemplateSetUpgrader templateSetUpgrader = new TemplateSetUpgrader(); |
|
templateSetUpgrader.upgradeTemplatesToTemplateSets(this.templateLocation); |
|
|
|
Path templateSetsPath = this.templateLocation.getParent().getParent() |
|
.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); |
|
Path backup = this.templateLocation.getParent().getParent().resolve(ConfigurationConstants.BACKUP_FOLDER); |
|
Path templateSetsAdapted = templateSetsPath.resolve(ConfigurationConstants.ADAPTED_FOLDER); |
|
assertThat(templateSetsPath).exists(); |
|
assertThat(templateSetsAdapted).exists(); |
|
assertThat(backup).exists(); |
|
}); |
|
} |
|
|
|
/** |
|
* Test the correct folder creation |
|
* |
|
* @throws Exception test fails |
|
*/ |
|
@Test |
|
public void testTemplateSetUpgradeWithoutTemplatesFolder() throws Exception { |
|
|
|
FileUtils.copyDirectory(new File(testFileRootPath + "valid-2.1/templates"), this.currentHome.toFile()); |
|
this.templateLocation = this.currentHome.resolve(ConfigurationConstants.COBIGEN_TEMPLATES); |
|
|
|
withEnvironmentVariable(ConfigurationConstants.CONFIG_ENV_HOME, this.currentHome.toString()).execute(() -> { |
|
TemplateSetUpgrader templateSetUpgrader = new TemplateSetUpgrader(); |
|
templateSetUpgrader.upgradeTemplatesToTemplateSets(this.templateLocation); |
|
|
|
Path templateSetsPath = this.templateLocation.getParent().resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); |
|
Path templateSetsAdapted = templateSetsPath.resolve(ConfigurationConstants.ADAPTED_FOLDER); |
|
Path backup = this.templateLocation.getParent().resolve(ConfigurationConstants.BACKUP_FOLDER); |
|
assertThat(templateSetsPath).exists(); |
|
assertThat(templateSetsAdapted).exists(); |
|
assertThat(backup).exists(); |
|
}); |
|
} |
Check:
cobigen/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/upgrade/TemplateSetUpgraderTest.java
Lines 65 to 114 in 5af0844