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 Sep 19, 2022
1 parent 82213b6 commit f1ba716
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ private void checkMonolithicConfigurationException() {
if (this.templatesProject == null)
LOG.warn(monolithicConfigurationMessage + "{} ", ConfigurationFinder.findTemplatesLocation());
else
LOG.warn(monolithicConfigurationMessage + "{} ", this.templatesProject);
LOG.warn(e.getMessage());
LOG.warn(monolithicConfigurationMessage + "{} {}", this.templatesProject, e.getMessage());
if (this.upgradeConfiguration) {
startTemplatesUpgrader();
} else {
Expand Down Expand Up @@ -326,7 +325,7 @@ private void startTemplatesUpgrader() {
}

/**
* ask the user if he wants to postpone the upgrade message for 30 days.
* Asks the user if he wants to postpone the upgrade message for 30 days.
*
* @throws IOException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ public static void setUserWantsToDownloadTemplates(boolean userWantsToDownloadTe
* Upgrades the given template configuration.
*
* @param configurationPath path to the templates Configuration
*
*
*/
public static void startTemplatesUpgrader(Path configurationPath) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ private static CobiGen initializeGenerator(boolean allowMonolithicConfiguration)
}

/**
* Initializes the {@link CobiGen} with the correct configuration, checks if template-sets exists, if not the Jar or
* generatorProj will be used.
*
* @param generatorProj the templates project
* @param allowMonolithicConfiguration ignores deprecated monolithic template folder structure and if found does not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class ConfigurationConstants {
public static final String BACKUP_FOLDER = "backup";

/**
* Default cobigen version
* Default cobigen version TODO retrieve the version dynamically(not as a constant) at runtime.
*/
public static final String CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_VERSION = "2021.12.007";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import com.devonfw.cobigen.api.util.CobiGenPaths;

/**
* This Class is used to set the timestamp property
* This util class is used to set(create) a timestamp property, read it, and checks if exists. Also can check if a
* timestamp passed the current time.
*
*/
public class PostponeUtil {
Expand All @@ -27,7 +28,7 @@ public class PostponeUtil {
private static final Logger LOG = LoggerFactory.getLogger(PostponeUtil.class);

/**
* Writes the timestamp in a config file.
* Writes the Timestamp to a config file.
*
* @param configFile the config file or .cobigen file containing the properties.
* @param timestamp to be added to the config file
Expand All @@ -49,7 +50,7 @@ public static void writeTimestamp(Path configFile, Timestamp timestamp) throws I
}

/**
* Reads the timestamp from a config file.
* Reads the Timestamp from a config file.
*
* @param configFile the config file or .cobigen file containing the properties.
* @return the timestamp found in a config file
Expand All @@ -73,7 +74,7 @@ public static Timestamp readTimestamp(Path configFile) {
}

/**
* creates a time stamp
* Creates a time stamp
*
* @return a new Timestamp with the current time
*/
Expand All @@ -83,16 +84,22 @@ public static Timestamp createInstantTimestamp() {
return new Timestamp(currentDate.getTime());
}

@SuppressWarnings("javadoc")
/**
* Searches any Timestamp inside the config file in the HomePath, to determine whether that time is already passed.
*
* @return true if the current time already passed the time written in the config file.
*/
public static boolean isTimePassed() {

return isTimePassed(getHomePath());
}

/**
* Searches any Timestamp inside the config file, to determine whether that time is already passed.
*
* @param configFile the config file or .cobigen file containing the properties.
* @return boolean true if config file not exists, if no Timestamp found, or if the current time already passed the
* time written in the config file
* time written in the config file.
*/
public static boolean isTimePassed(Path configFile) {

Expand All @@ -107,14 +114,16 @@ public static boolean isTimePassed(Path configFile) {
}
}

@SuppressWarnings("javadoc")
/**
* Adds a new Timestamp to the config file in HomePath.
*/
public static void addATimestampForOneMonth() {

addATimestampForOneMonth(getHomePath());
}

/**
* add a new Timestamp in the config file with the current time + one month
* Adds a new Timestamp in the config file with the current time + one month
*
* @param configFile the config file or .cobigen file containing the properties.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.devonfw.cobigen.unittest.util;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Timestamp;

import org.assertj.core.util.Files;
import org.junit.Assert;
import org.junit.Test;

import com.devonfw.cobigen.impl.util.PostponeUtil;
Expand All @@ -33,7 +34,7 @@ public void testWriteTimestamp() throws IOException {

Timestamp InstantTimestampCopy = PostponeUtil.readTimestamp(configFile);

Assert.assertEquals(InstantTimestamp, InstantTimestampCopy);
assertThat(InstantTimestamp).isEqualTo(InstantTimestampCopy);

Files.delete(configFile.toFile());

Expand All @@ -54,7 +55,7 @@ public void testReadTimestamp() throws IOException {

Timestamp InstantTimestampCopy = PostponeUtil.readTimestamp(configFile);

Assert.assertEquals(InstantTimestamp, InstantTimestampCopy);
assertThat(InstantTimestamp).isEqualTo(InstantTimestampCopy);

Files.delete(configFile.toFile());

Expand Down

0 comments on commit f1ba716

Please sign in to comment.