Search in sources :

Example 1 with StringTemplateCompiler

use of org.summerb.stringtemplate.api.StringTemplateCompiler in project summerb by skarpushin.

the class StringTemplateValidationUtilsTest method testValidateStringTemplate_blackbox_expectOkForValidExpression.

@Test
public void testValidateStringTemplate_blackbox_expectOkForValidExpression() throws Exception {
    StringTemplateCompiler stringTemplateCompiler = new StringTemplateCompilerlImpl();
    String stringTemplate = "Constant text plus ${vars['4444']}";
    ValidationContext ctx = new ValidationContext();
    String fieldToken = "fieldToken";
    StringTemplateValidationUtils.validateStringTemplate(stringTemplateCompiler, stringTemplate, ctx, fieldToken);
    assertEquals(false, ctx.getHasErrors());
}
Also used : StringTemplateCompilerlImpl(org.summerb.stringtemplate.impl.StringTemplateCompilerlImpl) StringTemplateCompiler(org.summerb.stringtemplate.api.StringTemplateCompiler) ValidationContext(org.summerb.validation.ValidationContext) Test(org.junit.Test)

Example 2 with StringTemplateCompiler

use of org.summerb.stringtemplate.api.StringTemplateCompiler in project summerb by skarpushin.

the class StringTemplateValidationUtilsTest method testValidateStringTemplate_blackbox_expectValidationErrorForWrongExpression.

@Test
public void testValidateStringTemplate_blackbox_expectValidationErrorForWrongExpression() throws Exception {
    StringTemplateCompiler stringTemplateCompiler = new StringTemplateCompilerlImpl();
    String stringTemplate = "Constant text plus ${vars['4444";
    ValidationContext ctx = new ValidationContext();
    String fieldToken = "fieldToken";
    StringTemplateValidationUtils.validateStringTemplate(stringTemplateCompiler, stringTemplate, ctx, fieldToken);
    assertEquals(true, ctx.getHasErrors());
}
Also used : StringTemplateCompilerlImpl(org.summerb.stringtemplate.impl.StringTemplateCompilerlImpl) StringTemplateCompiler(org.summerb.stringtemplate.api.StringTemplateCompiler) ValidationContext(org.summerb.validation.ValidationContext) Test(org.junit.Test)

Example 3 with StringTemplateCompiler

use of org.summerb.stringtemplate.api.StringTemplateCompiler in project summerb by skarpushin.

the class StringTemplateValidationUtilsTest method testValidateStringTemplate_blackbox_expectOkForConstant.

@Test
public void testValidateStringTemplate_blackbox_expectOkForConstant() throws Exception {
    StringTemplateCompiler stringTemplateCompiler = new StringTemplateCompilerlImpl();
    String stringTemplate = "Constant text";
    ValidationContext ctx = new ValidationContext();
    String fieldToken = "fieldToken";
    StringTemplateValidationUtils.validateStringTemplate(stringTemplateCompiler, stringTemplate, ctx, fieldToken);
    assertEquals(false, ctx.getHasErrors());
}
Also used : StringTemplateCompilerlImpl(org.summerb.stringtemplate.impl.StringTemplateCompilerlImpl) StringTemplateCompiler(org.summerb.stringtemplate.api.StringTemplateCompiler) ValidationContext(org.summerb.validation.ValidationContext) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 StringTemplateCompiler (org.summerb.stringtemplate.api.StringTemplateCompiler)3 StringTemplateCompilerlImpl (org.summerb.stringtemplate.impl.StringTemplateCompilerlImpl)3 ValidationContext (org.summerb.validation.ValidationContext)3