use of com.devonfw.cobigen.impl.config.entity.TemplateFile in project cobigen by devonfw.
the class TemplatePathTest method verifyChildren.
private static void verifyChildren(TemplateFolder folder, TemplatePath... children) {
assertThat(folder.getChildren()).containsOnly(children);
if (children.length == 0) {
return;
}
List<TemplateFolder> childFolders = new ArrayList<>();
List<TemplateFile> childFiles = new ArrayList<>();
for (TemplatePath child : children) {
if (child.isFolder()) {
assertThat(child.isFile()).isFalse();
childFolders.add((TemplateFolder) child);
} else {
assertThat(child.isFile()).isTrue();
childFiles.add((TemplateFile) child);
}
}
}
use of com.devonfw.cobigen.impl.config.entity.TemplateFile in project cobigen by devonfw.
the class TemplatePathTest method testFolderTree.
/**
* Test {@link TemplateFolder#create(Path)} for folder tree with property overloading.
*/
@Test
public void testFolderTree() {
String filename = "tree";
String emptyFile = "empty-file";
Path path = Paths.get(TEST_FILES_ROOT_PATH + filename);
TemplateFolder folder = TemplateFolder.create(path);
verifyRootFolder(folder, path);
assertThat(folder).isNotNull();
assertThat(folder.getVariables().asMap()).isEmpty();
TemplateFolder having = verifyChildFolder(folder, path, "having");
TemplateFolder or = verifyChildFolder(folder, path, "or");
verifyChildren(folder, having, or);
assertThat(having.getVariables().asMap()).isEmpty();
TemplateFolder property = verifyChildFolder(having, having.getPath(), "property");
verifyChildren(having, property);
assertThat(property.getChild("cobigen.properties")).isNull();
assertThat(property.getChild("COBIGEN.PROPERTIES")).isNull();
assertThat(property.getVariables().asMap()).hasSize(2).containsEntry("foo", "foo").containsEntry("bar", "bar");
TemplateFolder override = verifyChildFolder(property, property.getPath(), "override");
verifyChildren(property, override);
assertThat(override.getVariables().asMap()).hasSize(2).containsEntry("foo", "bar").containsEntry("bar", "bar");
TemplateFile emptyFileInOverride = verifyChildFile(override, override.getPath(), emptyFile);
verifyChildren(override, emptyFileInOverride);
TemplateFolder not = verifyChildFolder(or, or.getPath(), "not");
assertThat(not.getVariables().asMap()).isEmpty();
TemplateFile emptyFileInNot = verifyChildFile(not, not.getPath(), emptyFile);
verifyChildren(not, emptyFileInNot);
}
Aggregations