usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [1/2] git commit: Progress towards getting more query tests running.
Date Tue, 25 Feb 2014 15:20:44 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o cc24d6f1d -> dc9e27ee1


Progress towards getting more query tests running.


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

Branch: refs/heads/two-dot-o
Commit: ff6002a9932655faedb5ac2b744384a0550a17d0
Parents: cc24d6f
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Tue Feb 25 09:38:26 2014 -0500
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Tue Feb 25 09:38:26 2014 -0500

----------------------------------------------------------------------
 .gitignore                                      |   2 +
 stack/corepersistence/query/pom.xml             | 233 ----------
 .../query/src/test/resources/log4j.properties   |  30 --
 stack/corepersistence/queryindex/pom.xml        | 113 ++---
 .../index/EntityCollectionIndex.java            |   9 +-
 .../index/impl/EntityCollectionIndexImpl.java   |   8 +
 .../usergrid/persistence/query/Results.java     |   5 +
 .../apache/usergrid/persistence/IndexIT.java    | 448 +++++++++++++++++++
 .../persistence/index/impl/EntityIndexTest.java | 145 +-----
 .../usergrid/persistence/query/QueryTest.java   |   1 -
 .../apache/usergrid/test/AbstractCoreIT.java    |  55 +++
 .../org/apache/usergrid/test/Application.java   | 127 ++++++
 .../apache/usergrid/test/CassandraService.java  |  15 +
 .../apache/usergrid/test/CoreApplication.java   | 151 +++++++
 .../org/apache/usergrid/test/CoreITSetup.java   |  28 ++
 .../apache/usergrid/test/CoreITSetupImpl.java   |  80 ++++
 .../usergrid/test/EntityManagerFacade.java      |  61 +++
 .../apache/usergrid/test/EntityMapUtils.java    | 165 +++++++
 .../src/test/resources/dynamic-test.properties  |  12 +
 .../src/test/resources/usergrid-CHOP.properties |  12 +
 .../src/test/resources/usergrid-UNIT.properties |  14 +
 .../src/test/resources/usergrid.properties      |   1 +
 22 files changed, 1245 insertions(+), 470 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 70161ee..a1b782f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,5 @@ Icon
 /stack/corepersistence/priamcluster/aws.properties
 #Webstorm artifacts
 .idea/
