forked from devonfw/cobigen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1511 enable custom template set group ids for lookup (devonfw#1525)
* devonfw#1511 added new method to read properties in ConfigurationFinder.java new TemplateSetConfiguration Class to save properties new test cases in ConfigurationFinderTest.java * devonfw#1511 fixed logic in method readTemplateSetConfiguration in ConfigurationFinder added hideTemplates variable in TemplateSetConfiguration completed 2 out of 3 tests cases * devonfw#1511 corrected CheckTemplateSetConfiguration logic in ConfigurationFinder.java Test cases Correction for CheckTemplateSetConfiguration in ConfigurationFinderTest.java New Constants for the new properties created in ConfigurationConstants.java CheckTemplateSetConfiguration Called in load function in CobiGenPropertiesReader.java * devonfw#1511 canceled the method call in load properties in CobiGenPropertiesReader.java * devonfw#1511 written Documentation Modified the properties function to read properties corrected tests * devonfw#1511 documentation correction * devonfw#1511 Documentation correction * devonfw#1511 Documentation Correction * devonfw#1511 requested changes * devonfw#1511 requested changes #2 * devonfw#1511 requested changes 2 * devonfw#1511 requested changes * devonfw#1511 fix defaultGroupId logic
- Loading branch information
Showing
8 changed files
with
280 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
.../cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/TemplateSetConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.devonfw.cobigen.impl.config; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* mdukhan This Class is used to set specific properties if not found, or save them if correctly found. These properties | ||
* are groupIds, allowSnapshots and hideTemplates. | ||
*/ | ||
public class TemplateSetConfiguration { | ||
|
||
/** variable for template-set artifacts */ | ||
private List<String> groupIds; | ||
|
||
/** allow snapshots of template-sets */ | ||
private boolean allowSnapshots; | ||
|
||
/** variable to hide very specific template sets or versions of template sets */ | ||
private List<String> hideTemplates; | ||
|
||
/** | ||
* The constructor. load properties from a given source | ||
* | ||
* @param groupIds | ||
* @param allowSnapshots | ||
* @param hideTemplates | ||
*/ | ||
public TemplateSetConfiguration(List<String> groupIds, boolean allowSnapshots, List<String> hideTemplates) { | ||
|
||
super(); | ||
this.groupIds = groupIds; | ||
this.allowSnapshots = allowSnapshots; | ||
this.hideTemplates = hideTemplates; | ||
} | ||
|
||
/** | ||
* return a list of the saved groupIds | ||
* | ||
* @return groupIds | ||
*/ | ||
public List<String> getGroupIds() { | ||
|
||
return this.groupIds; | ||
} | ||
|
||
/** | ||
* set a list of the groupIds from a source | ||
* | ||
* @param groupIds new value of {@link #getgroupIds}. | ||
*/ | ||
public void setGroupIds(List<String> groupIds) { | ||
|
||
this.groupIds = groupIds; | ||
} | ||
|
||
/** | ||
* return a boolean which states if specific Snapshots should be allowed. | ||
* | ||
* @return allowSnapshots | ||
*/ | ||
public boolean isAllowSnapshots() { | ||
|
||
return this.allowSnapshots; | ||
} | ||
|
||
/** | ||
* set a value on the snapshot | ||
* | ||
* @param allowSnapshots new value of {@link #getallowSnapshots}. | ||
*/ | ||
public void setAllowSnapshots(boolean allowSnapshots) { | ||
|
||
this.allowSnapshots = allowSnapshots; | ||
} | ||
|
||
/** | ||
* return a list of the saved templates to be hidden | ||
* | ||
* @return hideTemplates | ||
*/ | ||
public List<String> getHideTemplates() { | ||
|
||
return this.hideTemplates; | ||
} | ||
|
||
/** | ||
* set a list of the HideTemplate from a source | ||
* | ||
* @param hideTemplates new value of {@link #gethideTemplates}. | ||
*/ | ||
public void setHideTemplates(List<String> hideTemplates) { | ||
|
||
this.hideTemplates = hideTemplates; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...bigen-core/src/test/java/com/devonfw/cobigen/unittest/config/ConfigurationFinderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.devonfw.cobigen.unittest.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import org.junit.Test; | ||
|
||
import com.devonfw.cobigen.api.constants.ConfigurationConstants; | ||
import com.devonfw.cobigen.impl.config.TemplateSetConfiguration; | ||
import com.devonfw.cobigen.impl.util.ConfigurationFinder; | ||
|
||
/** | ||
* mdukhan Class to test the method loadTemplateSetConfigurations in ConfigurationFinder | ||
* | ||
*/ | ||
public class ConfigurationFinderTest { | ||
|
||
/** | ||
* Test loadTemplateSetConfigurations Method in ConfigurationFinder if invalid properties found, to load the default | ||
* values. | ||
*/ | ||
@Test | ||
public void emptyConfigurationTest() { | ||
|
||
Path emptyConfiguration = Paths | ||
.get("src/test/resources/testdata/unittest/config/properties/emptyConfigProperties/config.properties"); | ||
TemplateSetConfiguration conf = ConfigurationFinder.loadTemplateSetConfigurations(emptyConfiguration); | ||
|
||
assertThat(conf.getGroupIds()).contains(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID); | ||
assertThat(conf.getHideTemplates()).isEmpty(); | ||
assertThat(conf.isAllowSnapshots()).isFalse(); | ||
} | ||
|
||
/** | ||
* Test loadTemplateSetConfigurations Method in ConfigurationFinder if valid properties found, to load these valid | ||
* properties correctly. | ||
*/ | ||
@Test | ||
public void validConfigurationTest() { | ||
|
||
Path validConfiguration = Paths | ||
.get("src/test/resources/testdata/unittest/config/properties/validConfigProperties/config.properties"); | ||
TemplateSetConfiguration conf = ConfigurationFinder.loadTemplateSetConfigurations(validConfiguration); | ||
|
||
assertThat(conf.getGroupIds()).containsSequence("devonfw-cobigen-bla", "abcd", "blablob", | ||
ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID); | ||
assertThat(conf.isAllowSnapshots()).isTrue(); | ||
assertThat(conf.getHideTemplates()).contains("com.devonfw(:test-artifact(:3.2.1-SNAPSHOT))"); | ||
} | ||
|
||
/** | ||
* Test loadTemplateSetConfigurations Method in ConfigurationFinder if file *.properties not found , to load the | ||
* default values. | ||
* | ||
*/ | ||
@Test | ||
public void invalidPathTest() { | ||
|
||
Path invalidPath = Paths.get("path/which/does/not/exist"); | ||
TemplateSetConfiguration conf = ConfigurationFinder.loadTemplateSetConfigurations(invalidPath); | ||
|
||
assertThat(conf.getGroupIds()).contains(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID); | ||
assertThat(conf.getHideTemplates()).isEmpty(); | ||
assertThat(conf.isAllowSnapshots()).isFalse(); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...est/resources/testdata/unittest/config/properties/emptyConfigProperties/config.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
foo=foo | ||
bar=bar |
4 changes: 4 additions & 0 deletions
4
...est/resources/testdata/unittest/config/properties/validConfigProperties/config.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
template-sets.groupIds=devonfw-cobigen-bla,abcd,blablob | ||
template-sets.allow-snapshots=true | ||
template-sets.disable-default-lookup=false | ||
template-sets.hide=com.devonfw(:test-artifact(:3.2.1-SNAPSHOT)) |
Oops, something went wrong.