SchemaQuery extends Query { public Map<String, String> getContextKeys() { return contextKeys; } SchemaQuery();  SchemaQuery(String id);  SchemaQuery(String id, Map<String, String> schemaKeys);  SchemaQuery(String id, Map<String, String> schemaKeys, Map<String, String> contextKeys); Map<String, String> getContextKeys(); void setContextKeys(Map<String, String> contextKeys); static final String FIELD_CONTEXT; static final String FIELD_CONTEXT_KEYS; static final String TYPE; }
@Test public void jsonToSchemaWithKeysAndSchemaKeys() throws Exception { final Map<String, String> expectedSchemaKeys = Maps.newHashMap(); expectedSchemaKeys.put("publisher", "google"); expectedSchemaKeys.put("advertiser", "microsoft"); expectedSchemaKeys.put("location", "CA"); final Map<String, String> expectedKeys = Maps.newHashMap(); expectedKeys.put("publisher", "google"); expectedKeys.put("advertiser", "microsoft"); final String id = "12345"; final String schemaQueryJSON = "{" + "\"id\":\"" + id + "\"," + "\"type\":\"" + SchemaQuery.TYPE + "\"," + "\"context\":{" + "\"schemaKeys\":" + "{\"publisher\":\"google\",\"advertiser\":\"microsoft\",\"location\":\"CA\"}," + "\"keys\":{\"publisher\":\"google\",\"advertiser\":\"microsoft\"}" + "}}"; @SuppressWarnings("unchecked") MessageDeserializerFactory qb = new MessageDeserializerFactory(SchemaQuery.class); SchemaQuery schemaQuery = (SchemaQuery)qb.deserialize(schemaQueryJSON); Assert.assertEquals("Id's must match", id, schemaQuery.getId()); Assert.assertEquals("Types must match", SchemaQuery.TYPE, schemaQuery.getType()); Assert.assertEquals("Schema keys must match", expectedSchemaKeys, schemaQuery.getSchemaKeys()); Assert.assertEquals("Expected keys must match", expectedKeys, schemaQuery.getContextKeys()); }