use of com.devonfw.cobigen.impl.config.ConfigurationHolder in project cobigen by devonfw.
the class TemplatesConfigurationReaderTest method testIncrementRefOutsideCurrentFile.
/**
* Tests the correct resolution of incrementsRef from outside the current templates file. (Issue #678)
*/
@Test
public void testIncrementRefOutsideCurrentFile() {
// given
Trigger trigger = new Trigger("testingTrigger", "asdf", "valid_external_incrementref", Charset.forName("UTF-8"), new LinkedList<Matcher>(), new LinkedList<ContainerMatcher>());
Path config = Paths.get(new File(testFileRootPath).toURI());
ConfigurationHolder configurationHolder = new ConfigurationHolder(config.toUri());
TemplatesConfiguration templatesConfiguration = configurationHolder.readTemplatesConfiguration(trigger);
Map<String, Increment> increments = templatesConfiguration.getIncrements();
// validation
assertThat(templatesConfiguration.getTrigger().getId()).isEqualTo("testingTrigger");
assertThat(increments).containsOnlyKeys("3", "4", "5");
Increment incrementThree = increments.get("3").getDependentIncrements().get(0);
assertThat(incrementThree.getName()).isEqualTo("0");
assertThat(incrementThree.getTemplates().size()).isEqualTo(1);
Increment incrementFour = increments.get("4").getDependentIncrements().get(0);
assertThat(incrementFour.getName()).isEqualTo("1");
assertThat(incrementFour.getTemplates().size()).isEqualTo(4);
Increment incrementFive = increments.get("5").getDependentIncrements().get(0);
assertThat(incrementFive.getName()).isEqualTo("2");
assertThat(incrementFive.getTemplates().size()).isEqualTo(4);
}
use of com.devonfw.cobigen.impl.config.ConfigurationHolder in project cobigen by devonfw.
the class TemplateClassTest method testResolveUtilClassesFromTemplatesFolder.
/**
* Tests if the template utility classes can be loaded from a configuration folder
*
* @throws IOException test fails
*/
@Test
public void testResolveUtilClassesFromTemplatesFolder() throws IOException {
String filename = "folder";
Path path = Paths.get(TEST_FILES_ROOT_PATH + filename);
List<Class<?>> classes = ConfigurationClassLoaderUtil.resolveUtilClasses(new ConfigurationHolder(path.toUri()), null);
assertThat(classes.get(0).getName()).contains("IDGenerator");
}
use of com.devonfw.cobigen.impl.config.ConfigurationHolder in project cobigen by devonfw.
the class TemplateClassTest method testResolveUtilClassesFromFolderFirst.
/**
* Tests if the template utility classes get loaded from a folder when both sources are available
*
* @throws IOException test fails
*/
@Test
public void testResolveUtilClassesFromFolderFirst() throws IOException {
Path pathArchive = Paths.get(TEST_FILES_ROOT_PATH + "archive" + File.separator + "templates.jar");
Path pathFolder = Paths.get(TEST_FILES_ROOT_PATH + "folder");
ClassLoader inputClassLoader = URLClassLoader.newInstance(new URL[] { pathArchive.toUri().toURL(), pathFolder.toUri().toURL() }, getClass().getClassLoader());
List<Class<?>> classes = ConfigurationClassLoaderUtil.resolveUtilClasses(new ConfigurationHolder(pathFolder.toUri()), inputClassLoader);
assertThat(classes.get(0).getName()).contains("IDGenerator");
}
Aggregations