Skip to content

Commit 927c227

Browse files
authored
added capture keyset tests (thekrakken#115)
1 parent 8a0a316 commit 927c227

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/test/java/io/krakens/grok/api/GrokDocumentationTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package io.krakens.grok.api;
22

3+
import java.util.HashSet;
34
import java.util.Map;
45

56
import org.assertj.core.api.Assertions;
67
import org.junit.Test;
8+
import static org.hamcrest.Matchers.containsInAnyOrder;
9+
import static org.hamcrest.Matchers.hasItem;
10+
import static org.junit.Assert.*;
11+
12+
import org.assertj.core.util.Arrays;
713

814
public class GrokDocumentationTest {
915

@@ -27,5 +33,23 @@ public void assureCodeInReadmeWorks() {
2733
final Map<String, Object> capture = gm.capture();
2834

2935
Assertions.assertThat(capture).hasSize(22);
36+
final boolean debug = false;
37+
final Object[] keywordArray = new Object[] { "COMBINEDAPACHELOG",
38+
"COMMONAPACHELOG", "clientip", "ident", "auth", "timestamp", "MONTHDAY",
39+
"MONTH", "YEAR", "TIME", "HOUR", "MINUTE", "SECOND", "INT", "verb",
40+
"httpversion", "rawrequest", "request", "response", "bytes", "referrer",
41+
"agent" };
42+
if (debug)
43+
capture.keySet().stream().forEach(System.err::println);
44+
assertTrue(new HashSet<Object>(Arrays.asList(keywordArray))
45+
.containsAll(new HashSet<Object>(capture.keySet())));
46+
47+
Arrays.asList(keywordArray).stream()
48+
.forEach(o -> assertThat(capture.keySet(), hasItem((String) o)));
49+
assertThat(new HashSet<Object>(capture.keySet()),
50+
containsInAnyOrder(keywordArray));
51+
assertTrue(new HashSet<Object>(capture.keySet())
52+
.containsAll(new HashSet<Object>(Arrays.asList(keywordArray))));
53+
3054
}
3155
}

0 commit comments

Comments
 (0)