+/stack/corepersistence/queryindex/nbactions.xml
+/stack/corepersistence/collection/nbactions.xml
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/query/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/query/pom.xml b/stack/corepersistence/query/pom.xml
deleted file mode 100644
index d4bff43..0000000
--- a/stack/corepersistence/query/pom.xml
+++ /dev/null
@@ -1,233 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
-    <properties>
-        <guice.version>3.0</guice.version>
-        <guicyfig.version>3.3</guicyfig.version>
-        <slf4j.version>1.7.2</slf4j.version>
-        <log4j.version>1.2.17</log4j.version>
-        <chop.version>1.0</chop.version>
-    </properties>
-
-    <parent>
-        <artifactId>persistence</artifactId>
-        <groupId>org.apache.usergrid</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-    <description>Module provates query for Entities via ElasticSearch</description>
-
-    <artifactId>query</artifactId>
-
-    <build>
-
-        <testResources>
-            <testResource>
-                <directory>src/test/resources</directory>
-                <filtering>true</filtering>
-                <includes>
-                    <include>**/*</include>
-                </includes>
-            </testResource>
-        </testResources>
-
-        <plugins>
-
-            <plugin>
-                <groupId>org.safehaus.chop</groupId>
-                <artifactId>chop-maven-plugin</artifactId>
-                <version>${chop.version}</version>
-
-                <!--
-                NOTE: you should be putting most of these variables into your settings.xml
-                as an automatically activated profile.
-                -->
-
-                <configuration>
-                    <accessKey>${aws.s3.key}</accessKey>
-                    <secretKey>${aws.s3.secret}</secretKey>
-                    <availabilityZone>${availabilityZone}</availabilityZone>
-                    <bucketName>${aws.s3.bucket}</bucketName>
-                    <managerAppUsername>admin</managerAppUsername>
-                    <managerAppPassword>${manager.app.password}</managerAppPassword>
-                    <testPackageBase>org.apache.usergrid</testPackageBase>
-                    <runnerSSHKeyFile>${runner.ssh.key.file}</runnerSSHKeyFile>
-                    <failIfCommitNecessary>false</failIfCommitNecessary>
-                    <amiID>${ami.id}</amiID>
-                    <instanceType>m1.large</instanceType>
-                    <resultsDirectory>${resultsDirectory}</resultsDirectory>
-                    <dumpType>${dumpType}</dumpType>
-                    <coldRestartTomcat>true</coldRestartTomcat>
-                    <awsSecurityGroup>${security.group}</awsSecurityGroup>
-                    <runnerKeyPairName>${runner.keypair.name}</runnerKeyPairName>
-                    <runnerCount>6</runnerCount>
-                    <securityGroupExceptions>
-                        <!--
-                        Add your own IP address as an exception to allow access
-                        but please do this in the settings.xml file .. essentially
-                        all parameters should be in the settings.xml file.
-                        -->
-                        <param>${myip.address}/32:24981</param>
-                        <param>${myip.address}/32:22</param>
-                    </securityGroupExceptions>
-                </configuration>
-            </plugin>
-
-<!--            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>cobertura-maven-plugin</artifactId>
-                <version>2.6</version>
-                <configuration>
-                    <check>
-                        <branchRate>85</branchRate>
-                        <lineRate>85</lineRate>
-                        <haltOnFailure>true</haltOnFailure>
-                        <totalBranchRate>85</totalBranchRate>
-                        <totalLineRate>85</totalLineRate>
-                        <packageLineRate>85</packageLineRate>
-                        <packageBranchRate>85</packageBranchRate>
-                    </check>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>clean</goal>
-                            <goal>check</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>-->
-
-            <plugin>
-                <groupId>org.antlr</groupId>
-                <artifactId>antlr3-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <configuration>
-                            <outputDirectory>src/main/java</outputDirectory>
-                        </configuration>
-                        <goals>
-                            <goal>antlr</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.safehaus.chop</groupId>
-            <artifactId>chop-api</artifactId>
-            <version>${chop.version}</version>
-        </dependency>
-
-        <!-- Google Guice Integration Test Injectors -->
-
-        <dependency>
-            <groupId>${project.parent.groupId}</groupId>
-            <artifactId>model</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.elasticsearch</groupId>
-            <artifactId>elasticsearch</artifactId>
-            <version>1.0.0.RC1</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.safehaus.guicyfig</groupId>
-            <artifactId>guicyfig</artifactId>
-            <version>${guicyfig.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.jukito</groupId>
-            <artifactId>jukito</artifactId>
-            <version>${jukito.version}</version>
-            <scope>test</scope>
-        </dependency>
-
-        <!-- lang utils for setting uuids etc -->
-
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.1</version>
-        </dependency>
-
-        <!-- Google Guice -->
-
-        <dependency>
-            <groupId>com.google.inject</groupId>
-            <artifactId>guice</artifactId>
-            <version>${guice.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>${slf4j.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>${slf4j.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-            <version>${log4j.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.usergrid</groupId>
-            <artifactId>model</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <type>jar</type>
-        </dependency>
-
-        <dependency>
-            <groupId>commons-codec</groupId>
-            <artifactId>commons-codec</artifactId>
-            <version>1.6</version>
-            <type>jar</type>
-        </dependency>
-
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.4</version>
-            <type>jar</type>
-        </dependency>
-
-        <dependency>
-            <groupId>commons-collections</groupId>
-            <artifactId>commons-collections</artifactId>
-            <version>3.2.1</version>
-            <type>jar</type>
-        </dependency>
-
-        <dependency>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-smile</artifactId>
-            <version>1.9.13</version>
-            <type>jar</type>
-        </dependency>
-
-        <dependency>
-            <groupId>org.antlr</groupId>
-            <artifactId>antlr-runtime</artifactId>
-            <version>3.5</version>
-            <type>jar</type>
-        </dependency>
-
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/query/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/query/src/test/resources/log4j.properties b/stack/corepersistence/query/src/test/resources/log4j.properties
deleted file mode 100644
index 75bbc31..0000000
--- a/stack/corepersistence/query/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,30 +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.
-
-# for production, you should probably set the root to INFO
-# and the pattern to %c instead of %l.  (%l is slower.)
-
-# output messages into a rolling log file as well as stdout
-log4j.rootLogger=INFO,stdout
-
-# stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) [%c] - %m%n
-
-log4j.category.org.apache=ERROR
-log4j.category.org.apache.usergrid=INFO
-

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/pom.xml b/stack/corepersistence/queryindex/pom.xml
index 87a7ebf..7fce6e5 100644
--- a/stack/corepersistence/queryindex/pom.xml
+++ b/stack/corepersistence/queryindex/pom.xml
@@ -9,14 +9,6 @@
     <artifactId>queryindex</artifactId>
     <description>Module provates indexing and query of Entities via ElasticSearch</description>
 
-    <properties>
-        <guice.version>3.0</guice.version>
-        <guicyfig.version>3.3</guicyfig.version>
-        <slf4j.version>1.7.2</slf4j.version>
-        <log4j.version>1.2.17</log4j.version>
-        <chop.version>1.0</chop.version>
-    </properties>
-
     <parent>
         <artifactId>persistence</artifactId>
         <groupId>org.apache.usergrid</groupId>
@@ -107,120 +99,113 @@
 
     <dependencies>
 
+        <!-- major dependencies -->
+
         <dependency>
-            <groupId>org.apache.usergrid</groupId>
+            <groupId>${project.parent.groupId}</groupId>
             <artifactId>model</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <type>jar</type>
+            <version>${project.version}</version>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.usergrid</groupId>
+            <groupId>${project.parent.groupId}</groupId>
             <artifactId>collection</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
             <type>jar</type>
         </dependency>
 
         <dependency>
-            <groupId>org.safehaus.chop</groupId>
-            <artifactId>chop-api</artifactId>
-            <version>${chop.version}</version>
+            <groupId>org.elasticsearch</groupId>
+            <artifactId>elasticsearch</artifactId>
+            <version>${elasticsearch.version}</version>
         </dependency>
 
-        <!-- Google Guice Integration Test Injectors -->
-
-        <dependency>
-            <groupId>${project.parent.groupId}</groupId>
-            <artifactId>model</artifactId>
-            <version>${project.version}</version>
+       <dependency>
+            <groupId>org.antlr</groupId>
+            <artifactId>antlr-runtime</artifactId>
+            <version>3.5</version>
+            <type>jar</type>
         </dependency>
 
         <dependency>
-            <groupId>org.elasticsearch</groupId>
-            <artifactId>elasticsearch</artifactId>
-            <version>1.0.0.RC1</version>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+            <version>${guice.version}</version>
         </dependency>
 
-        <dependency>
+         <dependency>
             <groupId>org.safehaus.guicyfig</groupId>
             <artifactId>guicyfig</artifactId>
             <version>${guicyfig.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>org.jukito</groupId>
-            <artifactId>jukito</artifactId>
-            <version>${jukito.version}</version>
-            <scope>test</scope>
-        </dependency>
-
-        <!-- lang utils for setting uuids etc -->
+        <!-- Test dependencies  -->
 
         <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.1</version>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>collection</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
         </dependency>
 
-        <!-- Google Guice -->
-
         <dependency>
-            <groupId>com.google.inject</groupId>
-            <artifactId>guice</artifactId>
-            <version>${guice.version}</version>
+            <groupId>org.safehaus.chop</groupId>
+            <artifactId>chop-api</artifactId>
+            <version>${chop.version}</version>
         </dependency>
 
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>${slf4j.version}</version>
+            <groupId>org.jukito</groupId>
+            <artifactId>jukito</artifactId>
+            <version>${jukito.version}</version>
+            <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>${slf4j.version}</version>
-        </dependency>
+        <!-- common stuff, logging, etc.-->
 
         <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-            <version>${log4j.version}</version>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>${commons.lang.version}</version>
         </dependency>
 
         <dependency>
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>
-            <version>1.6</version>
+            <version>${commons.codec.version}</version>
             <type>jar</type>
         </dependency>
 
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.4</version>
+            <version>${commons.io.version}</version>
             <type>jar</type>
         </dependency>
 
         <dependency>
             <groupId>commons-collections</groupId>
             <artifactId>commons-collections</artifactId>
-            <version>3.2.1</version>
+            <version>${commons.collections.version}</version>
             <type>jar</type>
         </dependency>
 
         <dependency>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-smile</artifactId>
-            <version>1.9.13</version>
-            <type>jar</type>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>${slf4j.version}</version>
         </dependency>
 
         <dependency>
-            <groupId>org.antlr</groupId>
-            <artifactId>antlr-runtime</artifactId>
-            <version>3.5</version>
-            <type>jar</type>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${slf4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>${log4j.version}</version>
         </dependency>
 
     </dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
index fd4cc5b..72470a0 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
@@ -20,6 +20,8 @@
 package org.apache.usergrid.persistence.index;
 
 import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Results;
 
 
 /**
@@ -40,7 +42,12 @@ public interface EntityCollectionIndex {
     public void deindex( Entity entity );
 
     /**
-     * Query interface for testing using Usergrid query syntax.
+     * Execute query in ElasticSearch syntax.
      */
     public EntitySearchResults simpleQuery( String query, int from, int size );
