usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdun...@apache.org
Subject [09/44] usergrid git commit: removing noop exceptions, removing failures due to bad location fields
Date Sat, 26 Sep 2015 01:42:14 GMT
removing noop exceptions, removing failures due to bad location fields


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/58f7402d
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/58f7402d
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/58f7402d

Branch: refs/heads/USERGRID-933
Commit: 58f7402db5686ada9174b301ebeebb09a55ceb29
Parents: c3c71c9
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Fri Sep 11 17:17:02 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Fri Sep 11 17:17:02 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityMapUtilsTest.java   | 51 ++++++++++++++++++--
 1 file changed, 47 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/58f7402d/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
index 5dd8f3a..6e4e9a4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
@@ -21,20 +21,21 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import junit.framework.Assert;
 import org.apache.usergrid.corepersistence.util.CpEntityMapUtils;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
 import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.LocationField;
+import org.apache.usergrid.persistence.model.field.StringField;
 import org.apache.usergrid.persistence.model.field.value.EntityObject;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -100,6 +101,48 @@ public class CpEntityMapUtilsTest {
     }
 
 
+    @Test
+    public void testLocation() {
+
+        /*** This tests example property input of
+
+         {
+         "nestedarray" : [ [ "fred" ] ]
+         }
+
+         ****/
+        Map<String, Object> locMap = new HashMap<>();
+        locMap.put("latitude", 123.1);
+        locMap.put("longitude", 123.1);
+
+        Map<String, Object> properties = new LinkedHashMap<String, Object>();
+        properties.put("location", locMap);
+
+        Entity cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
+
+        assertTrue(cpEntity.getFieldMap().get("location") instanceof LocationField);
+
+
+        locMap = new HashMap<>();
+        locMap.put("latitude", 123.1);
+        locMap.put("lgnosoos", 123.1);
+
+        properties = new LinkedHashMap<String, Object>();
+        properties.put("location", locMap);
+
+        cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
+
+        assertTrue(cpEntity.getFieldMap().get("location") instanceof EntityObjectField);
+
+        properties = new LinkedHashMap<String, Object>();
+        properties.put("location", "denver");
+
+        cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
+
+        assertTrue(cpEntity.getFieldMap().get("location") instanceof StringField);
+    }
+
+
 
     @Test
     public void testSerialization() throws JsonProcessingException, IOException {


Mime
View raw message