usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [21/27] git commit: Added test cases and fixes for the query testing. Changed error messages such that entire entity is returned with the GET call.
Date Tue, 01 Apr 2014 01:21:13 GMT
Added test cases and fixes for the query testing.
Changed error messages such that entire entity is returned with the GET call.


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

Branch: refs/pull/92/head
Commit: b9ba6ac61c9153ef1e874191d203bd2f09cced2f
Parents: a4d86b4
Author: grey <greyes@apigee.com>
Authored: Mon Mar 31 16:36:47 2014 -0700
Committer: grey <greyes@apigee.com>
Committed: Mon Mar 31 16:36:47 2014 -0700

----------------------------------------------------------------------
 portal/config.js                                |  2 +-
 .../applications/ApplicationResource.java       |  2 +-
 .../rest/management/ManagementResourceIT.java   |  6 +-
 .../management/export/ExportService.java        |  2 +
 .../management/export/ExportServiceImpl.java    | 70 +++++++++++++++++---
 .../cassandra/ManagementServiceIT.java          |  3 -
 .../security/tokens/TokenServiceIT.java         |  3 +-
 7 files changed, 70 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9ba6ac6/portal/config.js
----------------------------------------------------------------------
diff --git a/portal/config.js b/portal/config.js
index 12f1fe5..40a968f 100644
--- a/portal/config.js
+++ b/portal/config.js
@@ -19,7 +19,7 @@ Usergrid.showNotifcations = true;
 
 
 // used only if hostname does not match a real server name
