mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[jinja] disable failOnUnknownTokens (#16347)
Home Assistant doesn't enable strict mode, so we shouldn't either Signed-off-by: Cody Cutrer <cody@cutrer.us> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
1e35a90c09
commit
2c5d803489
@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.hubspot.jinjava.Jinjava;
|
||||
import com.hubspot.jinjava.JinjavaConfig;
|
||||
import com.hubspot.jinjava.interpret.FatalTemplateErrorsException;
|
||||
|
||||
/**
|
||||
@ -47,8 +46,7 @@ public class JinjaTransformationService implements TransformationService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(JinjaTransformationService.class);
|
||||
|
||||
private final JinjavaConfig config = JinjavaConfig.newBuilder().withFailOnUnknownTokens(true).build();
|
||||
private final Jinjava jinjava = new Jinjava(config);
|
||||
private final Jinjava jinjava = new Jinjava();
|
||||
|
||||
/**
|
||||
* Transforms the input <code>value</code> by Jinja template.
|
||||
|
@ -76,15 +76,13 @@ public class JinjaTransformationServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingVariableError() {
|
||||
assertThrows(TransformationException.class,
|
||||
() -> processor.transform("Hello {{ missing }}!", "{\"string\": \"world\"}"));
|
||||
public void testMissingVariableError() throws TransformationException {
|
||||
assertEquals("Hello !", processor.transform("Hello {{ missing }}!", "{\"string\": \"world\"}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingMapKeyError() {
|
||||
assertThrows(TransformationException.class,
|
||||
() -> processor.transform("Hello {{ value_json.missing }}!", "{\"string\": \"world\"}"));
|
||||
public void testMissingMapKeyError() throws TransformationException {
|
||||
assertEquals("Hello !", processor.transform("Hello {{ value_json.missing }}!", "{\"string\": \"world\"}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user