Skip to content

Commit 29f6296

Browse files
committed
tests: get back some tests we removed while migrating to Java 11
1 parent e46ba8d commit 29f6296

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

handlebars/src/test/java/com/github/jknack/handlebars/EachKeyTest.java

+16-12
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
import java.io.IOException;
2323
import java.util.LinkedHashMap;
2424
import java.util.Map;
25+
import java.util.Set;
26+
import java.util.stream.Collectors;
27+
import java.util.stream.Stream;
2528

26-
import org.junit.Ignore;
29+
import org.apache.commons.lang3.StringUtils;
2730
import org.junit.Test;
2831

2932
import com.github.jknack.handlebars.context.JavaBeanValueResolver;
@@ -57,28 +60,29 @@ public String getBody() {
5760
.build();
5861
}
5962

60-
@Ignore
63+
@Test
6164
public void eachKeyWithString() throws IOException {
62-
String result = compile("{{#each this}}{{@key}} {{/each}}").apply("String");
65+
Set<String> result = Stream.of(StringUtils.split(
66+
compile("{{#each this}}{{@key}} {{/each}}").apply(configureContext("String")), " "))
67+
.collect(Collectors.toSet());
6368

64-
String expected1 = "empty bytes ";
65-
String expected2 = "bytes empty ";
66-
assertTrue(result.equals(expected1) || result.equals(expected2));
69+
Set<String> expected = Stream.of("empty", "bytes").collect(Collectors.toSet());
70+
assertTrue(result.containsAll(expected));
6771
}
6872

69-
@Ignore
73+
@Test
7074
public void eachKeyWithInt() throws IOException {
71-
shouldCompileTo("{{#each this}}{{@key}} {{/each}}", 7, "");
75+
shouldCompileTo("{{#each this}}{{@key}} {{/each}}", configureContext(7), "");
7276
}
7377

7478
@Test
7579
public void eachKeyWithJavaBean() throws IOException {
7680
Blog blog = new Blog("Handlebars.java", "...");
77-
String result = compile("{{#each this}}{{@key}}: {{this}} {{/each}}").apply(configureContext(blog));
81+
Set<String> result = Stream.of(StringUtils.split(compile("{{#each this}}{{@key}}:{{this}} {{/each}}").apply(configureContext(blog)), " ")).collect(
82+
Collectors.toSet());
7883

79-
String expected1 = "body: ... title: Handlebars.java ";
80-
String expected2 = "title: Handlebars.java body: ... ";
81-
assertTrue(result.equals(expected1) || result.equals(expected2));
84+
Set<String> expected = Stream.of("body:...", "title:Handlebars.java").collect(Collectors.toSet());
85+
assertTrue(result.containsAll(expected));
8286
}
8387

8488
@Test

0 commit comments

Comments
 (0)