-Usergrid.overrideUrl = 'https://api.usergrid.com/';
+Usergrid.overrideUrl = 'https://localhost:8080/';
 
 Usergrid.options = {
   client:{

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9ba6ac6/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index 60ae26a..588e5a1 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -365,7 +365,7 @@ public class ApplicationResource extends AbstractContextResource {
             return Response.status( SC_BAD_REQUEST ).build();
         }
 
-        return Response.status( SC_OK ).entity( entity.getState() ).build();
+        return Response.status( SC_OK ).entity( entity).build();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9ba6ac6/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index d117e57..306c7a1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -781,7 +781,7 @@ public class ManagementResourceIT extends AbstractRestIT {
 
 
         assertEquals( Status.OK, responseStatus );
-        assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service
tier
+        assertEquals( "SCHEDULED", node.get( "state" ).getTextValue() );//TODO: do tests
for other states in service tier
     }
 
 
@@ -810,7 +810,7 @@ public class ManagementResourceIT extends AbstractRestIT {
 
 
         assertEquals( Status.OK, responseStatus );
-        assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service
tier
+        assertEquals( "SCHEDULED", node.get( "state" ).getTextValue() );//TODO: do tests
for other states in service tier
     }
 
 
@@ -838,7 +838,7 @@ public class ManagementResourceIT extends AbstractRestIT {
 
 
         assertEquals( Status.OK, responseStatus );
-        assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service
tier
+        assertEquals( "SCHEDULED", node.get( "state" ).getTextValue() );//TODO: do tests
for other states in service tier
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9ba6ac6/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
index eafc59a..abb8829 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
@@ -44,5 +44,7 @@ public interface ExportService {
      */
     String getState( UUID appId, UUID state ) throws Exception;
 
+    String getErrorMessage( UUID appId, UUID state ) throws Exception;
+
     void setS3Export( S3Export s3Export );
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9ba6ac6/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
index f1d316e..0ad61ee 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
@@ -172,6 +172,32 @@ public class ExportServiceImpl implements ExportService {
         return export.getState().toString();
     }
 
+    @Override
+    public String getErrorMessage( final UUID appId, final UUID uuid ) throws Exception {
+
+        //get application entity manager
+        if ( appId == null ) {
+            logger.error( "Application context cannot be found." );
+            return "Application context cannot be found.";
+        }
+
+        if ( uuid == null ) {
+            logger.error( "UUID passed in cannot be null." );
+            return "UUID passed in cannot be null";
+        }
+
+        EntityManager rootEm = emf.getEntityManager( appId );
+
+        //retrieve the export entity.
+        Export export = rootEm.get( uuid, Export.class );
+
+        if ( export == null ) {
+            logger.error( "no entity with that uuid was found" );
+            return "No Such Element found";
+        }
+        return export.getErrorMessage();
+    }
+
 
     @Override
     public void doExport( final JobExecution jobExecution ) throws Exception {
@@ -197,7 +223,14 @@ public class ExportServiceImpl implements ExportService {
         em.update( export );
 
         if ( em.getApplication().getApplicationName().equals( "exporters" ) ) {
-            exportApplicationsFromOrg( ( UUID ) config.get( "organizationId" ), config, jobExecution
);
+            try {
+                exportApplicationsFromOrg( ( UUID ) config.get( "organizationId" ), config,
jobExecution );
+            }
+            catch ( Exception e ) {
+                export.setErrorMessage( e.getMessage() );
+                export.setState( Export.State.FAILED );
+                em.update( export );
+            }
         }
         else if ( config.get( "collectionName" ) == null ) {
             //exports all the applications for a given organization.
@@ -208,8 +241,15 @@ public class ExportServiceImpl implements ExportService {
                 em.update( export );
                 return;
             }
-            exportApplicationFromOrg( ( UUID ) config.get( "organizationId" ), ( UUID ) config.get(
"applicationId" ),
-                    config, jobExecution );
+            try {
+                exportApplicationFromOrg( ( UUID ) config.get( "organizationId" ),
+                        ( UUID ) config.get( "applicationId" ), config, jobExecution );
+            }
+            catch ( Exception e ) {
+                export.setErrorMessage( e.getMessage() );
+                export.setState( Export.State.FAILED );
+                em.update( export );
+            }
         }
         else {
             try {
@@ -220,11 +260,19 @@ public class ExportServiceImpl implements ExportService {
                     em.update( export );
                     return;
                 }
-                exportCollectionFromOrgApp( ( UUID ) config.get( "organizationId" ),
-                        ( UUID ) config.get( "applicationId" ), config, jobExecution );
+                try {
+                    exportCollectionFromOrgApp( ( UUID ) config.get( "organizationId" ),
+                            ( UUID ) config.get( "applicationId" ), config, jobExecution
);
+                }
+                catch ( Exception e ) {
+                    export.setErrorMessage( e.getMessage() );
+                    export.setState( Export.State.FAILED );
+                    em.update( export );
+                }
             }
             catch ( Exception e ) {
                 //if for any reason the backing up fails, then update the entity with a failed
state.
+                export.setErrorMessage( e.getMessage() );
                 export.setState( Export.State.FAILED );
                 em.update( export );
                 return;
@@ -396,18 +444,21 @@ public class ExportServiceImpl implements ExportService {
             if ( ( config.get( "collectionName" ) == null ) || collectionName
                     .equals( config.get( "collectionName" ) ) ) {
                 //Query entity manager for the entities in a collection
-                Query query;
+                Query query = null;
                 if ( config.get( "query" ) == null ) {
                     query = new Query();
                 }
                 else {
-                    query = Query.fromQL( ( String ) config.get( "query" ) );
+                    try {
+                        query = Query.fromQL( ( String ) config.get( "query" ) );
+                    }
+                    catch ( Exception e ) {
+                        export.setErrorMessage( e.getMessage() );
+                    }
                 }
-                // Query query = Query.fromQL( ( String ) config.get( "query" ) ); //new
Query();
                 query.setLimit( MAX_ENTITY_FETCH );
                 query.setResultsLevel( Results.Level.ALL_PROPERTIES );
                 query.setCollection( collectionName );
-                //query.setQl( ( String ) config.get( "query" ) );
 
                 Results entities = em.searchCollection( em.getApplicationRef(), collectionName,
query );
 
@@ -518,6 +569,7 @@ public class ExportServiceImpl implements ExportService {
             s3Export.copyToS3( is, config, appFileName );
         }
         catch ( Exception e ) {
+            export.setErrorMessage( e.getMessage() );
             export.setState( Export.State.FAILED );
             return;
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9ba6ac6/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 0fd9676..558d7ea 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1392,9 +1392,6 @@ public class ManagementServiceIT {
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
 
-        //        payload.put( "organizationId",organization.getUuid() );
-        //        payload.put( "applicationId",applicationId);
-
         //creates 100s of organizations with some entities in each one to make sure we don't
actually apply it
         OrganizationInfo orgMade = null;
         ApplicationInfo appMade = null;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9ba6ac6/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
index 961d923..0141c9b 100644
--- a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
@@ -39,7 +39,8 @@ import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.entities.Application;
 import org.apache.usergrid.security.AuthPrincipalInfo;
 import org.apache.usergrid.security.AuthPrincipalType;
-import org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl;
+import org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl
+        ;
 import org.apache.usergrid.security.tokens.exceptions.ExpiredTokenException;
 import org.apache.usergrid.security.tokens.exceptions.InvalidTokenException;
 import org.apache.usergrid.utils.UUIDUtils;


Mime
View raw message