Skip to content

Commit

Permalink
devonfw#1518 Implemented requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MansourD committed Aug 23, 2022
1 parent 260c0e5 commit f067be5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ private void checkMonolithicConfigurationException() {
try {
CobiGenUtils.initializeCobiGen(this.templatesProject, false);
} catch (DeprecatedMonolithicConfigurationException e) {
String monolithicConfigurationMessage = "Found monolithic configuration at:";
if (this.templatesProject == null)
LOG.warn("Found monolithic configuration at: {} ", ConfigurationFinder.findTemplatesLocation());
LOG.warn(monolithicConfigurationMessage + "{} ", ConfigurationFinder.findTemplatesLocation());
else
LOG.warn("Found monolithic configuration at: {} ", this.templatesProject);
LOG.warn(monolithicConfigurationMessage + "{} ", this.templatesProject);
LOG.warn(e.getMessage());
if (this.upgradeConfiguration) {
startTemplatesUpgrader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class ResourcesPluginUtil {
/**
* This variable is used to know if the templates got upgraded or not
*/
public static boolean TemplatesUpgraded = false;
public static boolean templatesUpgraded = false;

/**
* This variable is used to know if we have a custom generator project
Expand Down Expand Up @@ -307,7 +307,7 @@ public static void startTemplatesUpgrader(Path monolithicConfiguration) {
templateAdapter = new TemplateAdapterImpl(monolithicConfiguration);
}
templateAdapter.upgradeMonolithicTemplates(monolithicConfiguration);
TemplatesUpgraded = true;
templatesUpgraded = true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private static CobiGen initializeGenerator(boolean allowMonolithicConfiguration)

// we need to check if templates got upgraded then initialize cobigen again. Now with the new template-set
// structure
if (ResourcesPluginUtil.TemplatesUpgraded)
if (ResourcesPluginUtil.templatesUpgraded)
return initializeCobiGen(null, true);

return initializeCobiGen(generatorProj, true);
Expand Down Expand Up @@ -261,15 +261,15 @@ private static CobiGen initializeCobiGen(IProject generatorProj, boolean allowMo
Path templateSetsAdaptedFolderPath = templatesDirectoryPath.resolve(ConfigurationConstants.ADAPTED_FOLDER);
Path templateSetsDownloadedFolderPath = templatesDirectoryPath.resolve(ConfigurationConstants.DOWNLOADED_FOLDER);

if (!ResourcesPluginUtil.generatorProjExists || ResourcesPluginUtil.TemplatesUpgraded
if (!ResourcesPluginUtil.generatorProjExists || ResourcesPluginUtil.templatesUpgraded
|| generatorProj.getLocationURI() == null) {

/*
* After the upgrade the new template-sets will be used. Only once! Then the old configuration has to be deleted
* or the upgrader will start again. This time the upgrader cannot start again because template-sets already
* exists.
*/
ResourcesPluginUtil.TemplatesUpgraded = false;
ResourcesPluginUtil.templatesUpgraded = false;
// check adapted and downloaded folder
if (Files.exists(templateSetsAdaptedFolderPath) || Files.exists(templateSetsDownloadedFolderPath)) {
return CobiGenFactory.create(templatesDirectoryPath.toUri(), allowMonolithicConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class TimestampUtilTest {

/**
*
* Tests the read and write method from TimestampUtil also tests that only one Timestamp will be stored at a time
* Tests the write method from TimestampUtil also tests that only one Timestamp will be stored at a time
*
* @throws IOException
*/
@Test
public void testWriteAndReadTimestamp() throws IOException {
public void testWriteTimestamp() throws IOException {

Path configFile = Paths.get("src/test/resources/testdata/unittest/config/util/config");
Timestamp InstantTimestamp = TimestampUtil.createInstantTimestamp();
Expand All @@ -39,4 +39,24 @@ public void testWriteAndReadTimestamp() throws IOException {

}

/**
*
* Tests the readTimestamp method from TimestampUtil
*
* @throws IOException
*/
@Test
public void testReadTimestamp() throws IOException {

Path configFile = Paths.get("src/test/resources/testdata/unittest/config/util/config");
Timestamp InstantTimestamp = TimestampUtil.createInstantTimestamp();
TimestampUtil.writeTimestamp(configFile, InstantTimestamp);

Timestamp InstantTimestampCopy = TimestampUtil.readTimestamp(configFile);

Assert.assertEquals(InstantTimestamp, InstantTimestampCopy);

Files.delete(configFile.toFile());

}
}

0 comments on commit f067be5

Please sign in to comment.