Search in sources :

Example 1 with StringTemplateCompiler

use of org.summerb.utils.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.utils.stringtemplate.impl.StringTemplateCompilerlImpl) StringTemplateCompiler(org.summerb.utils.stringtemplate.api.StringTemplateCompiler) ValidationContext(org.summerb.approaches.validation.ValidationContext) Test(org.junit.Test)

Example 2 with StringTemplateCompiler

use of org.summerb.utils.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.utils.stringtemplate.impl.StringTemplateCompilerlImpl) StringTemplateCompiler(org.summerb.utils.stringtemplate.api.StringTemplateCompiler) ValidationContext(org.summerb.approaches.validation.ValidationContext) Test(org.junit.Test)

Example 3 with StringTemplateCompiler

use of org.summerb.utils.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.utils.stringtemplate.impl.StringTemplateCompilerlImpl) StringTemplateCompiler(org.summerb.utils.stringtemplate.api.StringTemplateCompiler) ValidationContext(org.summerb.approaches.validation.ValidationContext) Test(org.junit.Test)

Aggregations

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