Search in sources :

Example 1 with CodeExecuteException

use of com.squarespace.template.CodeExecuteException in project template-compiler by Squarespace.

the class CoreFormattersTest method testApplyPartialMissing.

@Test
public void testApplyPartialMissing() throws CodeException {
    String template = "{@|apply foo}";
    String partials = "{\"block\": \"hello\"}";
    String input = "{}";
    Instruction inst = compiler().compile(template).code();
    Context ctx = new Context(JsonUtils.decode(input));
    ctx.setCompiler(compiler());
    ctx.setPartials(JsonUtils.decode(partials));
    try {
        ctx.execute(inst);
        fail("Expected exception");
    } catch (CodeExecuteException e) {
        assertEquals(e.getErrorInfo().getType(), APPLY_PARTIAL_MISSING);
    }
}
Also used : Context(com.squarespace.template.Context) CodeExecuteException(com.squarespace.template.CodeExecuteException) Instruction(com.squarespace.template.Instruction) Test(org.testng.annotations.Test)

Aggregations

CodeExecuteException (com.squarespace.template.CodeExecuteException)1 Context (com.squarespace.template.Context)1 Instruction (com.squarespace.template.Instruction)1 Test (org.testng.annotations.Test)1