assertEquals("prefix_hello_suffix", template.format(getResolver()));
}
@Test
public void testCond() throws Exception {
NameTemplate template = new NameTemplateParser().parse("${list?yes:no}", defaultValidator());
assertEquals("yes", template.format(getResolver()));
template = new NameTemplateParser().parse("${multiValue?yes:no}", defaultValidator());
assertEquals("no", template.format(getResolver()));
template = new NameTemplateParser().parse("${multiValue?yes}", defaultValidator());
assertEquals("", template.format(getResolver()));
template = new NameTemplateParser().parse("${list?yes}", defaultValidator());
assertEquals("yes", template.format(getResolver()));
// test with disabled validator because we want it to fail @ evaluation time
template = new NameTemplateParser().parse("${var1?yes:no}", disabledValidator());
try {
assertEquals("no", template.format(getResolver()));
fail("Expected exception");
} catch (NameTemplateEvaluationException e) {
// expected
}
// test with disabled validator because we want it to fail @ evaluation time
template = new NameTemplateParser().parse("${nonexisting?yes:no}", disabledValidator());
try {
assertEquals("no", template.format(getResolver()));
fail("Expected exception");
} catch (NameTemplateEvaluationException e) {
// expected