usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [03/23] incubator-usergrid git commit: [USERGRID-320] Added base class for common methods for query tests
Date Mon, 26 Jan 2015 14:24:02 GMT
[USERGRID-320] Added base class for common methods for query tests


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

Branch: refs/heads/two-dot-o-import
Commit: b07d52df290ddfae093f30a962b72fa814851f94
Parents: 5c23a7f
Author: ryan bridges <rbridges@apigee.com>
Authored: Mon Jan 12 10:54:41 2015 -0500
Committer: ryan bridges <rbridges@apigee.com>
Committed: Mon Jan 12 10:54:41 2015 -0500

----------------------------------------------------------------------
 .../applications/queries/QueryTestBase.java     | 56 ++++++++++++++++++++
 1 file changed, 56 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b07d52df/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
new file mode 100644
index 0000000..b9287da
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
@@ -0,0 +1,56 @@
+package org.apache.usergrid.rest.applications.queries;
+
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A base class containing common methods used by query tests
+ */
+public class QueryTestBase  extends AbstractRestIT {
+    private static Logger log = LoggerFactory.getLogger(QueryTestBase.class);
+    /**
+     * Create a number of entities in the specified collection
+     * with properties to make them independently searchable
+     *
+     * @param numberOfEntities
+     * @param collectionName
+     * @return an array of the Entity objects created
+     */
+    protected Entity[] generateTestEntities(int numberOfEntities, String collectionName)
{
+        Entity[] entities = new Entity[numberOfEntities];
+        Entity props = new Entity();
+        //Insert the desired number of entities
+        for (int i = 0; i < numberOfEntities; i++) {
+            Entity actor = new Entity();
+            actor.put("displayName", String.format("Test User %d", i));
+            actor.put("username", String.format("user%d", i));
+            props.put("actor", actor);
+            //give each entity a unique, numeric ordinal value
+            props.put("ordinal", i);
+            //Set half the entities to have a 'madeup' property of 'true'
+            // and set the other half to 'false'
+            if (i < numberOfEntities / 2) {
+                props.put("madeup", false);
+            } else {
+                props.put("madeup", true);
+            }
+            //Set even-numbered users to have a verb of 'go' and the rest to 'stop'
+            if (i % 2 == 0) {
+                props.put("verb", "go");
+            } else {
+                props.put("verb", "stop");
+            }
+            //create the entity in the desired collection and add it to the return array
+            entities[i] = this.app().collection(collectionName).post(props);
+            log.info(entities[i].entrySet().toString());
+        }
+        //refresh the index so that they are immediately searchable
+        this.refreshIndex();
+
+        return entities;
+    }
+
+
+}


Mime
View raw message