Improved robustness of query checking and validation for snapshot schema.
Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/commit/6cff9117 Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/tree/6cff9117 Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/diff/6cff9117 Branch: refs/heads/feature-AppData Commit: 6cff911728b6956e1e4c246aed3fb315707f4032 Parents: 6155673 Author: Timothy Farkas <[email protected]> Authored: Wed Aug 5 14:36:21 2015 -0700 Committer: David Yan <[email protected]> Committed: Fri Aug 28 18:09:31 2015 -0700 ---------------------------------------------------------------------- .../serde/DataQuerySnapshotDeserializer.java | 65 ++++++++-- .../query/serde/DataQuerySnapshotValidator.java | 5 + .../lib/appdata/schemas/DataQuerySnapshot.java | 6 +- .../lib/appdata/schemas/SchemaUtils.java | 70 ++++++----- .../DataQuerySnapshotDeserializerTest.java | 123 ++++++++++++++++--- .../resources/snapshotquery_deserialize1.json | 7 ++ .../resources/snapshotquery_deserialize2.json | 12 ++ .../resources/snapshotquery_deserialize3.json | 4 + .../resources/snapshotquery_deserialize4.json | 13 ++ .../resources/snapshotquery_deserialize5.json | 13 ++ .../resources/snapshotquery_deserialize6.json | 14 +++ .../resources/snapshotquery_deserialize7.json | 15 +++ .../snapshotquery_invalidcountdown.json | 13 ++ .../resources/snapshotquery_validation1.json | 3 + .../resources/snapshotquery_validation2.json | 3 + .../resources/snapshotquery_validation3.json | 6 + 16 files changed, 311 insertions(+), 61 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotDeserializer.java ---------------------------------------------------------------------- diff --git a/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotDeserializer.java b/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotDeserializer.java index bdc761f..9cc080a 100644 --- a/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotDeserializer.java +++ b/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotDeserializer.java @@ -30,8 +30,6 @@ import org.slf4j.LoggerFactory; import com.datatorrent.lib.appdata.schemas.DataQuerySnapshot; import com.datatorrent.lib.appdata.schemas.Fields; import com.datatorrent.lib.appdata.schemas.Message; -import com.datatorrent.lib.appdata.schemas.QRBase; -import com.datatorrent.lib.appdata.schemas.Query; import com.datatorrent.lib.appdata.schemas.SchemaUtils; /** @@ -40,6 +38,41 @@ import com.datatorrent.lib.appdata.schemas.SchemaUtils; */ public class DataQuerySnapshotDeserializer implements CustomMessageDeserializer { + public static final Set<Fields> FIRST_LEVEL_FIELD_COMBINATIONS; + public static final Set<Fields> DATA_FIELD_COMBINATIONS; + + static { + Set<Fields> firstLevelFieldCombinations = Sets.newHashSet(); + firstLevelFieldCombinations.add(new Fields(Sets.newHashSet(DataQuerySnapshot.FIELD_ID, + DataQuerySnapshot.FIELD_TYPE, + DataQuerySnapshot.FIELD_COUNTDOWN, + DataQuerySnapshot.FIELD_DATA, + DataQuerySnapshot.FIELD_INCOMPLETE_RESULTS_OK))); + firstLevelFieldCombinations.add(new Fields(Sets.newHashSet(DataQuerySnapshot.FIELD_ID, + DataQuerySnapshot.FIELD_TYPE, + DataQuerySnapshot.FIELD_DATA, + DataQuerySnapshot.FIELD_INCOMPLETE_RESULTS_OK))); + firstLevelFieldCombinations.add(new Fields(Sets.newHashSet(DataQuerySnapshot.FIELD_ID, + DataQuerySnapshot.FIELD_TYPE, + DataQuerySnapshot.FIELD_COUNTDOWN, + DataQuerySnapshot.FIELD_DATA))); + firstLevelFieldCombinations.add(new Fields(Sets.newHashSet(DataQuerySnapshot.FIELD_ID, + DataQuerySnapshot.FIELD_TYPE, + DataQuerySnapshot.FIELD_DATA))); + firstLevelFieldCombinations.add(new Fields(Sets.newHashSet(DataQuerySnapshot.FIELD_ID, + DataQuerySnapshot.FIELD_TYPE))); + + FIRST_LEVEL_FIELD_COMBINATIONS = firstLevelFieldCombinations; + + Set<Fields> dataFieldCombinations = Sets.newHashSet(); + dataFieldCombinations.add(new Fields(Sets.newHashSet(DataQuerySnapshot.FIELD_SCHEMA_KEYS, + DataQuerySnapshot.FIELD_FIELDS))); + dataFieldCombinations.add(new Fields(Sets.newHashSet(DataQuerySnapshot.FIELD_SCHEMA_KEYS))); + dataFieldCombinations.add(new Fields(Sets.newHashSet(DataQuerySnapshot.FIELD_FIELDS))); + + DATA_FIELD_COMBINATIONS = dataFieldCombinations; + } + /** * Constructor used to instantiate deserializer in {@link MessageDeserializerFactory}. */ @@ -57,7 +90,11 @@ public class DataQuerySnapshotDeserializer implements CustomMessageDeserializer context); } catch(Exception ex) { - throw new IOException(ex); + if (ex instanceof IOException) { + throw (IOException) ex; + } else { + throw new IOException(ex); + } } } @@ -74,9 +111,14 @@ public class DataQuerySnapshotDeserializer implements CustomMessageDeserializer { JSONObject jo = new JSONObject(json); + //Validate fields + if (!SchemaUtils.checkValidKeys(jo, FIRST_LEVEL_FIELD_COMBINATIONS)) { + throw new IOException("Invalid keys"); + } + //// Query id stuff - String id = jo.getString(QRBase.FIELD_ID); - String type = jo.getString(Message.FIELD_TYPE); + String id = jo.getString(DataQuerySnapshot.FIELD_ID); + String type = jo.getString(DataQuerySnapshot.FIELD_TYPE); if(!type.equals(DataQuerySnapshot.TYPE)) { LOG.error("Found type {} in the query json, but expected type {}.", type, DataQuerySnapshot.TYPE); @@ -85,10 +127,10 @@ public class DataQuerySnapshotDeserializer implements CustomMessageDeserializer /// Countdown long countdown = -1L; - boolean hasCountdown = jo.has(QRBase.FIELD_COUNTDOWN); + boolean hasCountdown = jo.has(DataQuerySnapshot.FIELD_COUNTDOWN); if(hasCountdown) { - countdown = jo.getLong(QRBase.FIELD_COUNTDOWN); + countdown = jo.getLong(DataQuerySnapshot.FIELD_COUNTDOWN); } ////Data @@ -98,8 +140,13 @@ public class DataQuerySnapshotDeserializer implements CustomMessageDeserializer if(jo.has(DataQuerySnapshot.FIELD_DATA)) { JSONObject data = jo.getJSONObject(DataQuerySnapshot.FIELD_DATA); - if(data.has(Query.FIELD_SCHEMA_KEYS)) { - schemaKeys = SchemaUtils.extractMap(data.getJSONObject(Query.FIELD_SCHEMA_KEYS)); + if (!SchemaUtils.checkValidKeys(data, DATA_FIELD_COMBINATIONS)) { + LOG.error("Error validating {} field", DataQuerySnapshot.FIELD_DATA); + throw new IOException("Invalid keys"); + } + + if (data.has(DataQuerySnapshot.FIELD_SCHEMA_KEYS)) { + schemaKeys = SchemaUtils.extractMap(data.getJSONObject(DataQuerySnapshot.FIELD_SCHEMA_KEYS)); } if(data.has(DataQuerySnapshot.FIELD_FIELDS)) { http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotValidator.java ---------------------------------------------------------------------- diff --git a/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotValidator.java b/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotValidator.java index d13dcc4..d2b7ef0 100644 --- a/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotValidator.java +++ b/library/src/main/java/com/datatorrent/lib/appdata/query/serde/DataQuerySnapshotValidator.java @@ -21,6 +21,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.datatorrent.lib.appdata.schemas.DataQuerySnapshot; +import com.datatorrent.lib.appdata.schemas.Fields; import com.datatorrent.lib.appdata.schemas.Message; import com.datatorrent.lib.appdata.schemas.SchemaRegistry; import com.datatorrent.lib.appdata.schemas.SnapshotSchema; @@ -53,6 +54,10 @@ public class DataQuerySnapshotValidator implements CustomMessageValidator return false; } + if (gdqt.getFields().getFields().isEmpty()) { + gdqt.setFields(new Fields(fields)); + } + return true; } http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/main/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshot.java ---------------------------------------------------------------------- diff --git a/library/src/main/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshot.java b/library/src/main/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshot.java index 0943172..5714597 100644 --- a/library/src/main/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshot.java +++ b/library/src/main/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshot.java @@ -51,6 +51,10 @@ public class DataQuerySnapshot extends Query * The JSON string for the schemaKeys in the query. */ public static final String SCHEMA_KEYS = "schemaKeys"; + /** + * The JSON string for the incompleteResultOK field in the query. + */ + public static final String FIELD_INCOMPLETE_RESULTS_OK = "incompleteResultOK"; /** * The fields requested to be returned in the query. @@ -132,7 +136,7 @@ public class DataQuerySnapshot extends Query * Sets the fields of the query. * @param fields The fields of the query. */ - private void setFields(Fields fields) + public final void setFields(Fields fields) { Preconditions.checkNotNull(fields); this.fields = fields; http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/main/java/com/datatorrent/lib/appdata/schemas/SchemaUtils.java ---------------------------------------------------------------------- diff --git a/library/src/main/java/com/datatorrent/lib/appdata/schemas/SchemaUtils.java b/library/src/main/java/com/datatorrent/lib/appdata/schemas/SchemaUtils.java index dbd276c..ce68c7f 100644 --- a/library/src/main/java/com/datatorrent/lib/appdata/schemas/SchemaUtils.java +++ b/library/src/main/java/com/datatorrent/lib/appdata/schemas/SchemaUtils.java @@ -19,8 +19,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.util.Collection; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Set; @@ -100,18 +100,10 @@ public class SchemaUtils Fields fields) { @SuppressWarnings("unchecked") - Iterator<String> keyIterator = jo.keys(); Set<String> fieldSet = fields.getFields(); + Set<String> jsonKeys = getSetOfJSONKeys(jo); - while(keyIterator.hasNext()) { - String key = keyIterator.next(); - - if(!fieldSet.contains(key)) { - return false; - } - } - - return true; + return jsonKeys.containsAll(fieldSet); } /** @@ -124,34 +116,38 @@ public class SchemaUtils Fields fields) { @SuppressWarnings("unchecked") - Iterator<String> keyIterator = jo.keys(); Set<String> fieldSet = fields.getFields(); + Set<String> jsonKeys = getSetOfJSONKeys(jo); - while(keyIterator.hasNext()) { - String key = keyIterator.next(); + if (!jsonKeys.containsAll(fieldSet)) { - if(!fieldSet.contains(key)) { - throw new IllegalArgumentException("The key " + key + - " is not valid."); - } + throw new IllegalArgumentException("The given set of keys " + + fieldSet + + " doesn't equal the set of keys in the json " + + jsonKeys); } } /** * This is a utility method to check that the given JSONObject has the given keys. * @param jo The {@link JSONObject} to check. - * @param fieldsList The keys in the {@link JSONObject} to check. + * @param fieldsCollection The keys in the {@link JSONObject} to check. * @return True if the given {@link JSONObject} contains all the given keys. False otherwise. */ public static boolean checkValidKeys(JSONObject jo, - List<Fields> fieldsList) + Collection<Fields> fieldsCollection) { - for(Fields fields: fieldsList) { - if(checkValidKeys(jo, fields)) { + for (Fields fields: fieldsCollection) { + LOG.debug("Checking keys: {}", fields); + if (checkValidKeys(jo, fields)) { return true; } } + LOG.error("The first level of keys in the provided JSON {} do not match any of the " + + "valid keysets {}", + getSetOfJSONKeys(jo), + fieldsCollection); return false; } @@ -159,31 +155,37 @@ public class SchemaUtils * This is a utility method to check that the given JSONObject has the given keys. * It throws an {@link IllegalArgumentException} if it doesn't contain all the given keys. * @param jo The {@link JSONObject} to check. - * @param fieldsList The keys in the {@link JSONObject} to check. + * @param fieldsCollection The keys in the {@link JSONObject} to check. * @return True if the given {@link JSONObject} contains all the given keys. False otherwise. */ public static boolean checkValidKeysEx(JSONObject jo, - List<Fields> fieldsList) + Collection<Fields> fieldsCollection) { - for(Fields fields: fieldsList) { - if(checkValidKeys(jo, fields)) { + for (Fields fields: fieldsCollection) { + if (checkValidKeys(jo, fields)) { return true; } } - Set<String> keys = Sets.newHashSet(); + Set<String> keys = getSetOfJSONKeys(jo); + + throw new IllegalArgumentException("The given json object has an invalid set of keys: " + + keys + + "\nOne of the following key combinations was expected:\n" + + fieldsCollection); + } + + public static Set<String> getSetOfJSONKeys(JSONObject jo) + { @SuppressWarnings("unchecked") Iterator<String> keyIterator = jo.keys(); + Set<String> keySet = Sets.newHashSet(); - while(keyIterator.hasNext()) { - String key = keyIterator.next(); - keys.add(key); + while (keyIterator.hasNext()) { + keySet.add(keyIterator.next()); } - throw new IllegalArgumentException("The given json object has an invalid set of keys: " + - keys + - "\nOne of the following key combinations was expected:\n" + - fieldsList); + return keySet; } public static Map<String, String> convertFieldToType(Map<String, Type> fieldToType) http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotDeserializerTest.java ---------------------------------------------------------------------- diff --git a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotDeserializerTest.java b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotDeserializerTest.java index a79cd63..f267571 100644 --- a/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotDeserializerTest.java +++ b/library/src/test/java/com/datatorrent/lib/appdata/schemas/DataQuerySnapshotDeserializerTest.java @@ -15,30 +15,48 @@ */ package com.datatorrent.lib.appdata.schemas; +import java.io.IOException; + import java.util.Map; +import java.util.Set; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestWatcher; import com.datatorrent.lib.appdata.query.serde.DataQuerySnapshotDeserializer; +import com.datatorrent.lib.appdata.query.serde.MessageDeserializerFactory; public class DataQuerySnapshotDeserializerTest { + @Rule + public DataQuerySnapshotInfo testMeta = new DataQuerySnapshotInfo(); + + public static class DataQuerySnapshotInfo extends TestWatcher + { + public MessageDeserializerFactory queryDeserializerFactory; + + @Override + protected void starting(org.junit.runner.Description description) + { + String snapshotSchemaJSON = SchemaUtils.jarResourceFileToString("snapshotschema.json"); + SchemaRegistrySingle schemaRegistry = new SchemaRegistrySingle(new SnapshotSchema(snapshotSchemaJSON)); + queryDeserializerFactory = new MessageDeserializerFactory(SchemaQuery.class, + DataQuerySnapshot.class); + queryDeserializerFactory.setContext(DataQuerySnapshot.class, schemaRegistry); + } + } + @Test public void simpleDeserializerTest() throws Exception { DataQuerySnapshotDeserializer deserializer = new DataQuerySnapshotDeserializer(); - String queryJSON = "{\n" - + " \"id\": \"1\",\n" - + " \"type\": \"dataQuery\",\n" - + " \"data\": {\n" - + " \"fields\": [ \"url\", \"count\" ]\n" - + " }\n" - + "}"; + String queryJSON = SchemaUtils.jarResourceFileToString("snapshotquery_deserialize1.json"); DataQuerySnapshot gQuery = (DataQuerySnapshot) deserializer.deserialize(queryJSON, DataQuerySnapshot.class, null); @@ -50,7 +68,6 @@ public class DataQuerySnapshotDeserializerTest Assert.assertEquals("The fields must equal.", fields, gQuery.getFields()); } - @Test public void simpleDeserializerWithSchemaKeysTest() throws Exception { @@ -61,15 +78,7 @@ public class DataQuerySnapshotDeserializerTest DataQuerySnapshotDeserializer deserializer = new DataQuerySnapshotDeserializer(); - String queryJSON = "{\n" - + " \"id\": \"1\",\n" - + " \"type\": \"dataQuery\",\n" - + " \"data\": {\n" - + " \"schemaKeys\":" - + " {\"publisher\":\"google\",\"advertiser\":\"microsoft\",\"location\":\"CA\"}," - + " \"fields\": [ \"url\", \"count\" ]\n" - + " }\n" - + "}"; + String queryJSON = SchemaUtils.jarResourceFileToString("snapshotquery_deserialize2.json"); DataQuerySnapshot gQuery = (DataQuerySnapshot) deserializer.deserialize(queryJSON, DataQuerySnapshot.class, null); @@ -81,4 +90,84 @@ public class DataQuerySnapshotDeserializerTest Assert.assertEquals("The fields must equal.", fields, gQuery.getFields()); Assert.assertEquals(expectedSchemaKeys, gQuery.getSchemaKeys()); } + + @Test + public void noFieldsSpecified() throws Exception + { + String snapshotQuery = SchemaUtils.jarResourceFileToString("snapshotquery_deserialize3.json"); + DataQuerySnapshot query = (DataQuerySnapshot) testMeta.queryDeserializerFactory.deserialize(snapshotQuery); + + Set<String> expectedFields = Sets.newHashSet("boolField", "intField", "doubleField"); + + Assert.assertEquals(expectedFields, query.getFields().getFields()); + } + + @Test + public void validDeserialize1Test() throws Exception + { + testValid("snapshotquery_deserialize4.json"); + } + + @Test + public void validDeserialize2Test() throws Exception + { + testValid("snapshotquery_deserialize5.json"); + } + + @Test + public void validDeserialize3Test() throws Exception + { + testValid("snapshotquery_deserialize6.json"); + } + + @Test + public void validDeserializeExtraFieldTest() throws Exception + { + testValid("snapshotquery_deserialize7.json"); + } + + @Test + public void invalidTestCountdownValue() throws Exception + { + testInvalid("snapshotquery_invalidcountdown.json"); + } + + @Test + public void invalidTest1() throws Exception + { + testInvalid("snapshotquery_validation1.json"); + } + + @Test + public void invalidTest2() throws Exception + { + testInvalid("snapshotquery_validation2.json"); + } + + @Test + public void invalidTest3() throws Exception + { + testInvalid("snapshotquery_validation3.json"); + } + + private void testInvalid(String invalidResourceJSON) throws Exception + { + boolean caughtException = false; + + try { + String snapshotQuery = SchemaUtils.jarResourceFileToString(invalidResourceJSON); + testMeta.queryDeserializerFactory.deserialize(snapshotQuery); + } catch (IOException e) { + caughtException = true; + } + + Assert.assertTrue(caughtException); + } + + private void testValid(String validResourceJSON) throws Exception + { + String snapshotQuery = SchemaUtils.jarResourceFileToString(validResourceJSON); + DataQuerySnapshot query = (DataQuerySnapshot) testMeta.queryDeserializerFactory.deserialize(snapshotQuery); + Assert.assertNotNull(query); + } } http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_deserialize1.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_deserialize1.json b/library/src/test/resources/snapshotquery_deserialize1.json new file mode 100644 index 0000000..13c80ac --- /dev/null +++ b/library/src/test/resources/snapshotquery_deserialize1.json @@ -0,0 +1,7 @@ +{ +"id": 1, +"type": "dataQuery", +"data": { + "fields": ["url", "count"] + } +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_deserialize2.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_deserialize2.json b/library/src/test/resources/snapshotquery_deserialize2.json new file mode 100644 index 0000000..8ebc168 --- /dev/null +++ b/library/src/test/resources/snapshotquery_deserialize2.json @@ -0,0 +1,12 @@ +{ + "id":1, + "type": "dataQuery", + "data": { + "schemaKeys": { + "publisher":"google", + "advertiser":"microsoft", + "location":"CA" + }, + "fields": ["url", "count"] + } +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_deserialize3.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_deserialize3.json b/library/src/test/resources/snapshotquery_deserialize3.json new file mode 100644 index 0000000..2d706af --- /dev/null +++ b/library/src/test/resources/snapshotquery_deserialize3.json @@ -0,0 +1,4 @@ +{ +"id": 1, +"type": "dataQuery" +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_deserialize4.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_deserialize4.json b/library/src/test/resources/snapshotquery_deserialize4.json new file mode 100644 index 0000000..3a150cf --- /dev/null +++ b/library/src/test/resources/snapshotquery_deserialize4.json @@ -0,0 +1,13 @@ +{ + "id":1, + "type": "dataQuery", + "data": { + "schemaKeys": { + "publisher":"google", + "advertiser":"microsoft", + "location":"CA" + }, + "fields": ["boolField", "doubleField"] + }, + "countdown":10 +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_deserialize5.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_deserialize5.json b/library/src/test/resources/snapshotquery_deserialize5.json new file mode 100644 index 0000000..e4907ad --- /dev/null +++ b/library/src/test/resources/snapshotquery_deserialize5.json @@ -0,0 +1,13 @@ +{ + "id":1, + "type": "dataQuery", + "data": { + "schemaKeys": { + "publisher":"google", + "advertiser":"microsoft", + "location":"CA" + }, + "fields": ["boolField", "doubleField"] + }, + "incompleteResultOK":true +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_deserialize6.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_deserialize6.json b/library/src/test/resources/snapshotquery_deserialize6.json new file mode 100644 index 0000000..abeddf4 --- /dev/null +++ b/library/src/test/resources/snapshotquery_deserialize6.json @@ -0,0 +1,14 @@ +{ + "id":1, + "type": "dataQuery", + "data": { + "schemaKeys": { + "publisher":"google", + "advertiser":"microsoft", + "location":"CA" + }, + "fields": ["boolField", "doubleField"] + }, + "incompleteResultOK":true, + "countdown":10 +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_deserialize7.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_deserialize7.json b/library/src/test/resources/snapshotquery_deserialize7.json new file mode 100644 index 0000000..3347b3c --- /dev/null +++ b/library/src/test/resources/snapshotquery_deserialize7.json @@ -0,0 +1,15 @@ +{ + "id":1, + "type": "dataQuery", + "data": { + "schemaKeys": { + "publisher":"google", + "advertiser":"microsoft", + "location":"CA" + }, + "fields": ["boolField", "doubleField"] + }, + "incompleteResultOK":true, + "countdown":10, + "blahblahblahinvalid":"a" +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_invalidcountdown.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_invalidcountdown.json b/library/src/test/resources/snapshotquery_invalidcountdown.json new file mode 100644 index 0000000..8551c83 --- /dev/null +++ b/library/src/test/resources/snapshotquery_invalidcountdown.json @@ -0,0 +1,13 @@ +{ + "id":1, + "type": "dataQuery", + "countdown":-10, + "data": { + "schemaKeys": { + "publisher":"google", + "advertiser":"microsoft", + "location":"CA" + }, + "fields": ["url", "count"] + } +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_validation1.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_validation1.json b/library/src/test/resources/snapshotquery_validation1.json new file mode 100644 index 0000000..2572ae5 --- /dev/null +++ b/library/src/test/resources/snapshotquery_validation1.json @@ -0,0 +1,3 @@ +{ + "id": 1 +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_validation2.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_validation2.json b/library/src/test/resources/snapshotquery_validation2.json new file mode 100644 index 0000000..40fe011 --- /dev/null +++ b/library/src/test/resources/snapshotquery_validation2.json @@ -0,0 +1,3 @@ +{ + "type": "dataQuery" +} http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/6cff9117/library/src/test/resources/snapshotquery_validation3.json ---------------------------------------------------------------------- diff --git a/library/src/test/resources/snapshotquery_validation3.json b/library/src/test/resources/snapshotquery_validation3.json new file mode 100644 index 0000000..e5aaad0 --- /dev/null +++ b/library/src/test/resources/snapshotquery_validation3.json @@ -0,0 +1,6 @@ +{ + "id": 1, + "type": "dataQuery", + "data": { + } +}
