usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [1/3] incubator-usergrid git commit: rewrote events test, still doesn't work
Date Wed, 15 Jul 2015 23:25:59 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-dev b3a8c97d3 -> 1fe579846


rewrote events test, still doesn't work


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

Branch: refs/heads/two-dot-o-dev
Commit: cf37b949c4e0a496896e02373334686e76a06e47
Parents: b3a8c97
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Jul 15 14:28:15 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Jul 15 14:28:15 2015 -0600

----------------------------------------------------------------------
 .../applications/events/EventsResourceIT.java   | 75 ++++++++------------
 1 file changed, 28 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf37b949/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
index 1384996..2777967 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
@@ -26,6 +26,8 @@ import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
 
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Collection;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -43,27 +45,23 @@ public class EventsResourceIT extends AbstractRestIT {
 
 
     @Test
-    @Ignore("until we have a fix, see also: https://issues.apache.org/jira/browse/USERGRID-212")
+    @Ignore("Events not working yet")
     public void testEventPostandGet() throws IOException {
 
         Map<String, Object> payload = new LinkedHashMap<String, Object>();
         payload.put( "timestamp", 0 );
-        payload.put( "category", "advertising" );
+        payload.put("category", "advertising");
         payload.put("counters", new LinkedHashMap<String, Object>() {
             {
                 put("ad_clicks", 5);
             }
         });
 
-        Token token = getAppUserToken(clientSetup.getUsername(),clientSetup.getPassword());
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/events"
)
-                .queryParam( "access_token", token.getAccessToken() )
-            .accept(MediaType.APPLICATION_JSON )
-            .type(MediaType.APPLICATION_JSON_TYPE )
-            .post(String.class, payload ));
+        ApiResponse node = this.app().collection("events")
+            .post(payload);
 
-        assertNotNull( node.get( "entities" ) );
-        String advertising = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
+        assertNotNull(node.getEntities());
+        String advertising = node.getEntity().get("uuid").toString();
 
         refreshIndex();
 
@@ -76,14 +74,11 @@ public class EventsResourceIT extends AbstractRestIT {
             }
         } );
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/events" )
-                .queryParam( "access_token", token.getAccessToken() )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .post( String.class, payload ));
+        node = this.app().collection("events")
+                .post(  payload );
 
-        assertNotNull( node.get( "entities" ) );
-        String sales = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
+        assertNotNull(node.getEntities());
+        String sales = node.getEntity().get("uuid").toString();
 
         refreshIndex( );
 
@@ -96,54 +91,40 @@ public class EventsResourceIT extends AbstractRestIT {
             }
         } );
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/events" )
-                .queryParam( "access_token", token.getAccessToken() )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .post( String.class, payload ));
+        node = this.app().collection( "events" )
+            .post(payload);
 
-        assertNotNull( node.get( "entities" ) );
-        String marketing = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
+        assertNotNull(node.getEntities());
+        String marketing = node.getEntity().get( "uuid" ).toString();
 
         refreshIndex();
 
         String lastId = null;
 
+        Collection collection;
         // subsequent GETs advertising
         for ( int i = 0; i < 3; i++ ) {
 
-            node = mapper.readTree( resource().path( "/test-organization/test-app/events"
)
-                    .queryParam( "access_token", token.getAccessToken() )
-                    .accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE )
-                    .get( String.class ));
+            collection = this.app().collection( "events" )
+                .get();
 
-            assertEquals( "Expected Advertising", advertising, node.get( "messages" ).get(
0 ).get( "uuid" ).asText() );
-            lastId = node.get( "last" ).asText();
+            assertEquals("Expected Advertising", advertising, ((Map<String, Object>)
((Map<String, Object>) collection.getResponse().getProperties().get("messages")).get(0)).get("uuid").toString());
+            lastId = collection.getResponse().getProperties().get("last").toString();
         }
 
         // check sales event in queue
-        node = mapper.readTree( resource().path( "/test-organization/test-app/events" )
-                .queryParam( "last", lastId )
-                .queryParam( "access_token", token.getAccessToken() )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .get( String.class ));
+        collection = this.app().collection( "events" )
+            .get();
 
 
-        assertEquals( "Expected Sales", sales, node.get( "messages" ).get( 0 ).get( "uuid"
).asText() );
-        lastId = node.get( "last" ).asText();
+        assertEquals( "Expected Sales", sales,((Map<String, Object>) ((Map<String,
Object>) collection.getResponse().getProperties().get("messages")).get(0)).get("uuid").toString());
+        lastId = collection.getResponse().getProperties().get("last").toString();
 
 
         // check marketing event in queue
-        node = mapper.readTree( resource().path( "/test-organization/test-app/events" )
-                .queryParam( "last", lastId )
-                .queryParam( "access_token", token.getAccessToken() )
-                .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE )
-                .get( String.class ));
+        collection = this.app().collection( "events" )
+            .get();
 
-
-        assertEquals( "Expected Marketing", marketing, node.get( "messages" ).get( 0 ).get(
"uuid" ).asText() );
+        assertEquals( "Expected Marketing", marketing, ((Map<String, Object>) ((Map<String,
Object>) collection.getResponse().getProperties().get("messages")).get(0)).get("uuid").toString());
     }
 }


Mime
View raw message