+
+    /**
+     * Execute query in Usergrid syntax.
+     */
+    public Results execute( Query query );
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
index c009a66..07178e8 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
@@ -37,6 +37,8 @@ import org.apache.usergrid.persistence.model.field.Field;
 import org.apache.usergrid.persistence.model.field.ListField;
 import org.apache.usergrid.persistence.model.field.SetField;
 import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Results;
 import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
 import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest;
 import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
@@ -120,6 +122,11 @@ public class EntityCollectionIndexImpl implements EntityCollectionIndex {
     }
 
 
+    public Results execute( Query query ) {
+        return null;
+    }
+
+
     public EntitySearchResults simpleQuery( String query, int from, int size ) {
 
         QueryStringQueryBuilder builder = new QueryStringQueryBuilder( query );
@@ -269,4 +276,5 @@ public class EntityCollectionIndexImpl implements EntityCollectionIndex {
         
         return builder;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
index cd0790a..34970cf 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
@@ -202,6 +202,11 @@ public class Results implements Iterable<Entity> {
     }
 
 
+    public String getCursor() {
+        return null;
+    }
+
+
     public Level getLevel() {
         return level;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/IndexIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/IndexIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/IndexIT.java
new file mode 100644
index 0000000..d4aeb56
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/IndexIT.java
@@ -0,0 +1,448 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.persistence;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Results;
+import org.apache.usergrid.persistence.utils.JsonUtils;
+import org.apache.usergrid.test.AbstractCoreIT;
+import org.apache.usergrid.test.EntityManagerFacade;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class IndexIT extends AbstractCoreIT {
+    private static final Logger LOG = LoggerFactory.getLogger( IndexIT.class );
+
+    public static final String[] alphabet = {
+            "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima",
+            "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey",
+            "X-ray", "Yankee", "Zulu"
+    };
+
+
+    @Test
+    public void testCollectionOrdering() throws Exception {
+        LOG.info( "testCollectionOrdering" );
+
+        Id appId = new SimpleId("application");
+        Id orgId = new SimpleId("organization");
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "items" );
+        EntityManagerFacade em = new EntityManagerFacade( factory, null);
+
+        for ( int i = alphabet.length - 1; i >= 0; i-- ) {
+            String name = alphabet[i];
+            Map<String, Object> properties = new LinkedHashMap<String, Object>();
+            properties.put( "name", name );
+
+            em.create( "item", properties );
+        }
+
+        int i = 0;
+
+        Query query = Query.fromQL( "order by name" );
+        Results r = em.searchCollection( em.getApplicationRef(), "items", query );
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+
+        query = Query.fromQL( "order by name" ).withCursor( r.getCursor() );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+
+        query = Query.fromQL( "order by name" ).withCursor( r.getCursor() );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+
+        assertEquals( alphabet.length, i );
+
+        i = alphabet.length;
+
+        query = Query.fromQL( "order by name desc" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        for ( Entity entity : r.getEntities() ) {
+            i--;
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+        }
+
+        query = Query.fromQL( "order by name desc" ).withCursor( r.getCursor() );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        // LOG.info(JsonUtils.mapToFormattedJsonString(r.getEntities()));
+        for ( Entity entity : r.getEntities() ) {
+            i--;
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+        }
+
+        query = Query.fromQL( "order by name desc" ).withCursor( r.getCursor() );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        for ( Entity entity : r.getEntities() ) {
+            i--;
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+        }
+
+        assertEquals( 0, i );
+    }
+
+
+    @Test
+    public void testCollectionFilters() throws Exception {
+        LOG.info( "testCollectionFilters" );
+
+        Id appId = new SimpleId("application");
+        Id orgId = new SimpleId("organization");
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "items" );
+        EntityManagerFacade em = new EntityManagerFacade( factory, null);
+
+        for ( int i = alphabet.length - 1; i >= 0; i-- ) {
+            String name = alphabet[i];
+            Map<String, Object> properties = new LinkedHashMap<String, Object>();
+            properties.put( "name", name );
+
+            em.create( "item", properties );
+        }
+
+        Query query = Query.fromQL( "name < 'delta'" );
+        Results r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        int i = 0;
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+        assertEquals( 3, i );
+
+        query = Query.fromQL( "name <= 'delta'" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        i = 0;
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+        assertEquals( 4, i );
+
+        query = Query.fromQL( "name <= 'foxtrot' and name > 'bravo'" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        i = 2;
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+        assertEquals( 6, i );
+
+        query = Query.fromQL( "name < 'foxtrot' and name > 'bravo'" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        i = 2;
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+        assertEquals( 5, i );
+
+        query = Query.fromQL( "name < 'foxtrot' and name >= 'bravo'" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        i = 1;
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+        assertEquals( 5, i );
+
+        query = Query.fromQL( "name <= 'foxtrot' and name >= 'bravo'" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        i = 1;
+        for ( Entity entity : r.getEntities() ) {
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+            i++;
+        }
+        assertEquals( 6, i );
+
+        query = Query.fromQL( "name <= 'foxtrot' and name >= 'bravo' order by name desc" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        i = 6;
+        for ( Entity entity : r.getEntities() ) {
+            i--;
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+        }
+        assertEquals( 1, i );
+
+        query = Query.fromQL( "name < 'foxtrot' and name > 'bravo' order by name desc" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        i = 5;
+        for ( Entity entity : r.getEntities() ) {
+            i--;
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+        }
+        assertEquals( 2, i );
+
+        query = Query.fromQL( "name < 'foxtrot' and name >= 'bravo' order by name desc" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        i = 5;
+        for ( Entity entity : r.getEntities() ) {
+            i--;
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+        }
+        assertEquals( 1, i );
+
+        query = Query.fromQL( "name = 'foxtrot'" );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        assertEquals( 1, r.size() );
+
+        long created = r.getEntity().getVersion().timestamp();
+        Id entityId = r.getEntity().getId();
+
+        query = Query.fromQL( "created = " + created );
+        r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        assertEquals( 1, r.size() );
+        assertEquals( entityId, r.getEntity().getId() );
+    }
+
+
+    @Test
+    public void testSecondarySorts() throws Exception {
+        LOG.info( "testSecondarySorts" );
+
+        Id appId = new SimpleId("application");
+        Id orgId = new SimpleId("organization");
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "items" );
+        EntityManagerFacade em = new EntityManagerFacade( factory, null);
+
+        for ( int i = alphabet.length - 1; i >= 0; i-- ) {
+            String name = alphabet[i];
+            Map<String, Object> properties = new LinkedHashMap<String, Object>();
+            properties.put( "name", name );
+            properties.put( "group", i / 3 );
+            properties.put( "reverse_name", alphabet[alphabet.length - 1 - i] );
+
+            em.create( "item", properties );
+        }
+
+        Query query = Query.fromQL( "group = 1 order by name desc" );
+        Results r = em.searchCollection( em.getApplicationRef(), "items", query );
+        LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
+        int i = 6;
+        for ( Entity entity : r.getEntities() ) {
+            i--;
+            assertEquals( 1L, entity.getField( "group" ).getValue() );
+            assertEquals( alphabet[i], entity.getField( "name" ).getValue() );
+        }
+        assertEquals( 3, i );
+    }
+
+
+//    @Test
+//    public void testPropertyUpdateWithConnection() throws Exception {
+//
+//        Id appId = new SimpleId("application");
+//        Id orgId = new SimpleId("organization");
+//        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "items" );
+//        EntityManagerFacade em = new EntityManagerFacade( factory, null);
+//
+//
+//        Map<String, Object> entity1 = new LinkedHashMap<String, Object>();
+//        entity1.put( "name", "name_1" );
+//        entity1.put( "status", "pickled" );
+//
+//
+//        Map<String, Object> entity2 = new LinkedHashMap<String, Object>();
+//        entity2.put( "name", "name_2" );
+//        entity2.put( "status", "foo" );
+//
+//
+//        Entity entity1Ref = em.create( "names", entity1 );
+//        Entity entity2Ref = em.create( "names", entity2 );
+//
+//
+//        em.createConnection( entity2Ref, "connecting", entity1Ref );
+//
+//        //should return valid values
+//        Query query = Query.fromQL( "select * where status = 'pickled'" );
+//
+//        Results r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 1, r.size() );
+//        assertEquals( entity1Ref.getUuid(), r.getEntity().getUuid() );
+//
+//
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 1, r.size() );
+//        assertEquals( entity1Ref.getUuid(), r.getEntity().getUuid() );
+//
+//        //now update the first entity, this causes the failure after connections
+//        entity1Ref.setProperty( "status", "herring" );
+//
+//        em.update( entity1Ref );
+//
+//        //query and check the status has been updated, shouldn't return results
+//        query = Query.fromQL( "select * where status = 'pickled'" );
+//
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 0, r.size() );
+//
+//        //search connections
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 0, r.size() );
+//
+//
+//        //should return results
+//        query = Query.fromQL( "select * where status = 'herring'" );
+//
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 1, r.size() );
+//
+//        assertEquals( entity1Ref.getUuid(), r.getEntity().getUuid() );
+//
+//
+//        //search connections
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 1, r.size() );
+//        assertEquals( entity1Ref.getUuid(), r.getEntity().getUuid() );
+//    }
+//
+//
+//    /** Same as above, but verifies the data in our entity_index_entry CF after the operations have completed */
+//
+//    @Test
+//    public void testPropertyUpdateWithConnectionEntityIndexEntryAudit() throws Exception {
+//
+//        Id appId = new SimpleId("application");
+//        Id orgId = new SimpleId("organization");
+//        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "items" );
+//        EntityManagerFacade em = new EntityManagerFacade( factory, null);
+//
+//
+//        Map<String, Object> entity1 = new LinkedHashMap<String, Object>();
+//        entity1.put( "name", "name_1" );
+//        entity1.put( "status", "pickled" );
+//
+//
+//        Map<String, Object> entity2 = new LinkedHashMap<String, Object>();
+//        entity2.put( "name", "name_2" );
+//        entity2.put( "status", "foo" );
+//
+//
+//        Entity entity1Ref = em.create( "names", entity1 );
+//        Entity entity2Ref = em.create( "names", entity2 );
+//
+//
+//        em.createConnection( entity2Ref, "connecting", entity1Ref );
+//
+//        //should return valid values
+//        Query query = Query.fromQL( "select * where status = 'pickled'" );
+//
+//        Results r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 1, r.size() );
+//        assertEquals( entity1Ref.getUuid(), r.getEntity().getUuid() );
+//
+//
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 1, r.size() );
+//        assertEquals( entity1Ref.getUuid(), r.getEntity().getUuid() );
+//
+//        //now update the first entity, this causes the failure after connections
+//        entity1Ref.setProperty( "status", "herring" );
+//
+//        em.update( entity1Ref );
+//
+//        //query and check the status has been updated, shouldn't return results
+//        query = Query.fromQL( "select * where status = 'pickled'" );
+//
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 0, r.size() );
+//
+//        //search connections
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 0, r.size() );
+//
+//
+//        //should return results
+//        query = Query.fromQL( "select * where status = 'herring'" );
+//
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 1, r.size() );
+//
+//        assertEquals( entity1Ref.getUuid(), r.getEntity().getUuid() );
+//
+//
+//        //search connections
+//        r = em.searchCollection( em.getApplicationRef(), "names", query );
+//        assertEquals( 1, r.size() );
+//        assertEquals( entity1Ref.getUuid(), r.getEntity().getUuid() );
+//
+//
+//        RelationManagerImpl impl = ( RelationManagerImpl ) em.getRelationManager( entity2Ref );
+//
+//        //now read the index and see what properties are there
+//
+//
+//        CassandraService cass = CoreITSuite.cassandraResource.getBean( CassandraService.class );
+//
+//        ByteBufferSerializer buf = ByteBufferSerializer.get();
+//
+//        Keyspace ko = cass.getApplicationKeyspace( applicationId );
+//        Mutator<ByteBuffer> m = createMutator( ko, buf );
+//
+//
+//        IndexUpdate update =
+//                impl.batchStartIndexUpdate( m, entity1Ref, "status", "ignore", UUIDUtils.newTimeUUID(), false, false,
+//                        true, false );
+//
+//        int count = 0;
+//
+//        IndexEntry lastMatch = null;
+//
+//        for ( IndexEntry entry : update.getPrevEntries() ) {
+//            if ( "status".equals( entry.getPath() ) ) {
+//                count++;
+//                lastMatch = entry;
+//            }
+//        }
+//
+//
+//        assertEquals( 1, count );
+//
+//        if ( lastMatch != null ) {
+//            assertEquals( "herring", lastMatch.getValue() );
+//        }
+//        else {
+//            fail( "The last match was null but should have been herring!" );
+//        }
+//    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index ee884f7..46c05c6 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -19,10 +19,8 @@ package org.apache.usergrid.persistence.index.impl;
 
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Maps;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.lang3.RandomStringUtils;
@@ -33,20 +31,15 @@ import org.apache.usergrid.persistence.index.EntityCollectionIndex;
 import org.apache.usergrid.persistence.index.EntitySearchResults;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.field.BooleanField;
-import org.apache.usergrid.persistence.model.field.DoubleField;
-import org.apache.usergrid.persistence.model.field.EntityObjectField;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.apache.usergrid.persistence.model.field.ListField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.StringField;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.persistence.utils.ElasticSearchRule;
+import org.apache.usergrid.test.EntityMapUtils;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.client.Client;
 import org.elasticsearch.index.query.QueryBuilder;
 import org.elasticsearch.index.query.QueryBuilders;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 import org.junit.Rule;
 import org.junit.Test;
 import static org.mockito.Mockito.mock;
@@ -86,7 +79,7 @@ public class EntityIndexTest {
             Map<String, Object> item = (Map<String, Object>)o;
 
             Entity entity = new Entity(new SimpleId(UUIDGenerator.newTimeUUID(), scope.getName()));
-            entity = EntityIndexTest.mapToEntity( scope.getName(), entity, item );
+            entity = EntityMapUtils.mapToEntity( scope.getName(), entity, item );
             EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
 
             entityIndex.index( entity );
@@ -171,136 +164,6 @@ public class EntityIndexTest {
     
     @Test
     public void testRemoveIndex() {
+        fail("Not implemented");
     }
-
-
-    /**
-     * Test of mapToEntity method, of class EntityUtils.
-     */
-    @Test
-    public void testMapToEntityRoundTrip() throws IOException {
-
-        InputStream is = this.getClass().getResourceAsStream( "/sample-large.json" );
-        ObjectMapper mapper = new ObjectMapper();
-        List<Object> contacts = mapper.readValue( is, new TypeReference<List<Object>>() {} );
-
-        for ( Object o : contacts ) {
-
-            Map<String, Object> map1 = (Map<String, Object>)o;
-
-            // convert map to entity
-            Entity entity1 = EntityIndexTest.mapToEntity( "testscope", map1 );
-
-            // convert entity back to map
-            Map map2 = EntityCollectionIndexImpl.entityToMap( entity1 );
-
-            // the two maps should be the same except for the two new _ug_analyzed properties
-            Map diff = Maps.difference( map1, map2 ).entriesDiffering();
-            assertEquals( 2, diff.size() );
-        }
-    }
-
-    
-    public static Entity mapToEntity( String scope, Map<String, Object> item ) {
-        return mapToEntity( scope, null, item );
-    }
-
-
-    public static Entity mapToEntity( String scope, Entity entity, Map<String, Object> map ) {
-
-        if ( entity == null ) {
-            entity = new Entity();
-        }
-
-        for ( String fieldName : map.keySet() ) {
-
-            Object value = map.get( fieldName );
-
-            if ( value instanceof String ) {
-                entity.setField( new StringField(fieldName, (String)value ));
-
-            } else if ( value instanceof Boolean ) {
-                entity.setField( new BooleanField(fieldName, (Boolean)value ));
-                        
-            } else if ( value instanceof Integer ) {
-                entity.setField( new IntegerField(fieldName, (Integer)value ));
-
-            } else if ( value instanceof Double ) {
-                entity.setField( new DoubleField(fieldName, (Double)value ));
-
-            } else if ( value instanceof Long ) {
-                entity.setField( new LongField(fieldName, (Long)value ));
-
-            } else if ( value instanceof List) {
-                entity.setField( listToListField( scope, fieldName, (List)value ));
-
-            } else if ( value instanceof Map ) {
-                entity.setField( new EntityObjectField( fieldName, 
-                    mapToEntity( scope, (Map<String, Object>)value ))); // recursion
-
-            } else {
-                throw new RuntimeException("Unknown type " + value.getClass().getName());
-            }
-        }
-
-        return entity;
-    }
-
-    
-    private static ListField listToListField( String scope, String fieldName, List list ) {
-
-        if (list.isEmpty()) {
-            return new ListField( fieldName );
-        }
-
-        Object sample = list.get(0);
-
-        if ( sample instanceof Map ) {
-            return new ListField<Entity>( fieldName, processListForField( scope, list ));
-
-        } else if ( sample instanceof List ) {
-            return new ListField<List>( fieldName, processListForField( scope, list ));
-            
-        } else if ( sample instanceof String ) {
-            return new ListField<String>( fieldName, (List<String>)list );
-                    
-        } else if ( sample instanceof Boolean ) {
-            return new ListField<Boolean>( fieldName, (List<Boolean>)list );
-                    
-        } else if ( sample instanceof Integer ) {
-            return new ListField<Integer>( fieldName, (List<Integer>)list );
-
-        } else if ( sample instanceof Double ) {
-            return new ListField<Double>( fieldName, (List<Double>)list );
-
-        } else if ( sample instanceof Long ) {
-            return new ListField<Long>( fieldName, (List<Long>)list );
-
-        } else {
-            throw new RuntimeException("Unknown type " + sample.getClass().getName());
-        }
-    }
-
-    
-    private static List processListForField( String scope, List list ) {
-        if ( list.isEmpty() ) {
-            return list;
-        }
-        Object sample = list.get(0);
-
-        if ( sample instanceof Map ) {
-            List<Entity> newList = new ArrayList<Entity>();
-            for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
-                newList.add( mapToEntity( scope, map ) );
-            }
-            return newList;
-
-        } else if ( sample instanceof List ) {
-            return processListForField( scope, list ); // recursion
-            
-        } else { 
-            return list;
-        } 
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
index fa46f4c..25f8dd1 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
@@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory;
 import org.apache.usergrid.persistence.query.Query.SortDirection;
 import org.apache.usergrid.persistence.query.Query.SortPredicate;
 import org.apache.usergrid.persistence.exceptions.QueryParseException;
-import org.apache.usergrid.persistence.query.Query;
 import org.apache.usergrid.persistence.query.tree.AndOperand;
 import org.apache.usergrid.persistence.query.tree.ContainsOperand;
 import org.apache.usergrid.persistence.query.tree.Equal;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/AbstractCoreIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/AbstractCoreIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/AbstractCoreIT.java
new file mode 100644
index 0000000..e2b8821
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/AbstractCoreIT.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012 Apigee Corporation
+ * 
+ * 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.test;
+
+
+import com.google.inject.Inject;
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.collection.cassandra.CassandraRule;
+import org.apache.usergrid.persistence.utils.JsonUtils;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public abstract class AbstractCoreIT {
+    private static final Logger LOG = LoggerFactory.getLogger( AbstractCoreIT.class );
+
+    @ClassRule
+    public static CassandraRule cass = new CassandraRule();
+
+    @ClassRule
+    public static CoreITSetup setup = new CoreITSetupImpl();
+
+    @Inject
+    public EntityCollectionManagerFactory factory;
+
+    @Rule
+    public CoreApplication app = new CoreApplication( setup );
+
+
+    public void dump( Object obj ) {
+        dump( "Object", obj );
+    }
+
+
+    public void dump( String name, Object obj ) {
+        if ( obj != null && LOG.isInfoEnabled() ) {
+            LOG.info( name + ":\n" + JsonUtils.mapToFormattedJsonString( obj ) );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/Application.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/Application.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/Application.java
new file mode 100644
index 0000000..d75455f
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/Application.java
@@ -0,0 +1,127 @@
+package org.apache.usergrid.test;
+
+
+import java.util.Map;
+import java.util.UUID;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Results;
+
+import org.junit.rules.TestRule;
+
+
+
+/**
+ * A Usergrid Application object used to simplify Test code by making it much more readable and removing unnecessary
+ * clutter due to boilerplate code. Use concrete instances of Application from various modules like {@link
+ * CoreApplication} with the Rule and ClassRule annotations to create unique Applications in Usergrid for use in
+ * testing.
+ */
+public interface Application extends TestRule {
+    /**
+     * Gets the Application's UUID.
+     *
+     * @return the UUID of the application
+     */
+    UUID getId();
+
+    /** Clears the properties associated with this Application. */
+    void clear();
+
+    /**
+     * Gets a property value managed by this Application.
+     *
+     * @param key the key associated with the property
+     *
+     * @return the value of the property
+     */
+    Object get( String key );
+
+    /**
+     * Puts a property value into the Application.
+     *
+     * @param property the key of the property
+     * @param value the value of the property
+     *
+     * @return the last value held by the property
+     */
+    Object put( String property, Object value );
+
+    /**
+     * Gets the Map of properties associated with this Application.
+     *
+     * @return the Map of properties associated with this Application
+     */
+    Map<String, Object> getProperties();
+
+    /**
+     * Gets the name of the organization this Application is associated with.
+     *
+     * @return the name of this Application's organization
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    String getOrgName();
+
+    /**
+     * Gets the name of this Application.
+     *
+     * @return the name of this Application
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    String getAppName();
+
+    /**
+     * Gets an entity associated with this Application based on it's type.
+     *
+     * @param type the type of the entity
+     *
+     * @return the entity
+     *
+     * @throws Exception if something goes wrong accessing the entity
+     */
+    Entity create( String type ) throws Exception;
+
+    /**
+     * Gets an entity associated with this Application by unique id.
+     *
+     * @param id the unique identifier for the entity associated with this Application
+     *
+     * @return the entity associated with this Application
+     *
+     * @throws Exception if anything goes wrong accessing the entity
+     */
+    Entity get( UUID id ) throws Exception;
+
+    
+    /**
+     * Adds an item to a collection associated with this Application.
+     *
+     * @param user the user adding the item
+     * @param collection the collection the item is added to
+     * @param item the entity being added to the collection
+     *
+     * @throws Exception if anything goes wrong adding the item to the specified collection
+     */
+    void addToCollection( Entity user, String collection, Entity item ) throws Exception;
+
+    /**
+     * Searches a collection for items satisfying a Query.
+     *
+     * @param user the user performing the query
+     * @param collection the collection being queried
+     * @param query the query to apply for selecting items in the collection
+     *
+     * @return the set of items resulting from the query
+     *
+     * @throws Exception if anything goes wrong querying the specified collection
+     */
+    Results searchCollection( Entity user, String collection, Query query ) throws Exception;
+
+
+    /**
+     * Puts all of the properties into this Application's properties.
+     *
+     * @param properties the Map of property key value pairs
+     */
+    void putAll( Map<String, Object> properties );
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CassandraService.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CassandraService.java
new file mode 100644
index 0000000..d080445
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CassandraService.java
@@ -0,0 +1,15 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.usergrid.test;
+
+/**
+ *
+ * @author ApigeeCorporation
+ */
+class CassandraService {
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreApplication.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreApplication.java
new file mode 100644
index 0000000..9b90a8e
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreApplication.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2012 Apigee Corporation
+ * 
+ * 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.test;
+
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Results;
+
+
+public class CoreApplication implements Application, TestRule {
+
+    private final static Logger LOG = LoggerFactory.getLogger( CoreApplication.class );
+    protected UUID id;
+    protected String appName;
+    protected String orgName;
+    protected CoreITSetup setup;
+    protected EntityManagerFacade em;
+    protected Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+
+    public CoreApplication( CoreITSetup setup ) {
+        this.setup = setup;
+    }
+
+
+    @Override
+    public void putAll( Map<String, Object> properties ) {
+        this.properties.putAll( properties );
+    }
+
+
+    @Override
+    public Object get( String key ) {
+        return properties.get( key );
+    }
+
+
+    @Override
+    public Map<String, Object> getProperties() {
+        return properties;
+    }
+
+
+    @Override
+    public UUID getId() {
+        return id;
+    }
+
+
+    @Override
+    public String getOrgName() {
+        return orgName;
+    }
+
+
+    @Override
+    public String getAppName() {
+        return appName;
+    }
+
+
+    @Override
+    public Entity create( String type ) throws Exception {
+        Entity entity = em.create( type, properties );
+        clear();
+        return entity;
+    }
+
+
+    @Override
+    public Object put( String property, Object value ) {
+        return properties.put( property, value );
+    }
+
+
+    @Override
+    public void clear() {
+        properties.clear();
+    }
+
+    @Override
+    public Entity get( UUID id ) throws Exception {
+        return em.get( id );
+    }
+
+
+    @Override
+    public Statement apply( final Statement base, final Description description ) {
+        return new Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                before( description );
+
+                try {
+                    base.evaluate();
+                }
+                finally {
+                    after( description );
+                }
+            }
+        };
+    }
+
+
+    protected void after( Description description ) {
+        LOG.info( "Test {}: finish with application", description.getDisplayName() );
+    }
+
+
+    protected void before( Description description ) throws Exception {
+    }
+
+
+    public EntityManagerFacade getEm() {
+        return em;
+    }
+
+    public void addToCollection( Entity user, String collection, Entity item ) throws Exception {
+        em.addToCollection( user, collection, item );
+    }
+
+    public Results searchCollection( Entity user, String collection, Query query ) throws Exception {
+        return em.searchCollection( user, collection, query );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreITSetup.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreITSetup.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreITSetup.java
new file mode 100644
index 0000000..efc6845
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreITSetup.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012 Apigee Corporation
+ * 
+ * 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.test;
+
+
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.junit.rules.TestRule;
+
+
+public interface CoreITSetup extends TestRule {
+
+    EntityCollectionManagerFactory getEmf();
+
+    void dump( String name, Object obj );
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreITSetupImpl.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreITSetupImpl.java
new file mode 100644
index 0000000..da819db
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/CoreITSetupImpl.java
@@ -0,0 +1,80 @@
+package org.apache.usergrid.test;
+
+
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.utils.JsonUtils;
+
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class CoreITSetupImpl implements CoreITSetup {
+    private static final Logger LOG = LoggerFactory.getLogger( CoreITSetupImpl.class );
+
+    protected EntityCollectionManagerFactory emf;
+    protected CassandraService cassandraService;
+    protected boolean enabled = false;
+
+
+//    public CoreITSetupImpl( CassandraResource cassandraResource ) {
+//        this.cassandraResource = cassandraResource;
+//    }
+
+
+    @Override
+    public Statement apply( Statement base, Description description ) {
+        return statement( base, description );
+    }
+
+
+    private Statement statement( final Statement base, final Description description ) {
+        return new Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                before( description );
+
+                try {
+                    base.evaluate();
+                }
+                finally {
+                    after( description );
+                }
+            }
+        };
+    }
+
+
+    /**
+     * Sets up the resources for the test here.
+     *
+     * @throws Throwable if setup fails (which will disable {@code after}
+     */
+    protected void before( Description description ) throws Throwable {
+        LOG.info( "Setting up for {}", description.getDisplayName() );
+        initialize();
+    }
+
+
+    private void initialize() {
+    }
+
+
+    /** Override to tear down your specific external resource. */
+    protected void after( Description description ) {
+        LOG.info( "Tearing down for {}", description.getDisplayName() );
+    }
+
+
+    @Override
+    public void dump( String name, Object obj ) {
+        if ( obj != null && LOG.isInfoEnabled() ) {
+            LOG.info( name + ":\n" + JsonUtils.mapToFormattedJsonString( obj ) );
+        }
+    }
+
+    public EntityCollectionManagerFactory getEmf() {
+        return emf;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/EntityManagerFacade.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/EntityManagerFacade.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/EntityManagerFacade.java
new file mode 100644
index 0000000..5a0283b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/EntityManagerFacade.java
@@ -0,0 +1,61 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.usergrid.test;
+
+import java.util.Map;
+import java.util.UUID;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerSync;
+import org.apache.usergrid.persistence.collection.util.EntityUtils;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Results;
+
+/**
+ *
+ * @author ApigeeCorporation
+ */
+public class EntityManagerFacade {
+    private final EntityCollectionManagerFactory factory;
+    private final EntityCollectionManagerSync ecm;
+    private final CollectionScope scope;
+    
+    public EntityManagerFacade( EntityCollectionManagerFactory factory, CollectionScope scope ) {
+        this.factory = factory;
+        this.ecm = factory.createCollectionManagerSync( scope );
+        this.scope = scope;
+    }
+
+    public Entity create( String type, Map<String, Object> properties ) {
+        if ( type.equals( scope.getName() )) { 
+            throw new RuntimeException("Incorrect type [" + type + "] for scope: " + scope.getName());
+        }
+        Entity entity = new Entity( new SimpleId( type ) );
+        EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
+        return ecm.write( entity );
+    }
+
+    public Entity get( UUID id ) {
+        throw new UnsupportedOperationException( "Not supported yet." );
+    }
+
+    public void addToCollection( Entity user, String collection, Entity item ) {
+        throw new UnsupportedOperationException( "Not supported yet." );
+    }
+
+    public Results searchCollection( Entity user, String collection, Query query ) {
+        throw new UnsupportedOperationException( "Not supported yet." );
+    }
+
+    public Entity getApplicationRef() {
+        return null; 
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/EntityMapUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/EntityMapUtils.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/EntityMapUtils.java
new file mode 100644
index 0000000..3fbb632
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/test/EntityMapUtils.java
@@ -0,0 +1,165 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.usergrid.test;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.usergrid.persistence.index.impl.EntityCollectionIndexImpl;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.field.BooleanField;
+import org.apache.usergrid.persistence.model.field.DoubleField;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+/**
+ *
+ * @author ApigeeCorporation
+ */
+public class EntityMapUtils {
+   
+    /**
+     * Test of mapToEntity method, of class EntityUtils.
+     */
+    @Test
+    public void testMapToEntityRoundTrip() throws IOException {
+
+        InputStream is = this.getClass().getResourceAsStream( "/sample-large.json" );
+        ObjectMapper mapper = new ObjectMapper();
+        List<Object> contacts = mapper.readValue( is, new TypeReference<List<Object>>() {} );
+
+        for ( Object o : contacts ) {
+
+            Map<String, Object> map1 = (Map<String, Object>)o;
+
+            // convert map to entity
+            Entity entity1 = EntityMapUtils.mapToEntity( "testscope", map1 );
+
+            // convert entity back to map
+            Map map2 = EntityCollectionIndexImpl.entityToMap( entity1 );
+
+            // the two maps should be the same except for the two new _ug_analyzed properties
+            Map diff = Maps.difference( map1, map2 ).entriesDiffering();
+            assertEquals( 2, diff.size() );
+        }
+    }
+
+    
+    public static Entity mapToEntity( String scope, Map<String, Object> item ) {
+        return mapToEntity( scope, null, item );
+    }
+
+
+    public static Entity mapToEntity( String scope, Entity entity, Map<String, Object> map ) {
+
+        if ( entity == null ) {
+            entity = new Entity();
+        }
+
+        for ( String fieldName : map.keySet() ) {
+
+            Object value = map.get( fieldName );
+
+            if ( value instanceof String ) {
+                entity.setField( new StringField(fieldName, (String)value ));
+
+            } else if ( value instanceof Boolean ) {
+                entity.setField( new BooleanField(fieldName, (Boolean)value ));
+                        
+            } else if ( value instanceof Integer ) {
+                entity.setField( new IntegerField(fieldName, (Integer)value ));
+
+            } else if ( value instanceof Double ) {
+                entity.setField( new DoubleField(fieldName, (Double)value ));
+
+            } else if ( value instanceof Long ) {
+                entity.setField( new LongField(fieldName, (Long)value ));
+
+            } else if ( value instanceof List) {
+                entity.setField( listToListField( scope, fieldName, (List)value ));
+
+            } else if ( value instanceof Map ) {
+                entity.setField( new EntityObjectField( fieldName, 
+                    mapToEntity( scope, (Map<String, Object>)value ))); // recursion
+
+            } else {
+                throw new RuntimeException("Unknown type " + value.getClass().getName());
+            }
+        }
+
+        return entity;
+    }
+
+    
+    private static ListField listToListField( String scope, String fieldName, List list ) {
+
+        if (list.isEmpty()) {
+            return new ListField( fieldName );
+        }
+
+        Object sample = list.get(0);
+
+        if ( sample instanceof Map ) {
+            return new ListField<Entity>( fieldName, processListForField( scope, list ));
+
+        } else if ( sample instanceof List ) {
+            return new ListField<List>( fieldName, processListForField( scope, list ));
+            
+        } else if ( sample instanceof String ) {
+            return new ListField<String>( fieldName, (List<String>)list );
+                    
+        } else if ( sample instanceof Boolean ) {
+            return new ListField<Boolean>( fieldName, (List<Boolean>)list );
+                    
+        } else if ( sample instanceof Integer ) {
+            return new ListField<Integer>( fieldName, (List<Integer>)list );
+
+        } else if ( sample instanceof Double ) {
+            return new ListField<Double>( fieldName, (List<Double>)list );
+
+        } else if ( sample instanceof Long ) {
+            return new ListField<Long>( fieldName, (List<Long>)list );
+
+        } else {
+            throw new RuntimeException("Unknown type " + sample.getClass().getName());
+        }
+    }
+
+    
+    private static List processListForField( String scope, List list ) {
+        if ( list.isEmpty() ) {
+            return list;
+        }
+        Object sample = list.get(0);
+
+        if ( sample instanceof Map ) {
+            List<Entity> newList = new ArrayList<Entity>();
+            for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
+                newList.add( mapToEntity( scope, map ) );
+            }
+            return newList;
+
+        } else if ( sample instanceof List ) {
+            return processListForField( scope, list ); // recursion
+            
+        } else { 
+            return list;
+        } 
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties b/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties
new file mode 100644
index 0000000..e656ddd
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties
@@ -0,0 +1,12 @@
+# The properties are not the actual configuration properties but
+# safe dynamic property defaults for our testing via IDE or Maven
+cassandra.connections=10
+cassandra.port=9160
+cassandra.version=1.2
+cassandra.hosts=localhost
+cassandra.cluster_name=Usergrid
+collections.keyspace=Usergrid_Collections
+cassandra.timeout=5000
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties b/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties
new file mode 100644
index 0000000..d9c72be
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties
@@ -0,0 +1,12 @@
+# These are for CHOP environment settings
+
+cassandra.connections=20
+cassandra.port=9160
+cassandra.version=1.2
+
+# a comma delimited private IP address list to your chop cassandra cluster
+# define this in your settings.xml and have it as an always active profile
+cassandra.hosts=${chop.cassandra.hosts}
+cassandra.cluster_name=Usergrid
+collections.keyspace=Usergrid_Collections
+cassandra.timeout=5000

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties b/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties
new file mode 100644
index 0000000..152693a
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties
@@ -0,0 +1,14 @@
+# Keep nothing but overriding test defaults in here
+cassandra.connections=10
+cassandra.port=9160
+cassandra.version=1.2
+cassandra.hosts=localhost
+cassandra.cluster_name=Usergrid
+collections.keyspace=Usergrid_Collections
+cassandra.timeout=5000
+
+
+collections.keyspace.replicationfactor=1
+collections.keyspace.strategy.options=
+collection.stage.transient.timeout=60
+collections.keyspace.strategy.class=org.apache.cassandra.locator.SimpleStrategy

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ff6002a9/stack/corepersistence/queryindex/src/test/resources/usergrid.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/usergrid.properties b/stack/corepersistence/queryindex/src/test/resources/usergrid.properties
new file mode 100644
index 0000000..febda88
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/resources/usergrid.properties
@@ -0,0 +1 @@
+# No properties in our test env


Mime
View raw message