usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [3/6] git commit: Add ArrayField to Mvcc serialization test and default constructor to ArrayField.
Date Thu, 28 Aug 2014 11:42:45 GMT
Add ArrayField to Mvcc serialization test and default constructor to ArrayField.


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

Branch: refs/heads/two-dot-o
Commit: 9b53e16453cda51df9a7c9463453dff8dd47eb6a
Parents: 718c0fe
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Wed Aug 27 13:07:02 2014 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Wed Aug 27 13:07:02 2014 -0400

----------------------------------------------------------------------
 .../usergrid/persistence/GeoQueryOrTest.java    | 111 -------------------
 ...MvccEntitySerializationStrategyImplTest.java |  13 ++-
 .../persistence/model/field/ArrayField.java     |   4 +
 .../persistence/model/field/SetField.java       |   1 +
 4 files changed, 16 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b53e164/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryOrTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryOrTest.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryOrTest.java
deleted file mode 100644
index 7acc4f7..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryOrTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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 java.util.LinkedHashMap;
-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.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.index.query.Query;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-
-@Concurrent()
-public class GeoQueryOrTest extends AbstractCoreIT {
-    private static final Logger LOG = LoggerFactory.getLogger( GeoQueryOrTest.class );
-
-
-    public GeoQueryOrTest() {
-        super();
-    }
-
-
-    @Test
-    public void testGeoQueryWithOr() throws Exception {
-
-        LOG.info( "GeoIT.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() );
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b53e164/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
index ebb77e0..6780115 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
@@ -67,6 +67,7 @@ import static junit.framework.TestCase.assertFalse;
 import static junit.framework.TestCase.assertNotNull;
 import static junit.framework.TestCase.assertNull;
 import static junit.framework.TestCase.assertTrue;
+import org.apache.usergrid.persistence.model.field.ArrayField;
 import static org.mockito.Mockito.mock;
 
 
@@ -142,13 +143,17 @@ public class MvccEntitySerializationStrategyImplTest {
         StringField stringField = new StringField( "name", "test" );
         UUIDField uuidField = new UUIDField( "uuid", UUIDGenerator.newTimeUUID() );
 
+        ArrayField arrayField = new ArrayField("array");
+        arrayField.add("item1");
+        arrayField.add("item2");
+
         entity.setField( boolField );
         entity.setField( doubleField );
         entity.setField( intField );
         entity.setField( longField );
         entity.setField( stringField );
         entity.setField( uuidField );
-
+        entity.setField( arrayField );
 
         MvccEntity saved = new MvccEntityImpl( id, version, MvccEntity.Status.COMPLETE, Optional.of(
entity ) );
 
@@ -190,6 +195,10 @@ public class MvccEntitySerializationStrategyImplTest {
 
         assertEquals( uuidField, uuidFieldReturned );
 
+        Field<ArrayField> arrayFieldReturned = returned.getEntity().get().getField(
arrayField.getName() );
+
+        assertEquals( arrayField, arrayFieldReturned );
+
 
         Set<Field> results = new HashSet<Field>();
         results.addAll( returned.getEntity().get().getFields());
@@ -202,7 +211,7 @@ public class MvccEntitySerializationStrategyImplTest {
         assertTrue( results.contains( stringField ) );
         assertTrue( results.contains( uuidField ) );
 
-        assertEquals( 6, results.size() );
+        assertEquals( 7, results.size() );
 
 
         assertEquals( id, entity.getId() );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b53e164/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/ArrayField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/ArrayField.java
b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/ArrayField.java
index 0ec00a7..452eb49 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/ArrayField.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/ArrayField.java
@@ -36,6 +36,10 @@ public class ArrayField<T> extends ListField<T> {
         super( name, list );
     }
 
+    public ArrayField() {
+        super();
+    }
+
     /**
      * Add the value to the list
      */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b53e164/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/SetField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/SetField.java
b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/SetField.java
index e68769a..f93c9db 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/SetField.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/SetField.java
@@ -38,6 +38,7 @@ public class SetField<T> extends AbstractField<Set<T>>
{
     }
 
     public SetField() {
+        super();
     }
 
     /**


Mime
View raw message