Search in sources :

Example 26 with Template

use of com.devonfw.cobigen.impl.config.entity.Template 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");
}
Also used : Trigger(com.devonfw.cobigen.impl.config.entity.Trigger) ContainerMatcher(com.devonfw.cobigen.impl.config.entity.ContainerMatcher) Matcher(com.devonfw.cobigen.impl.config.entity.Matcher) ContainerMatcher(com.devonfw.cobigen.impl.config.entity.ContainerMatcher) Increment(com.devonfw.cobigen.impl.config.entity.Increment) TemplatesConfigurationReader(com.devonfw.cobigen.impl.config.reader.TemplatesConfigurationReader) File(java.io.File) Template(com.devonfw.cobigen.impl.config.entity.Template) AbstractUnitTest(com.devonfw.cobigen.unittest.config.common.AbstractUnitTest) Test(org.junit.Test)

Aggregations

Template (com.devonfw.cobigen.impl.config.entity.Template)26 Trigger (com.devonfw.cobigen.impl.config.entity.Trigger)19 File (java.io.File)17 ContainerMatcher (com.devonfw.cobigen.impl.config.entity.ContainerMatcher)16 Matcher (com.devonfw.cobigen.impl.config.entity.Matcher)16 AbstractUnitTest (com.devonfw.cobigen.unittest.config.common.AbstractUnitTest)16 Test (org.junit.Test)16 TemplatesConfigurationReader (com.devonfw.cobigen.impl.config.reader.TemplatesConfigurationReader)15 InvalidConfigurationException (com.devonfw.cobigen.api.exception.InvalidConfigurationException)5 Increment (com.devonfw.cobigen.impl.config.entity.Increment)5 Path (java.nio.file.Path)5 ConfigurationHolder (com.devonfw.cobigen.impl.config.ConfigurationHolder)4 TemplatePath (com.devonfw.cobigen.impl.config.entity.TemplatePath)4 TextTemplateEngine (com.devonfw.cobigen.api.extension.TextTemplateEngine)3 TemplatesConfiguration (com.devonfw.cobigen.impl.config.TemplatesConfiguration)3 HashMap (java.util.HashMap)3 CobiGenRuntimeException (com.devonfw.cobigen.api.exception.CobiGenRuntimeException)2 TemplateTo (com.devonfw.cobigen.api.to.TemplateTo)2 TemplateFolder (com.devonfw.cobigen.impl.config.entity.TemplateFolder)2 TemplateExtension (com.devonfw.cobigen.impl.config.entity.io.TemplateExtension)2