use of dev.jbang.catalog.TemplateProperty in project jbang by jbangdev.
the class TestTemplate method testGetTemplateThreeWithProperties.
@Test
void testGetTemplateThreeWithProperties() throws IOException {
Template template = Template.get("three-with-properties");
assertThat(template, notNullValue());
assertThat(template.description, is("Template 3"));
assertThat(template.fileRefs, aMapWithSize(2));
assertThat(template.fileRefs.keySet(), hasItems("src/{filename}", "src/file2.java"));
assertThat(template.fileRefs.values(), hasItems("tpl2/file2_1.java", "tpl2/file2_2.java"));
assertThat(template.properties.entrySet(), hasItems(new AbstractMap.SimpleEntry<>("test-key", new TemplateProperty(null, null)), new AbstractMap.SimpleEntry<>("test-key-with-description", new TemplateProperty("This is a test description", null)), new AbstractMap.SimpleEntry<>("test-key-with-description-and-default-value", new TemplateProperty("This is a test description with default value", "2.11")), new AbstractMap.SimpleEntry<>("test-key-with-default-value", new TemplateProperty(null, "3.12"))));
}
use of dev.jbang.catalog.TemplateProperty in project jbang by jbangdev.
the class TestTemplate method testAddWithSingleComplexProperty.
@Test
void testAddWithSingleComplexProperty() throws IOException {
Path cwd = Util.getCwd();
Path testFile = cwd.resolve("test.java");
Files.write(testFile, "// Test file".getBytes());
assertThat(Files.isRegularFile(Paths.get(cwd.toString(), Catalog.JBANG_CATALOG_JSON)), is(false));
JBang jbang = new JBang();
new CommandLine(jbang).execute("template", "add", "-f", cwd.toString(), "--name=template-with-single-complex-property", "-d", "Description of the template", "-P", "new-test-key:This is a description for the property key:3.14", testFile.toString());
assertThat(Files.isRegularFile(Paths.get(cwd.toString(), Catalog.JBANG_CATALOG_JSON)), is(true));
Template name = Template.get("template-with-single-complex-property");
assertThat(name.properties.entrySet(), hasItems(new AbstractMap.SimpleEntry<>("new-test-key", new TemplateProperty("This is a description for the property key", "3.14"))));
}
use of dev.jbang.catalog.TemplateProperty in project jbang by jbangdev.
the class TestTemplate method testAddWithMultipleComplexProperties.
@Test
void testAddWithMultipleComplexProperties() throws IOException {
Path cwd = Util.getCwd();
Path testFile = cwd.resolve("test.java");
Files.write(testFile, "// Test file".getBytes());
assertThat(Files.isRegularFile(Paths.get(cwd.toString(), Catalog.JBANG_CATALOG_JSON)), is(false));
JBang jbang = new JBang();
new CommandLine(jbang).execute("template", "add", "-f", cwd.toString(), "--name=template-with-complex-properties", "-d", "Description of the template", "-P", "new-test-key:This is a description for the property key:3.14", "--property", "second-test-key:This is another description for the second property key:Non-Blocker", testFile.toString());
assertThat(Files.isRegularFile(Paths.get(cwd.toString(), Catalog.JBANG_CATALOG_JSON)), is(true));
Template name = Template.get("template-with-complex-properties");
assertThat(name.properties.entrySet(), hasItems(new AbstractMap.SimpleEntry<>("new-test-key", new TemplateProperty("This is a description for the property key", "3.14")), new AbstractMap.SimpleEntry<>("second-test-key", new TemplateProperty("This is another description for the second property key", "Non-Blocker"))));
}
use of dev.jbang.catalog.TemplateProperty in project jbang by jbangdev.
the class TestTemplate method testAddWithSingleProperty.
@Test
void testAddWithSingleProperty() throws IOException {
Path cwd = Util.getCwd();
Path testFile = cwd.resolve("test.java");
Files.write(testFile, "// Test file".getBytes());
assertThat(Files.isRegularFile(Paths.get(cwd.toString(), Catalog.JBANG_CATALOG_JSON)), is(false));
JBang jbang = new JBang();
new CommandLine(jbang).execute("template", "add", "-f", cwd.toString(), "--name=template-with-single-property", "-d", "Description of the template", "-P", "new-test-key", testFile.toString());
assertThat(Files.isRegularFile(Paths.get(cwd.toString(), Catalog.JBANG_CATALOG_JSON)), is(true));
Template name = Template.get("template-with-single-property");
assertThat(name.properties.entrySet(), hasItems(new AbstractMap.SimpleEntry<>("new-test-key", new TemplateProperty(null, null))));
}
Aggregations