diff --git a/src/main/java/com/hubspot/jinjava/interpret/NullValue.java b/src/main/java/com/hubspot/jinjava/interpret/NullValue.java index 4c6e61e26..ed3d7f0d3 100644 --- a/src/main/java/com/hubspot/jinjava/interpret/NullValue.java +++ b/src/main/java/com/hubspot/jinjava/interpret/NullValue.java @@ -8,7 +8,9 @@ public final class NullValue { public static final NullValue INSTANCE = new NullValue(); - static NullValue instance() { + private NullValue() {} + + public static NullValue instance() { return INSTANCE; } diff --git a/src/test/java/com/hubspot/jinjava/lib/tag/ForTagTest.java b/src/test/java/com/hubspot/jinjava/lib/tag/ForTagTest.java index bc3a7a515..ec36d07f5 100644 --- a/src/test/java/com/hubspot/jinjava/lib/tag/ForTagTest.java +++ b/src/test/java/com/hubspot/jinjava/lib/tag/ForTagTest.java @@ -381,12 +381,13 @@ public void itAllowsCheckingOfWithinForLoop() throws NoSuchMethodException { public void forLoopWithNullValues() { context.put("number", -1); context.put("the_list", Lists.newArrayList(1L, 2L, null, null, null)); - TagNode tagNode = (TagNode) fixture("loop-last-var"); - Document dom = Jsoup.parseBodyFragment(tag.interpret(tagNode, interpreter)); - - assertThat(dom.select("h3")).hasSize(4); - dom.outputSettings().prettyPrint(true).indentAmount(4); - assertThat(dom.html()).contains("seven: null"); + String template = "{% for number in the_list %} {{ number }} {% endfor %}"; + TagNode tagNode = (TagNode) new TreeParser(interpreter, template) + .buildTree() + .getChildren() + .getFirst(); + String result = tag.interpret(tagNode, interpreter); + assertThat(result).isEqualTo(" 1 2 null null null "); } public static boolean inForLoop() {