You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/08/28 13:42:48 UTC

[6/6] git commit: Fix for the way that arrays are serialized by JSON and a test to verify that arrays work as expected.

Fix for the way that arrays are serialized by JSON and a test to verify that arrays work as expected.


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

Branch: refs/heads/two-dot-o
Commit: 4e428e364b031d80e6ec1b8cd05f1f148d764a2d
Parents: 9b53e16
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Aug 27 20:42:04 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Aug 27 20:42:04 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |    7 +-
 .../corepersistence/CpEntityMapUtils.java       |    2 +-
 .../corepersistence/CpRelationManager.java      |   26 +-
 .../corepersistence/CpEntityMapUtilsTest.java   |  119 +
 .../persistence/GeoQueryBooleanTest.java        |  178 +
 .../MvccEntitySerializationStrategyImpl.java    |    9 +-
 .../persistence/model/entity/Entity.java        |    2 +-
 .../model/field/value/EntityObject.java         |   12 +-
 stack/corepersistence/pom.xml                   |    2 +-
 .../index/query/tree/CpQueryFilterLexer.java    | 3123 ------------------
 .../index/query/tree/CpQueryFilterParser.java   | 2501 --------------
 11 files changed, 326 insertions(+), 5655 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 2ce3d56..28124c2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -2486,12 +2486,13 @@ public class CpEntityManager implements EntityManager {
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug( "Writing entity {}:{} into scope\n   app {}\n   owner {}\n   name {}", 
+            logger.debug( "Writing entity {}:{} into scope\n   app {}\n   owner {}\n   name {} data {}", 
                 new Object[] {
                     entity.getType(), entity.getUuid(), 
                     collectionScope.getApplication(), 
                     collectionScope.getOwner(),
-                    collectionScope.getName()
+                    collectionScope.getName(),
+                    CpEntityMapUtils.toMap(cpEntity)
             } );
 //
 //            if ( entity.getType().equals("group")) {
@@ -2750,7 +2751,7 @@ public class CpEntityManager implements EntityManager {
     }
 
 
-    private org.apache.usergrid.persistence.model.entity.Entity entityToCpEntity( Entity entity, UUID importId ) {
+    public static org.apache.usergrid.persistence.model.entity.Entity entityToCpEntity( Entity entity, UUID importId ) {
 
         UUID uuid = importId != null ? importId : entity.getUuid();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityMapUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityMapUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityMapUtils.java
index 560f283..18eb7f9 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityMapUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityMapUtils.java
@@ -59,7 +59,7 @@ import org.slf4j.LoggerFactory;
  * Utilities for converting entities to/from maps suitable for Core Persistence.
  * Aware of unique properties via Schema.
  */
-class CpEntityMapUtils {
+public class CpEntityMapUtils {
     private static final Logger logger = LoggerFactory.getLogger( CpEntityMapUtils.class );
 
     public static ObjectMapper objectMapper = new ObjectMapper(  );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index d467682..31d32dd 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -650,7 +650,6 @@ public class CpRelationManager implements RelationManager {
             return null;
         }
 
-
         // load the new member entity to be added to the collection from its default scope
         CollectionScope memberScope = new CollectionScopeImpl( 
             applicationScope.getApplication(), 
@@ -658,28 +657,29 @@ public class CpRelationManager implements RelationManager {
             CpEntityManager.getCollectionScopeNameFromEntityType( itemRef.getType()));
         EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager(memberScope);
 
+        org.apache.usergrid.persistence.model.entity.Entity memberEntity = memberMgr.load(
+            new SimpleId( itemRef.getUuid(), itemRef.getType() )).toBlockingObservable().last();
+
+        if ( memberEntity == null ) {
+            throw new RuntimeException("Unable to load entity uuid=" 
+                + itemRef.getUuid() + " type=" + itemRef.getType());
+        }
+
         if ( logger.isDebugEnabled() ) {
-            logger.debug("Loading member entity {}:{} from scope\n   app {}\n   owner {}\n   name {}", 
+            logger.debug("Loaded member entity {}:{} from scope\n   app {}\n   owner {}\n   name {} data {}", 
                 new Object[] { 
                     itemRef.getType(), 
                     itemRef.getUuid(), 
                     memberScope.getApplication(), 
                     memberScope.getOwner(), 
-                    memberScope.getName() 
+                    memberScope.getName(),
+                    CpEntityMapUtils.toMap(memberEntity)
             });
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity memberEntity = memberMgr.load(
-            new SimpleId( itemRef.getUuid(), itemRef.getType() )).toBlockingObservable().last();
-
-        if ( memberEntity == null ) {
-            throw new RuntimeException("Unable to load entity uuid=" 
-                + itemRef.getUuid() + " type=" + itemRef.getType());
-        }
-
         String edgeType = getEdgeTypeFromCollectionName( collName, memberEntity.getId().getType() );
 
-        logger.debug("createCollection(): Creating edge type {} from {}:{} to {}:{}", 
+        logger.debug("addToCollection(): Creating edge type {} from {}:{} to {}:{}", 
             new Object[] { 
                 edgeType, 
                 headEntity.getType(), headEntity.getUuid(), 
@@ -694,7 +694,7 @@ public class CpRelationManager implements RelationManager {
         GraphManager gm = managerCache.getGraphManager(applicationScope);
         gm.writeEdge(edge).toBlockingObservable().last();
 
-        // index member into entity connection | type scope
+        // index member into entity collection | type scope
         IndexScope collectionIndexScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             cpHeadEntity.getId(), 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/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
new file mode 100644
index 0000000..87f6b46
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.corepersistence;
+
+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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.value.EntityObject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class CpEntityMapUtilsTest {
+    private static final Logger log = LoggerFactory.getLogger( CpEntityMapUtilsTest.class );
+
+    @Test
+    public void testToMap() {
+
+        Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+            put( "username", "bart" );
+            put( "email", "bart@example.com" );
+            put( "block", new ArrayList<Object>() {{
+                add( new LinkedHashMap<String, Object>() {{ put("name", "fred"); }});
+                add( new LinkedHashMap<String, Object>() {{ put("name", "gertrude"); }});
+                add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
+            }});            
+            put( "blockedBy", new ArrayList<Object>() {{
+                add( new LinkedHashMap<String, Object>() {{ put("name", "isabell"); }});
+            }});
+            put( "location", new LinkedHashMap<String, Object>() {{
+                put("latitude", 37.776753 );
+                put("longitude", -122.407846 );
+            }}); 
+        }};
+
+        Entity cpEntity = CpEntityMapUtils.fromMap( properties, "user", true );
+        assertUserWithBlocks( cpEntity );
+    }
+
+        
+    @Test
+    public void testSerialization() throws JsonProcessingException, IOException {
+
+        Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+            put( "username", "bart" );
+            put( "email", "bart@example.com" );
+            put( "block", new ArrayList<Object>() {{
+                add( new LinkedHashMap<String, Object>() {{ put("name", "fred"); }});
+                add( new LinkedHashMap<String, Object>() {{ put("name", "gertrude"); }});
+                add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
+            }});            
+            put( "blockedBy", new ArrayList<Object>() {{
+                add( new LinkedHashMap<String, Object>() {{ put("name", "isabell"); }});
+            }});
+            put( "location", new LinkedHashMap<String, Object>() {{
+                put("latitude", 37.776753 );
+                put("longitude", -122.407846 );
+            }}); 
+        }};
+
+        org.apache.usergrid.persistence.model.entity.Entity entity = 
+            new org.apache.usergrid.persistence.model.entity.Entity(
+                new SimpleId( "user" ) );
+        entity = CpEntityMapUtils.fromMap( entity, properties, null, true );
+
+        assertUserWithBlocks( entity );
+
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.enable(SerializationFeature.INDENT_OUTPUT);
+        mapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, "@class");
+
+        String entityString = mapper.writeValueAsString( entity );
+        //log.debug("Serialized to JSON: " + entityString );
+
+        TypeReference<Entity> tr = new TypeReference<Entity>() {};
+        entity = mapper.readValue( entityString, tr );
+        //log.debug("Round-tripped entity: " + CpEntityMapUtils.toMap(entity) );
+
+        assertUserWithBlocks( entity );
+    }
+
+
+    private void assertUserWithBlocks( org.apache.usergrid.persistence.model.entity.Entity e ) {
+        
+        assertTrue( e.getField("block") instanceof ListField );
+        assertTrue( e.getField("block").getValue() instanceof List );
+        List blockList = (List)e.getField("block").getValue();
+
+        EntityObject entityObject = (EntityObject)blockList.get(0);
+        assertEquals("fred", entityObject.getField("name").getValue());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
new file mode 100644
index 0000000..8767a70
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence;
+
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.inject.Injector;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.AbstractCoreIT;
+import org.apache.usergrid.cassandra.Concurrent;
+import org.apache.usergrid.corepersistence.CpEntityMapUtils;
+import org.apache.usergrid.corepersistence.CpSetup;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntityCollectionManager;
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.geo.model.Point;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.value.EntityObject;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+
+@Concurrent()
+public class GeoQueryBooleanTest extends AbstractCoreIT {
+    private static final Logger log = LoggerFactory.getLogger( GeoQueryBooleanTest.class );
+
+
+    public GeoQueryBooleanTest() {
+        super();
+    }
+
+
+    @Test
+    public void testGeoQueryWithOr() throws Exception {
+
+        log.info( "GeoQueryBooleanTest.testGeoQueryWithOr" );
+
+        UUID applicationId = setup.createApplication( "testOrganization", "testGeoQueryWithOr" );
+        assertNotNull( applicationId );
+
+        EntityManager em = setup.getEmf().getEntityManager( applicationId );
+        assertNotNull( em );
+
+        // create two users at a location
+
+        Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+            put( "username", "ed" );
+            put( "employer", "Apigee" );
+            put( "email", "ed@example.com" );
+            put( "location", new LinkedHashMap<String, Object>() {{
+                put("latitude", 37.776753 );
+                put("longitude", -122.407846 );
+            }} ); 
+        }};
+
+        Entity user1 = em.create( "user", properties );
+        assertNotNull( user1 );
+
+        properties = new LinkedHashMap<String, Object>() {{
+            put( "username", "fred" );
+            put( "employer", "Microsoft" );
+            put( "email", "fred@example.com" );
+            put( "location", new LinkedHashMap<String, Object>() {{
+                put("latitude", 37.776753 );
+                put("longitude", -122.407846 );
+            }} ); 
+        }};
+
+        Entity user2 = em.create( "user", properties );
+        assertNotNull( user2 );
+
+        em.refreshIndex();
+
+        // define center point about 300m from that location
+        Point center = new Point( 37.774277, -122.404744 );
+
+        Query query = Query.fromQL( "select * where location within 400 of " 
+                                    + center.getLat() + "," + center.getLon());
+        Results listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+        assertEquals( 2, listResults.size() );
+
+        query = Query.fromQL( "select * where employer='Apigee' or location within 100 of " 
+                                    + center.getLat() + "," + center.getLon());
+        listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+
+        // no results because geo filter applied after query even in the case or 'or'
+        assertEquals( 0, listResults.size() );
+
+        query = Query.fromQL( "select * where employer='Apigee' or location within 400 of " 
+                                    + center.getLat() + "," + center.getLon());
+        listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+
+        // only one result because geo filter applied after query even in the case or 'or'
+        assertEquals( 1, listResults.size() );
+    }
+
+
+    @Test
+    public void testGeoQueryWithNot() throws Exception {
+
+        log.info( "GeoQueryBooleanTest.testGeoQueryWithOr" );
+
+        UUID applicationId = setup.createApplication( "testOrganization", "testGeoQueryWithOr" );
+        assertNotNull( applicationId );
+
+        EntityManager em = setup.getEmf().getEntityManager( applicationId );
+        assertNotNull( em );
+
+        Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+            put( "username", "bart" );
+            put( "email", "bart@example.com" );
+            put( "block", new ArrayList<Object>() {{
+                add( new LinkedHashMap<String, Object>() {{ put("name", "fred"); }});
+                add( new LinkedHashMap<String, Object>() {{ put("name", "gertrude"); }});
+                add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
+            }});            
+            put( "blockedBy", new ArrayList<Object>() {{
+                add( new LinkedHashMap<String, Object>() {{ put("name", "isabell"); }});
+            }});
+            put( "location", new LinkedHashMap<String, Object>() {{
+                put("latitude", 37.776753 );
+                put("longitude", -122.407846 );
+            }}); 
+        }};
+
+        Entity userBart = em.create( "user", properties );
+        assertNotNull( userBart );
+//
+//        properties = new LinkedHashMap<String, Object>() {{
+//            put( "username", "fred" );
+//            put( "email", "fred@example.com" );
+//            put( "block", new ArrayList<Object>() {{
+//                add( new LinkedHashMap<String, Object>() {{ put("name", "steve"); }});
+//                add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
+//            }});
+//            put( "blockedBy", new ArrayList<Object>() {{
+//                add( new LinkedHashMap<String, Object>() {{ put("name", "bart"); }});
+//            }});
+//            put( "location", new LinkedHashMap<String, Object>() {{
+//                put("latitude", 37.776753 );
+//                put("longitude", -122.407846 );
+//            }} ); 
+//        }};
+//
+//        Entity userFred = em.create( "user", properties );
+//        assertNotNull( userFred );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index cbc1c8c..4f8d1f3 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -366,9 +366,8 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
 
             byte[] state = parser.read( BYTES_ARRAY_SERIALIZER );
 
-            /**
-             * It's been deleted, remove it
-             */
+            // it's been deleted, remove it
+
             if ( Arrays.equals( STATE_DELETED, state ) ) {
                 return new EntityWrapper( MvccEntity.Status.COMPLETE, Optional.<Entity>absent() );
             }
@@ -381,7 +380,7 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
             int length = jsonBytes.remaining();
 
             try {
-                storedEntity = mapper.readValue( array,start,length,Entity.class);
+                storedEntity = mapper.readValue( array, start, length, Entity.class );
             }
             catch ( Exception e ) {
                 throw new RuntimeException(e.getMessage());
@@ -393,7 +392,7 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
                 return new EntityWrapper( MvccEntity.Status.COMPLETE, entity );
             }
 
-            //it's partial by default
+            // it's partial by default
             return new EntityWrapper( MvccEntity.Status.PARTIAL, entity );
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
index 4287626..c5089dc 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/Entity.java
@@ -34,7 +34,7 @@ import com.google.common.base.Preconditions;
  * Equality is based both on id an on version.
  */
 @JsonIgnoreProperties(ignoreUnknown = true)
-@JsonTypeInfo( use= JsonTypeInfo.Id.CLASS,include= JsonTypeInfo.As.WRAPPER_OBJECT,property="@class" )
+@JsonTypeInfo( use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class" )
 public class Entity extends EntityObject {
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
index 2443776..12915e2 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/value/EntityObject.java
@@ -41,7 +41,7 @@ public class EntityObject implements Serializable {
     /**
      * Fields the users can set
      */
-    @JsonTypeInfo( use= JsonTypeInfo.Id.CLASS,include= JsonTypeInfo.As.WRAPPER_OBJECT,property="@class" )
+    @JsonTypeInfo( use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class" )
     private final Map<String, Field> fields = new HashMap<String, Field>();
 
     /**
@@ -66,12 +66,14 @@ public class EntityObject implements Serializable {
 
     //@JsonAnySetter
     public void setFields(ArrayList al) {
-        if(al.size() == 0)
+
+        if ( al.isEmpty()) {
             return;
+        }
 
         for(int i = 0; i < al.size(); i++) {
             String str = al.get( i ).toString();
-            if(str.contains( "version" )){
+            if ( str.contains( "version" )) {
                 continue;
             }
             Field fd = ( Field ) al.get( i );
@@ -79,10 +81,6 @@ public class EntityObject implements Serializable {
         }
     }
 
-
-    public void getFields( String name) {
-        fields.get( name );
-    }
     /**
      * Get all fields in the entity
      */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4e428e36/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index 5a5c20c..7dad18c 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -94,7 +94,7 @@
                     <systemPropertyVariables>
                         <archaius.deployment.environment>UNIT</archaius.deployment.environment>
                     </systemPropertyVariables>
-                    <argLine>-Xms2G -Xmx4G</argLine>
+                    <argLine>-Xms2G -Xmx4G -Dlog4j.debug=true -Dlog4j.configuration=file://${project.basedir}/src/test/resources/log4j.properties</argLine>
                 </configuration>
             </plugin>