use of com.devonfw.cobigen.impl.config.reader.ContextConfigurationReader in project cobigen by devonfw.
the class TemplatesConfigurationReaderTest method testInvalidTemplateRefOutsideCurrentFile.
/**
* Tests the correct detection of invalid external increment reference.
*
* @throws InvalidConfigurationException expected
*/
@Test(expected = InvalidConfigurationException.class)
public void testInvalidTemplateRefOutsideCurrentFile() {
Path config = Paths.get(new File(testFileRootPath).toURI());
new ContextConfigurationReader(config);
// given
ConfigurationHolder configurationHolder = new ConfigurationHolder(config.toUri());
TemplatesConfigurationReader target = new TemplatesConfigurationReader(new File(testFileRootPath).toPath(), "faulty_invalid_external_templateref", configurationHolder);
Trigger trigger = new Trigger("", "asdf", "", Charset.forName("UTF-8"), new LinkedList<Matcher>(), new LinkedList<ContainerMatcher>());
// when
Map<String, Template> templates = target.loadTemplates(trigger);
target.loadIncrements(templates, trigger);
}
use of com.devonfw.cobigen.impl.config.reader.ContextConfigurationReader in project cobigen by devonfw.
the class ContextConfigurationReaderTest method testOldConfiguration.
/**
* Tests that exactly one v2.1 context configuration is read
*
* Backward Compatibility test, remove when monolithic context.xml is deprecated.
*/
@Test
public void testOldConfiguration() {
ContextConfigurationReader context = new ContextConfigurationReader(Paths.get(testFileRootPath + "valid_source_folder"));
assertThat(context.getContextFiles().size()).isEqualTo(1);
}
use of com.devonfw.cobigen.impl.config.reader.ContextConfigurationReader in project cobigen by devonfw.
the class TemplatesConfigurationReaderTest method testInvalidIncrementRefOutsideCurrentFile.
/**
* Tests the correct detection of invalid external increment reference.
*
* @throws InvalidConfigurationException expected
*/
@Test(expected = InvalidConfigurationException.class)
public void testInvalidIncrementRefOutsideCurrentFile() {
Path config = Paths.get(new File(testFileRootPath).toURI());
new ContextConfigurationReader(config);
// given
ConfigurationHolder configurationHolder = new ConfigurationHolder(config.toUri());
TemplatesConfigurationReader target = new TemplatesConfigurationReader(new File(testFileRootPath).toPath(), "faulty_invalid_external_incrementref", configurationHolder);
Trigger trigger = new Trigger("", "asdf", "", Charset.forName("UTF-8"), new LinkedList<Matcher>(), new LinkedList<ContainerMatcher>());
// when
Map<String, Template> templates = target.loadTemplates(trigger);
target.loadIncrements(templates, trigger);
}
use of com.devonfw.cobigen.impl.config.reader.ContextConfigurationReader in project cobigen by devonfw.
the class ContextConfiguration method readConfiguration.
/**
* Reads the configuration from the given path
*
* @param configRoot CobiGen configuration root path
* @throws InvalidConfigurationException thrown if the {@link File} is not valid with respect to the context.xsd
*/
private void readConfiguration(Path configRoot) throws InvalidConfigurationException {
ContextConfigurationReader reader = new ContextConfigurationReader(configRoot);
this.configurationPath = reader.getContextRoot();
this.triggers = reader.loadTriggers();
}
use of com.devonfw.cobigen.impl.config.reader.ContextConfigurationReader in project cobigen by devonfw.
the class ContextConfigurationReaderTest method testNewConfiguration.
/**
* Tests if multiple (2) templates are found with v2.2 context configuration
*/
@Test
public void testNewConfiguration() {
ContextConfigurationReader context = new ContextConfigurationReader(Paths.get(testFileRootPath + "valid_new"));
assertThat(context.getContextFiles().size()).isEqualTo(2);
}
Aggregations