change test collection names so no race condition conflicts
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
index 4bdd3fc..d49460c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
@@ -47,20 +47,20 @@
@Test
public void queryAndInclusive() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "apples";
// create our test entities
generateTestEntities(numOfEntities, collectionName);
// Query where madeup = true (the last half) and the last quarter of entries
QueryParameters params = new QueryParameters()
.setQuery("select * where madeup = true AND ordinal >= " + (numOfEntities - numOfEntities / 4));
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
// results should have madeup = true and ordinal 15-19
- assertEquals(numOfEntities / 4, activities.getResponse().getEntityCount());
+ assertEquals(numOfEntities / 4, coll.getResponse().getEntityCount());
// loop though entities that were returned, and test against the ordinals and values we are
// expecting, starting with the last entity and decrementing
int index = 19;
- while (activities.hasNext()) {
- Entity activity = activities.next();
+ while (coll.hasNext()) {
+ Entity activity = coll.next();
// ensure the 'madeup' property is set to true
assertTrue(Boolean.parseBoolean(activity.get("madeup").toString()));
// make sure the correct ordinal properties are returned
@@ -71,15 +71,15 @@
@Test
public void someTestProp() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "bananas";
// create our test entities
generateTestEntities(numOfEntities, collectionName);
// Query where madeup = true (the last half) and the last quarter of entries
QueryParameters params = new QueryParameters()
.setQuery("where sometestprop = 'testprop'");
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
// results should have madeup = true and ordinal 15-19
- assertEquals(10, activities.getResponse().getEntityCount());
+ assertEquals(10, coll.getResponse().getEntityCount());
}
@@ -87,15 +87,15 @@
@Test
public void someTestPropPartialContains() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "cantaloupes";
// create our test entities
generateTestEntities(numOfEntities, collectionName);
// Query where madeup = true (the last half) and the last quarter of entries
QueryParameters params = new QueryParameters()
.setQuery("where sometestprop contains 'test*'");
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
// results should have madeup = true and ordinal 15-19
- assertEquals(10, activities.getResponse().getEntityCount());
+ assertEquals(10, coll.getResponse().getEntityCount());
}
@@ -108,25 +108,25 @@
@Test
public void queryAndExclusive() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "dates";
generateTestEntities(numOfEntities, collectionName);
//Query where madeup = true (the last half) and NOT the last quarter of entries
QueryParameters params = new QueryParameters()
.setQuery("select * where madeup = true AND NOT ordinal >= " + (numOfEntities - numOfEntities / 4));
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
//results should have madeup = true and ordinal 10-14
- assertEquals(numOfEntities / 4, activities.getResponse().getEntityCount());
+ assertEquals(numOfEntities / 4, coll.getResponse().getEntityCount());
// loop though entities that were returned, and test against the ordinals and values we are
// expecting, starting with the last expected entity and decrementing
int index = 14;
- while (activities.hasNext()) {
- Entity activity = activities.next();
+ while (coll.hasNext()) {
+ Entity entity = coll.next();
//ensure the 'madeup' property is set to true
- assertTrue(Boolean.parseBoolean(activity.get("madeup").toString()));
+ assertTrue(Boolean.parseBoolean(entity.get("madeup").toString()));
//make sure the correct ordinal properties are returned
- assertEquals(index--, Long.parseLong(activity.get("ordinal").toString()));
+ assertEquals(index--, Long.parseLong(entity.get("ordinal").toString()));
}
}
@@ -138,7 +138,7 @@
@Test
public void queryOrInclusive() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "elderberries";
generateTestEntities(numOfEntities, collectionName);
@@ -146,26 +146,26 @@
QueryParameters params = new QueryParameters()
.setQuery("select * where madeup = false OR ordinal >= " + (numOfEntities - numOfEntities / 4))
.setLimit((numOfEntities));
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
int index = numOfEntities - 1;
int count = 0;
- int returnSize = activities.getResponse().getEntityCount();
+ int returnSize = coll.getResponse().getEntityCount();
//loop through the returned results
for (int i = 0; i < returnSize; i++, index--) {
count++;
- Entity activity = activities.getResponse().getEntities().get(i);
- logger.info(String.valueOf(activity.get("ordinal")) + " " + String.valueOf(activity.get("madeup")));
+ Entity entity = coll.getResponse().getEntities().get(i);
+ logger.info(String.valueOf(entity.get("ordinal")) + " " + String.valueOf(entity.get("madeup")));
//if the entity is in the first half, the property "madeup" should be false
if (index < numOfEntities / 2) {
- assertFalse(Boolean.parseBoolean(String.valueOf(activity.get("madeup"))));
+ assertFalse(Boolean.parseBoolean(String.valueOf(entity.get("madeup"))));
}
//else if the entity is in the second half, the property "madeup" should be true
else if (index >= (numOfEntities - numOfEntities / 4)) {
- assertTrue(Boolean.parseBoolean(String.valueOf(activity.get("madeup"))));
+ assertTrue(Boolean.parseBoolean(String.valueOf(entity.get("madeup"))));
}
//test to ensure that the ordinal is in the first half (where "madeup = false")
//OR that the ordinal is in the last quarter of the entity list (where "ordinal >= (numOfEntities - numOfEntities / 4))")
- long ordinal = Long.parseLong(String.valueOf(activity.get("ordinal")));
+ long ordinal = Long.parseLong(String.valueOf(entity.get("ordinal")));
assertTrue(ordinal < (numOfEntities / 2) || ordinal >= (numOfEntities - numOfEntities / 4));
}
//results should have madeup = false or ordinal 0-9,15-19
@@ -181,7 +181,7 @@
@Test
public void queryOrExclusive() throws IOException {
int numOfEntities = 30;
- String collectionName = "activities";
+ String collectionName = "figs";
generateTestEntities(numOfEntities, collectionName);
@@ -189,23 +189,23 @@
QueryParameters params = new QueryParameters()
.setQuery("select * where (verb = 'go' OR ordinal >= " + (numOfEntities - numOfEntities / 4) + ") AND NOT (verb = 'go' AND ordinal >= " + (numOfEntities - numOfEntities / 4) + ")")
.setLimit((numOfEntities));
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
int index = numOfEntities - 1;
int count = 0;
- int returnSize = activities.getResponse().getEntityCount();
+ int returnSize = coll.getResponse().getEntityCount();
for (int i = 0; i < returnSize; i++, index--) {
count++;
- Entity activity = activities.getResponse().getEntities().get(i);
- long ordinal = Long.parseLong(String.valueOf(activity.get("ordinal")));
- logger.info(ordinal + " " + String.valueOf(activity.get("verb")));
+ Entity entity = coll.getResponse().getEntities().get(i);
+ long ordinal = Long.parseLong(String.valueOf(entity.get("ordinal")));
+ logger.info(ordinal + " " + String.valueOf(entity.get("verb")));
//if the entity is in the first three quarters, the property "verb" should be "go"
if (ordinal < (numOfEntities - numOfEntities / 4)) {
- assertEquals("go", String.valueOf(activity.get("verb")));
+ assertEquals("go", String.valueOf(entity.get("verb")));
}
//if the entity is in the last quarter, the property "verb" should be "stop"
else if (ordinal >= (numOfEntities - numOfEntities / 4)) {
- assertEquals("stop", String.valueOf(activity.get("verb")));
+ assertEquals("stop", String.valueOf(entity.get("verb")));
}
}
//results should be even ordinals in the first 3 quarters and odd ordinals from the last quarter
@@ -225,17 +225,18 @@
public void queryWithAndPastLimit() throws IOException {
int numValuesTested = 40;
- generateTestEntities(numValuesTested, "activities");
+ String collectionName = "grapes";
+ generateTestEntities(numValuesTested, collectionName);
//3. Query all entities where "madeup = true"
String errorQuery = "select * where madeup = true";
QueryParameters params = new QueryParameters()
.setQuery(errorQuery)
.setLimit(numValuesTested / 2);//4. Limit the query to half of the number of entities
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
//5. Ensure the correct entities are returned
- assertEquals(numValuesTested / 2, activities.getResponse().getEntityCount());
- while (activities.hasNext()) {
- assertTrue(Boolean.parseBoolean(activities.next().get("madeup").toString()));
+ assertEquals(numValuesTested / 2, coll.getResponse().getEntityCount());
+ while (coll.hasNext()) {
+ assertTrue(Boolean.parseBoolean(coll.next().get("madeup").toString()));
}
}
@@ -252,16 +253,17 @@
public void queryNegated() throws IOException {
int numValuesTested = 20;
- generateTestEntities(numValuesTested, "activities");
+ String collectionName = "huckleberries";
+ generateTestEntities(numValuesTested, collectionName);
//1. Query all entities where "NOT verb = 'go'"
String query = "select * where not verb = 'go'";
//2. Limit the query to half of the number of entities
QueryParameters params = new QueryParameters().setQuery(query).setLimit(numValuesTested / 2);
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
//3. Ensure the returned entities have "verb = 'stop'"
- assertEquals(numValuesTested / 2, activities.getResponse().getEntityCount());
- while (activities.hasNext()) {
- assertEquals("stop", activities.next().get("verb").toString());
+ assertEquals(numValuesTested / 2, coll.getResponse().getEntityCount());
+ while (coll.hasNext()) {
+ assertEquals("stop", coll.next().get("verb").toString());
}
@@ -278,15 +280,16 @@
public void queryReturnCount() throws Exception {
int numValuesTested = 20;
- generateTestEntities(numValuesTested, "activities");
+ String collectionName = "lemons";
+ generateTestEntities(numValuesTested, collectionName);
//1. Query for a subset of the entities
String inCorrectQuery = "select * where ordinal >= " + (numValuesTested / 2) + " order by ordinal asc";
QueryParameters params = new QueryParameters().setQuery(inCorrectQuery).setLimit(numValuesTested / 2);
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
//2. Validate that the correct entities are returned
- assertEquals(numValuesTested / 2, activities.getResponse().getEntityCount());
+ assertEquals(numValuesTested / 2, coll.getResponse().getEntityCount());
- List<Entity> entitiesReturned = activities.getResponse().getEntities();
+ List<Entity> entitiesReturned = coll.getResponse().getEntities();
for (int i = 0; i < numValuesTested / 2; i++) {
assertEquals(numValuesTested / 2 + i, Integer.parseInt(entitiesReturned.get(i).get("ordinal").toString()));
}
@@ -303,7 +306,7 @@
@Test
public void queryCheckAsc() throws Exception {
int numOfEntities = 20;
- String collectionName = "imagination";
+ String collectionName = "melons";
generateTestEntities(numOfEntities, collectionName);
@@ -332,18 +335,18 @@
@Test
public void queryReturnCheck() throws Exception {
int numOfEntities = 20;
- String collectionName = "imagination";
+ String collectionName = "nectarines";
generateTestEntities(numOfEntities, collectionName);
//2. Issue a query
String inquisitiveQuery = String.format("select * where ordinal >= 0 and ordinal <= %d or WhoHelpedYou = 'Ruff' ORDER BY created", numOfEntities);
QueryParameters params = new QueryParameters().setQuery(inquisitiveQuery);
- Collection activities = this.app().collection(collectionName).get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
//3. validate that a full page of (10) entities is returned
- assertEquals(10, activities.getResponse().getEntityCount());
- List<Entity> entitiesReturned = activities.getResponse().getEntities();
+ assertEquals(10, coll.getResponse().getEntityCount());
+ List<Entity> entitiesReturned = coll.getResponse().getEntities();
for (int i = 0; i < 10; i++) {
assertEquals(i, Integer.parseInt(entitiesReturned.get(i).get("ordinal").toString()));
}
@@ -359,7 +362,7 @@
@Test
public void queryReturnCheckWithShortHand() throws Exception {
int numOfEntities = 10;
- String collectionName = "imagination";
+ String collectionName = "oranges";
generateTestEntities(numOfEntities, collectionName);
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
index 0692667..950d59d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
@@ -69,7 +69,7 @@
public void exceptionOnDoubleQuotes() throws IOException {
int numOfEntities = 1;
- String collectionName = "things";
+ String collectionName = "otherthings";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
@@ -95,7 +95,7 @@
public void exceptionOnMissingQuotes() throws IOException {
int numOfEntities = 1;
- String collectionName = "things";
+ String collectionName = "stillotherthings";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
@@ -121,7 +121,7 @@
public void exceptionOnMissingProperty() throws IOException {
int numOfEntities = 1;
- String collectionName = "things";
+ String collectionName = "yetotherthings";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
@@ -147,7 +147,7 @@
public void exceptionOnMissingPropertyValue() throws IOException {
int numOfEntities = 1;
- String collectionName = "things";
+ String collectionName = "thesethings";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
@@ -173,7 +173,7 @@
public void exceptionOnMissingOperator() throws IOException {
int numOfEntities = 1;
- String collectionName = "things";
+ String collectionName = "thosethings";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
@@ -200,7 +200,7 @@
public void limitInQuery() throws IOException {
int numOfEntities =1;
- String collectionName = "things";
+ String collectionName = "whatthings";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
index 6591713..e9bb021 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
@@ -41,21 +41,21 @@
@Test
public void orderByLongAsc() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "beans";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
QueryParameters params = new QueryParameters()
.setQuery("select * order by ordinal asc")
.setLimit(numOfEntities);
- Collection activities = this.app().collection("activities").get(params);
- assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+ Collection coll = this.app().collection(collectionName).get(params);
+ assertEquals(numOfEntities, coll.getResponse().getEntityCount());
//results should be ordered by ordinal
int index = 0;
- while (activities.hasNext()) {
- Entity activity = activities.next();
+ while (coll.hasNext()) {
+ Entity entity = coll.next();
//make sure the correct ordinal properties are returned
- assertEquals(index++, Long.parseLong(activity.get("ordinal").toString()));
+ assertEquals(index++, Long.parseLong(entity.get("ordinal").toString()));
}
}
@@ -68,23 +68,23 @@
@Test
public void orderByLongDesc() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "chickpeas";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
QueryParameters params = new QueryParameters()
.setQuery("select * order by ordinal desc")
.setLimit(numOfEntities);
- Collection activities = this.app().collection("activities").get(params);
- assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+ Collection coll = this.app().collection(collectionName).get(params);
+ assertEquals(numOfEntities, coll.getResponse().getEntityCount());
//Since the sort order is descending, start at the last entity we created
int index = numOfEntities - 1;
//results should be sorted by ordinal
- while (activities.hasNext()) {
- Entity activity = activities.next();
+ while (coll.hasNext()) {
+ Entity entity = coll.next();
//make sure the correct ordinal properties are returned
//decrement the index to get the next entity in reverse order
- assertEquals(index--, Long.parseLong(activity.get("ordinal").toString()));
+ assertEquals(index--, Long.parseLong(entity.get("ordinal").toString()));
}
}
@@ -96,25 +96,25 @@
@Test
public void orderByBooleanAsc() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "lentils";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
QueryParameters params = new QueryParameters()
.setQuery("select * order by madeup asc")
.setLimit(numOfEntities);
- Collection activities = this.app().collection("activities").get(params);
- assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+ Collection coll = this.app().collection(collectionName).get(params);
+ assertEquals(numOfEntities, coll.getResponse().getEntityCount());
int index = 0;
//results should be sorted false, then true
//The first half of entities returned should have "madeup = false"
//The second half of entities returned should have "madeup = true"
- while (activities.hasNext()) {
- Entity activity = activities.next();
+ while (coll.hasNext()) {
+ Entity entity = coll.next();
if (index++ < numOfEntities / 2) {
- assertEquals("false", activity.get("madeup").toString());
+ assertEquals("false", entity.get("madeup").toString());
} else {
- assertEquals("true", activity.get("madeup").toString());
+ assertEquals("true", entity.get("madeup").toString());
}
}
}
@@ -127,26 +127,26 @@
@Test
public void orderByBooleanDesc() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "peas";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
QueryParameters params = new QueryParameters()
.setQuery("select * order by madeup desc")
.setLimit(numOfEntities);
- Collection activities = this.app().collection("activities").get(params);
- assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+ Collection coll = this.app().collection(collectionName).get(params);
+ assertEquals(numOfEntities, coll.getResponse().getEntityCount());
int index = 0;
//results should be sorted true, then false
- while (activities.hasNext()) {
- Entity activity = activities.next();
+ while (coll.hasNext()) {
+ Entity entity = coll.next();
//make sure the booleans are ordered correctly
//The first half of entities returned should have "madeup = true"
//The second half of entities returned should have "madeup = false"
if (index++ < numOfEntities / 2) {
- assertEquals("true", activity.get("madeup").toString());
+ assertEquals("true", entity.get("madeup").toString());
} else {
- assertEquals("false", activity.get("madeup").toString());
+ assertEquals("false", entity.get("madeup").toString());
}
}
}
@@ -159,25 +159,25 @@
@Test
public void orderByStringAsc() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "carrots";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
//Sort by the "verb" property to test alphabetical sorting of string properties
QueryParameters params = new QueryParameters()
.setQuery("select * order by verb asc")
.setLimit(numOfEntities);
- Collection activities = this.app().collection("activities").get(params);
- assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+ Collection coll = this.app().collection(collectionName).get(params);
+ assertEquals(numOfEntities, coll.getResponse().getEntityCount());
int index = 0;
//results should be sorted "go", then "stop"
- while (activities.hasNext()) {
- Entity activity = activities.next();
+ while (coll.hasNext()) {
+ Entity entity = coll.next();
//The first half of entities returned should have "verb = 'go'"
//The second half of entities returned should have "verb = 'stop'"
if (index++ < numOfEntities / 2) {
- assertEquals("go", activity.get("verb").toString());
+ assertEquals("go", entity.get("verb").toString());
} else {
- assertEquals("stop", activity.get("verb").toString());
+ assertEquals("stop", entity.get("verb").toString());
}
}
}
@@ -190,7 +190,7 @@
@Test
public void orderByStringDesc() throws IOException {
int numOfEntities = 20;
- String collectionName = "activities";
+ String collectionName = "celery";
//create our test entities
generateTestEntities(numOfEntities, collectionName);
@@ -198,18 +198,18 @@
QueryParameters params = new QueryParameters()
.setQuery("select * order by verb desc")
.setLimit(numOfEntities);
- Collection activities = this.app().collection("activities").get(params);
- assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+ Collection coll = this.app().collection(collectionName).get(params);
+ assertEquals(numOfEntities, coll.getResponse().getEntityCount());
int index = 0;
//results should be sorted "stop", then "go"
- while (activities.hasNext()) {
- Entity activity = activities.next();
+ while (coll.hasNext()) {
+ Entity entity = coll.next();
//The first half of entities returned should have "verb = 'stop'"
//The second half of entities returned should have "verb = 'go'"
if (index++ < numOfEntities / 2) {
- assertEquals("stop", activity.get("verb").toString());
+ assertEquals("stop", entity.get("verb").toString());
} else {
- assertEquals("go", activity.get("verb").toString());
+ assertEquals("go", entity.get("verb").toString());
}
}
@@ -229,6 +229,7 @@
@Test
public void orderByShouldNotAffectResults() throws IOException {
+ String collectionName = "mushrooms";
long created = 0;
Entity actor = new Entity();
actor.put("displayName", "Erin");
@@ -239,10 +240,10 @@
//1. Insert entities
for (int i = 0; i < 20; i++) {
props.put("ordinal", i);
- Entity activity = this.app().collection("activity").post(props);
- logger.info("Created", activity.get("created").toString());
+ Entity entity = this.app().collection(collectionName).post(props);
+ logger.info("Created", entity.get("created").toString());
if (i == 5) {
- created = Long.parseLong(activity.get("created").toString());
+ created = Long.parseLong(entity.get("created").toString());
}
}
@@ -250,18 +251,18 @@
//2. Query without 'order by'
String query = "select * where created > " + created;
QueryParameters params = new QueryParameters().setQuery(query);
- Collection activitiesWithoutOrderBy = this.app().collection("activities").get(params);
- assertEquals(10, activitiesWithoutOrderBy.getResponse().getEntityCount());
+ Collection entitiesWithoutOrderBy = this.app().collection(collectionName).get(params);
+ assertEquals(10, entitiesWithoutOrderBy.getResponse().getEntityCount());
//3. Query with 'order by'
query = query + " order by created desc";
params.setQuery(query);
- Collection activitiesWithOrderBy = this.app().collection("activities").get(params);
+ Collection activitiesWithOrderBy = this.app().collection(collectionName).get(params);
assertEquals(10, activitiesWithOrderBy.getResponse().getEntityCount());
//4. Ensure the same entities are returned
- while (activitiesWithoutOrderBy.hasNext() && activitiesWithOrderBy.hasNext()) {
- Entity activityWithoutOrderBy = activitiesWithoutOrderBy.next();
- Entity activityWithOrderBy = activitiesWithOrderBy.next();
- assertEquals(activityWithoutOrderBy.get("uuid").toString(), activityWithOrderBy.get("uuid").toString());
+ while (entitiesWithoutOrderBy.hasNext() && activitiesWithOrderBy.hasNext()) {
+ Entity entityWithoutOrderBy = entitiesWithoutOrderBy.next();
+ Entity entityWithOrderBy = activitiesWithOrderBy.next();
+ assertEquals(entityWithoutOrderBy.get("uuid").toString(), entityWithOrderBy.get("uuid").toString());
}
}
@@ -277,6 +278,7 @@
@Test
public void orderByComesBeforeLimitResult() throws IOException {
+ String collectionName = "onions";
Entity actor = new Entity();
actor.put("displayName", "Erin");
Entity props = new Entity();
@@ -286,23 +288,23 @@
//1. Insert entities
for (int i = 0; i < 20; i++) {
props.put("ordinal", i);
- this.app().collection("activity").post(props);
+ this.app().collection(collectionName).post(props);
}
waitForQueueDrainAndRefreshIndex();
//2. Query a subset of the entities, specifying order and limit
String query = "select * where created > " + 1 + " order by created desc";
QueryParameters params = new QueryParameters().setQuery(query).setLimit(5);
- Collection activities = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
//3. Ensure the correct number of results are returned
- assertEquals(5, activities.getResponse().getEntityCount());
+ assertEquals(5, coll.getResponse().getEntityCount());
//2. Query a subset of the entities, specifying order and limit
query = " where created > " + 1 + " order by created desc";
params = new QueryParameters().setQuery(query).setLimit(5);
- activities = this.app().collection("activities").get(params);
+ coll = this.app().collection(collectionName).get(params);
//3. Ensure the correct number of results are returned
- assertEquals(5, activities.getResponse().getEntityCount());
+ assertEquals(5, coll.getResponse().getEntityCount());
}
/**
@@ -316,8 +318,9 @@
@Test
public void orderByReturnCorrectResults() throws IOException {
+ String collectionName = "peppers";
int size = 20;
- Entity[] activities = new Entity[size];
+ Entity[] entities = new Entity[size];
Entity actor = new Entity();
actor.put("displayName", "Erin");
@@ -328,34 +331,34 @@
//1. Insert a number of entities and add them to an array
for (int i = 0; i < size; i++) {
props.put("ordinal", i);
- Entity e = this.app().collection("activity").post(props);
- activities[i] = e;
+ Entity e = this.app().collection(collectionName).post(props);
+ entities[i] = e;
logger.info(String.valueOf(e.get("uuid").toString()));
- logger.info(String.valueOf(Long.parseLong(activities[0].get("created").toString())));
+ logger.info(String.valueOf(Long.parseLong(entities[0].get("created").toString())));
}
waitForQueueDrainAndRefreshIndex(750);
- ArrayUtils.reverse(activities);
- long lastCreated = Long.parseLong(activities[0].get("created").toString());
+ ArrayUtils.reverse(entities);
+ long lastCreated = Long.parseLong(entities[0].get("created").toString());
//2. Query for the entities in descending order
String errorQuery = String.format("select * where created <= %d order by created desc", lastCreated);
int index = 0;
QueryParameters params = new QueryParameters().setQuery(errorQuery);
- Collection activitiesResponse = this.app().collection("activities").get(params);
+ Collection coll = this.app().collection(collectionName).get(params);
//3. Validate that the order is correct
do {
- int returnSize = activitiesResponse.getResponse().getEntityCount();
+ int returnSize = coll.getResponse().getEntityCount();
//loop through the current page of results
for (int i = 0; i < returnSize; i++, index++) {
- assertEquals( ( activities[index] ).get( "uuid" ).toString(),
- activitiesResponse.getResponse().getEntities().get(i).get("uuid").toString());
+ assertEquals( ( entities[index] ).get( "uuid" ).toString(),
+ coll.getResponse().getEntities().get(i).get("uuid").toString());
}
//grab the next page of results
- activitiesResponse = this.app().collection("activities").getNextPage(activitiesResponse, params, true);
+ coll = this.app().collection(collectionName).getNextPage(coll, params, true);
}
- while (activitiesResponse.getCursor() != null);
+ while (coll.getCursor() != null);
}
}
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java
index acf51c1..cb103cf 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java
@@ -41,14 +41,15 @@
@Test
public void testNestedSelectFieldNames() throws Exception {
- generateTestEntities(20, "things");
+ String collectionName = "basketballs";
+ generateTestEntities(20, collectionName);
QueryParameters params = new QueryParameters()
.setQuery("select actor.displayName,sometestprop where sometestprop = 'testprop'");
- Collection things = this.app().collection("things").get(params);
- assertEquals( 10, things.getNumOfEntities() );
+ Collection coll = this.app().collection(collectionName).get(params);
+ assertEquals( 10, coll.getNumOfEntities() );
- Iterator<Entity> iter = things.iterator();
+ Iterator<Entity> iter = coll.iterator();
while ( iter.hasNext() ) {
Entity entity = iter.next();
@@ -73,7 +74,7 @@
@Test
public void testMixedCaseDupField() throws Exception {
- String collectionName = "things";
+ String collectionName = "baseballs";
String value = RandomStringUtils.randomAlphabetic( 20 );
String otherValue = RandomStringUtils.randomAlphabetic( 20 );
@@ -89,19 +90,19 @@
QueryParameters params = new QueryParameters()
.setQuery( "select * where testProp='" + otherValue + "'" );
- Collection things = this.app().collection( "things" ).get( params );
- assertEquals( 1, things.getNumOfEntities() );
+ Collection coll = this.app().collection(collectionName).get( params );
+ assertEquals( 1, coll.getNumOfEntities() );
params = new QueryParameters()
.setQuery( "select * where TESTPROP='" + otherValue + "'" );
- things = app().collection( "things" ).get( params );
- assertEquals( 1, things.getNumOfEntities() );
+ coll = app().collection(collectionName).get( params );
+ assertEquals( 1, coll.getNumOfEntities() );
}
@Test
public void testStringWithSingleQuote() throws Exception {
- String collectionName = "things";
+ String collectionName = "footballs";
String value = "test'value";
String escapedValue = "test\\'value";
@@ -116,14 +117,14 @@
QueryParameters params = new QueryParameters()
.setQuery( "select * where testprop='" + escapedValue + "'" );
- Collection things = this.app().collection( "things" ).get( params );
+ Collection things = this.app().collection(collectionName).get( params );
assertEquals( 1, things.getNumOfEntities() );
}
@Test
public void testStringWithPlus() throws Exception {
- String collectionName = "things";
+ String collectionName = "volleyballs";
String value = "ed+test@usergrid.com";
// create entity with value containing a plus symbol
@@ -135,15 +136,15 @@
// now query this without encoding the plus symbol
QueryParameters params = new QueryParameters()
.setQuery( "select * where testprop='" + value + "'" );
- Collection things = this.app().collection( "things" ).get( params );
- assertEquals( 1, things.getNumOfEntities() );
+ Collection coll = this.app().collection(collectionName).get( params );
+ assertEquals( 1, coll.getNumOfEntities() );
// again query with the plus symbol url encoded
String escapedValue = "ed%2Btest@usergrid.com";
params = new QueryParameters()
.setQuery( "select * where testprop='" + escapedValue + "'" );
- things = this.app().collection( "things" ).get( params );
- assertEquals( 1, things.getNumOfEntities() );
+ coll = this.app().collection(collectionName).get( params );
+ assertEquals( 1, coll.getNumOfEntities() );
}
@@ -154,7 +155,7 @@
@Test
public void testFieldOverride1() throws Exception {
- String collectionName = "things";
+ String collectionName = "pickleballs";
// create entity with testProp=value
String value = RandomStringUtils.randomAlphabetic( 20 );
@@ -172,13 +173,13 @@
QueryParameters params = new QueryParameters()
.setQuery( "select * where testProp='" + newValue + "'" );
- Collection things = this.app().collection( "things" ).get( params );
- assertEquals( 1, things.getNumOfEntities() );
+ Collection coll = this.app().collection(collectionName).get( params );
+ assertEquals( 1, coll.getNumOfEntities() );
params = new QueryParameters()
.setQuery( "select * where TESTPROP='" + newValue + "'" );
- things = app().collection( "things" ).get( params );
- assertEquals( 1, things.getNumOfEntities() );
+ coll = app().collection(collectionName).get( params );
+ assertEquals( 1, coll.getNumOfEntities() );
}
/**
@@ -187,7 +188,7 @@
@Test
public void testFieldOverride2() throws Exception {
- String collectionName = "things";
+ String collectionName = "tennisballs";
// create entity with TESTPROP=value
String value = RandomStringUtils.randomAlphabetic( 20 );
@@ -205,13 +206,13 @@
QueryParameters params = new QueryParameters()
.setQuery( "select * where testProp='" + newValue + "'" );
- Collection things = this.app().collection( "things" ).get( params );
- assertEquals( 1, things.getNumOfEntities() );
+ Collection coll = this.app().collection(collectionName).get( params );
+ assertEquals( 1, coll.getNumOfEntities() );
params = new QueryParameters()
.setQuery( "select * where TESTPROP='" + newValue + "'" );
- things = app().collection( "things" ).get( params );
- assertEquals( 1, things.getNumOfEntities() );
+ coll = app().collection(collectionName).get( params );
+ assertEquals( 1, coll.getNumOfEntities() );
}
}