summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-05-10 11:02:07 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-05-10 11:02:07 +0200
commit670fc2a89d65d9855d50a62f87c1cc061b280215 (patch)
treea543eba5dc663f6e580c4eeafabff5a9ee7c2ae3 /test
parent651e477d0da9f74f3e2193de6827c9ff9d098564 (diff)
downloadDatafiller-670fc2a89d65d9855d50a62f87c1cc061b280215.tar.gz
Coordinates is an object with an array
Ensure that the array is of a fixed length, add tests to check for that.
Diffstat (limited to 'test')
-rw-r--r--test/data/ValidatingJsonDeserializerTest.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/data/ValidatingJsonDeserializerTest.java b/test/data/ValidatingJsonDeserializerTest.java
index 85f1661..b51631a 100644
--- a/test/data/ValidatingJsonDeserializerTest.java
+++ b/test/data/ValidatingJsonDeserializerTest.java
@@ -362,7 +362,7 @@ public class ValidatingJsonDeserializerTest {
tweet.addProperty("created_at", "X");
tweet.addProperty("favorite_count", 4);
tweet.add("place", JsonNull.INSTANCE);
- tweet.addProperty("coordinates", "X");
+ tweet.add("coordinates", JsonNull.INSTANCE);
tweet.addProperty("text", "X");
tweet.add("retweeted_status", JsonNull.INSTANCE); // Tweet object
JsonObject entities = new JsonObject();
@@ -469,6 +469,32 @@ public class ValidatingJsonDeserializerTest {
}
@Test
+ public void testTweetCoordinates() {
+ JsonObject tweet = buildMinimalTweet(buildMinimalUser());
+ addProperty(tweet, new JsonPrimitive("X"), "coordinates");
+ checkTweetFail(tweet, "Expected object: coordinates");
+
+ JsonObject coords = new JsonObject();
+ // overwrite coordinates with object
+ addProperty(tweet, coords, "coordinates");
+ checkTweetFail(tweet, "Missing field: coordinates.coordinates");
+
+ // set coordinates.coordinates
+ JsonArray coordsFloat = new JsonArray();
+ coords.add("coordinates", coordsFloat);
+ checkTweetFail(tweet, "Array smaller than 2: coordinates.coordinates");
+
+ coordsFloat.add(new JsonPrimitive(1.0f));
+ checkTweetFail(tweet, "Array smaller than 2: coordinates.coordinates");
+
+ coordsFloat.add(new JsonPrimitive(1.0f));
+ checkTweetPass(tweet);
+
+ coordsFloat.add(new JsonPrimitive(1.0f));
+ checkTweetFail(tweet, "Array larger than 2: coordinates.coordinates");
+ }
+
+ @Test
public void testTweetEntities() {
checkImpairedTweet("entities");
checkImpairedTweet("entities", "hashtags");