Skip to content

Instantly share code, notes, and snippets.

@mid0111
Created January 31, 2014 03:46
Show Gist options
  • Save mid0111/8726316 to your computer and use it in GitHub Desktop.
Save mid0111/8726316 to your computer and use it in GitHub Desktop.
assert to nested Map
import org.codehaus.jackson.map.ObjectMapper;
public class QueryMapFactoryTest {
@Test
public void クエリを作成できること() {
Map<String, Object> actual = QueryMapFactoryTest.getQuery();
String expectedStr = "{"
+ " \"query\": {"
+ " \"bool\": {"
+ " \"must\": ["
+ " {"
+ " \"term\": {"
+ " \"l.xxx\": \"xxxx\""
+ " }"
+ " },"
+ " {"
+ " \"term\": {"
+ " \"s.yyy.untouched\": false"
+ " }"
+ " }"
+ " ]"
+ " }"
+ " },"
+ " \"filter\": {"
+ " \"and\": {"
+ " \"filters\": ["
+ " {"
+ " \"term\": {"
+ " \"c\": \"cccc\""
+ " }"
+ " },"
+ " {"
+ " \"term\": {"
+ " \"b\": \"bbbb\""
+ " }"
+ " },"
+ " {"
+ " \"term\": {"
+ " \"a\": \"aaaa\""
+ " }"
+ " },"
+ " {"
+ " \"term\": {"
+ " \"d\": \"dddd\""
+ " }"
+ " }"
+ " ]"
+ " }"
+ " },"
+ " \"size\": 10,"
+ " \"version\": true"
+ "}";
Map<String, Integer> expected = null;
try {
expected = new ObjectMapper().readValue(expectedStr, HashMap.class);
} catch (IOException e) {
fail(e.getMessage());
}
assertEquals(expected, actual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment