use of com.devonfw.cobigen.impl.config.reader.TemplatesConfigurationReader in project cobigen by devonfw.
the class TemplatesConfigurationReaderTest method testErrorOnUnhookedTemplateExtensionDeclaration.
/**
* Tests whether a template extension with an id-reference, which does not point on any template, will cause an
* {@link InvalidConfigurationException}
*
* @throws InvalidConfigurationException expected
*/
@Test(expected = InvalidConfigurationException.class)
public void testErrorOnUnhookedTemplateExtensionDeclaration() throws InvalidConfigurationException {
TemplatesConfigurationReader reader = new TemplatesConfigurationReader(new File(testFileRootPath).toPath(), "faulty_unhooked_template_extension");
reader.loadTemplates(null);
}
use of com.devonfw.cobigen.impl.config.reader.TemplatesConfigurationReader in project cobigen by devonfw.
the class TemplatesConfigurationReaderTest method testErrorOnDuplicateTemplateExtensionDeclaration.
/**
* Tests whether a duplicate template extension declaration will result in an {@link InvalidConfigurationException}
*
* @throws InvalidConfigurationException expected
*/
@Test(expected = InvalidConfigurationException.class)
public void testErrorOnDuplicateTemplateExtensionDeclaration() throws InvalidConfigurationException {
TemplatesConfigurationReader reader = new TemplatesConfigurationReader(new File(testFileRootPath).toPath(), "faulty_duplicate_template_extension");
reader.loadTemplates(null);
}
use of com.devonfw.cobigen.impl.config.reader.TemplatesConfigurationReader in project cobigen by devonfw.
the class TemplatesConfigurationReaderTest method testErrorOnInvalidTemplateScanReference.
/**
* Tests the correct detection of invalid template scan references.
*
* @throws InvalidConfigurationException expected
*/
@Test(expected = InvalidConfigurationException.class)
public void testErrorOnInvalidTemplateScanReference() throws InvalidConfigurationException {
TemplatesConfigurationReader reader = new TemplatesConfigurationReader(new File(testFileRootPath).toPath(), "faulty_invalid_template_scan_ref");
reader.loadTemplates(null);
}
use of com.devonfw.cobigen.impl.config.reader.TemplatesConfigurationReader in project cobigen by devonfw.
the class TemplatesConfigurationReaderTest method testTemplatesOfAPackageRetrieval.
/**
* Tests whether all templates of a template package could be retrieved successfully.
*
* @throws Exception test fails
*/
@Test
public void testTemplatesOfAPackageRetrieval() throws Exception {
TemplatesConfigurationReader target = new TemplatesConfigurationReader(new File(testFileRootPath).toPath(), "valid");
Trigger trigger = new Trigger("", "asdf", "", Charset.forName("UTF-8"), new LinkedList<Matcher>(), new LinkedList<ContainerMatcher>());
Template templateMock = mock(Template.class);
HashMap<String, Template> templates = new HashMap<>();
templates.put("resources_resources_spring_common", templateMock);
target.loadIncrements(templates, trigger);
}
use of com.devonfw.cobigen.impl.config.reader.TemplatesConfigurationReader in project cobigen by devonfw.
the class TemplatesConfigurationReaderTest method testCorrectResolutionOfTemplateScanReferences.
/**
* Tests the correct resolution of template scan references in increments.
*
* @throws InvalidConfigurationException test fails
*/
@Test
public void testCorrectResolutionOfTemplateScanReferences() throws InvalidConfigurationException {
// given
TemplatesConfigurationReader reader = new TemplatesConfigurationReader(new File(testFileRootPath).toPath(), "valid_template_scan_references");
Trigger trigger = new Trigger("", "asdf", "", Charset.forName("UTF-8"), new LinkedList<Matcher>(), new LinkedList<ContainerMatcher>());
// when
Map<String, Template> templates = reader.loadTemplates(trigger);
Map<String, Increment> increments = reader.loadIncrements(templates, trigger);
// validation
assertThat(templates).containsOnlyKeys("prefix_foo_BarClass.java", "prefix_bar_Foo2Class.java", "prefix_foo_FooClass.java");
assertThat(increments).containsOnlyKeys("test");
assertThat(increments.get("test").getTemplates()).extracting("name").containsOnly("prefix_foo_BarClass.java", "prefix_foo_FooClass.java");
}
Aggregations