You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/03/06 06:21:09 UTC

git commit: Fixed collections bug, fixed all tests to prepare for removal of ExportInfo.

Repository: incubator-usergrid
Updated Branches:
  refs/pull/60/head a02b08c7f -> 9e716a6f6


Fixed collections bug, fixed all tests to prepare for removal of ExportInfo.


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

Branch: refs/pull/60/head
Commit: 9e716a6f6c28639b77b39c239ded544ff2f4873e
Parents: a02b08c
Author: grey <gr...@apigee.com>
Authored: Wed Mar 5 20:45:34 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 5 20:45:34 2014 -0800

----------------------------------------------------------------------
 .../applications/ApplicationResource.java       |    3 +
 .../rest/management/ManagementResourceIT.java   |  350 +++---
 .../management/export/ExportServiceImpl.java    |    2 +-
 .../cassandra/ManagementServiceIT.java          | 1063 +++++++++---------
 4 files changed, 724 insertions(+), 694 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9e716a6f/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 d88ef8d..73e550b 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
@@ -225,6 +225,9 @@ public class ApplicationResource extends AbstractContextResource {
         try {
             //parse the json into some useful object (the config params)
             //ExportInfo objEx = new ExportInfo( json );
+            if(json.get( "properties" ) == null){
+                throw new NullPointerException();
+            }
             json.put( "organizationId",organization.getUuid());
             //objEx.setOrganizationId( organization.getUuid() );
             json.put( "applicationId",applicationId);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9e716a6f/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 00a8a97..7eb9ed1 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
@@ -614,193 +614,193 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertNotNull( node.get( "jobUUID" ) );
     }
 //
-//    @Test
-//    public void exportCollectionUUIDRetTest() throws Exception {
-//        Status responseStatus = Status.ACCEPTED;
-//        String uuid;
-//        UUID jobUUID = null;
-//        JsonNode node = null;
-//
-//
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        try {
-//            node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
-//                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-//                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            responseStatus = uie.getResponse().getClientResponseStatus();
-//        }
-//
-//        assertEquals( Status.ACCEPTED, responseStatus );
-//        assertNotNull( node.get( "jobUUID" ) );
-//    }
+    @Test
+    public void exportCollectionUUIDRetTest() throws Exception {
+        Status responseStatus = Status.ACCEPTED;
+        String uuid;
+        UUID jobUUID = null;
+        JsonNode node = null;
+
+
+        HashMap<String, Object> payload = payloadBuilder();
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+
+        assertEquals( Status.ACCEPTED, responseStatus );
+        assertNotNull( node.get( "jobUUID" ) );
+    }
 
 
     /*Make a test with an invalid uuid and a wrong uuid.*/
     //all tests should be moved to OrganizationResourceIT ( *not* Organizations there is a difference)
-//    @Test
-//    public void exportGetApplicationJobStatTest() throws Exception {
-//        JsonNode node = null;
-//        Status responseStatus = Status.OK;
-//
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
-//                         .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-//                         .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
-//        String uuid = String.valueOf( node.get( "jobUUID" ) );
-//        uuid = uuid.replaceAll( "\"", "" );
-//
-//        try {
-//            node = resource().path( "/management/orgs/test-organization/apps/test-app/export/" + uuid )
-//                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-//                             .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            responseStatus = uie.getResponse().getClientResponseStatus();
-//        }
-//
-//
-//        assertEquals( Status.OK, responseStatus );
-//        assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service tier
-//    }
-//
-//    @Test
-//    public void exportGetCollectionJobStatTest() throws Exception {
-//        JsonNode node = null;
-//        Status responseStatus = Status.OK;
-//
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
-//                         .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-//                         .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
-//        String uuid = String.valueOf( node.get( "jobUUID" ) );
-//        uuid = uuid.replaceAll( "\"", "" );
-//
-//        try {
-//            node = resource().path( "/management/orgs/test-organization/apps/test-app/export/" + uuid )
-//                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-//                             .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            responseStatus = uie.getResponse().getClientResponseStatus();
-//        }
-//
-//
-//        assertEquals( Status.OK, responseStatus );
-//        assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service tier
-//    }
+    @Test
+    public void exportGetApplicationJobStatTest() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+
+        HashMap<String, Object> payload = payloadBuilder();
+
+        node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
+                         .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                         .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+        String uuid = String.valueOf( node.get( "jobUUID" ) );
+        uuid = uuid.replaceAll( "\"", "" );
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/export/" + uuid )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+
+
+        assertEquals( Status.OK, responseStatus );
+        assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service tier
+    }
+
+    @Test
+    public void exportGetCollectionJobStatTest() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+
+        HashMap<String, Object> payload = payloadBuilder();
+
+        node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
+                         .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                         .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+        String uuid = String.valueOf( node.get( "jobUUID" ) );
+        uuid = uuid.replaceAll( "\"", "" );
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/export/" + uuid )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+
+
+        assertEquals( Status.OK, responseStatus );
+        assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service tier
+    }
 
 
 //    //do an unauthorized test for both post and get
-//    @Test
-//    public void exportGetWrongUUID() throws Exception {
-//        JsonNode node = null;
-//        Status responseStatus = Status.OK;
-//        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
-//        try {
-//            node = resource().path( "/management/orgs/test-organization/apps/test-app/export/" + fake )
-//                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-//                             .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            responseStatus = uie.getResponse().getClientResponseStatus();
-//        }
-//        assertEquals( Status.BAD_REQUEST, responseStatus );
-//    }
-//
-//    @Test
-//    public void exportPostApplicationNullPointer() throws Exception {
-//        JsonNode node = null;
-//        Status responseStatus = Status.OK;
-//
-//        HashMap<String, Object> payload = new HashMap<String, Object>();
-//        Map<String, Object> properties = new HashMap<String, Object>();
-//        Map<String, Object> storage_info = new HashMap<String, Object>();
-//        //TODO: always put dummy values here and ignore this test.
-//        //TODO: add a ret for when s3 values are invalid.
-//        storage_info.put( "bucket_location", "insert bucket name here" );
-//
-//
-//        properties.put( "storage_provider", "s3" );
-//        properties.put( "storage_info", storage_info );
-//
-//        payload.put( "path", "test-organization/test-app" );
-//
-//        try {
-//            node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
-//                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-//                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            responseStatus = uie.getResponse().getClientResponseStatus();
-//        }
-//        assertEquals( Status.BAD_REQUEST, responseStatus );
-//    }
-//
-//    @Test
-//    public void exportPostCollectionNullPointer() throws Exception {
-//        JsonNode node = null;
-//        Status responseStatus = Status.OK;
-//
-//        HashMap<String, Object> payload = new HashMap<String, Object>();
-//        Map<String, Object> properties = new HashMap<String, Object>();
-//        Map<String, Object> storage_info = new HashMap<String, Object>();
-//        //TODO: always put dummy values here and ignore this test.
-//        //TODO: add a ret for when s3 values are invalid.
-//        storage_info.put( "bucket_location", "insert bucket name here" );
-//
-//
-//        properties.put( "storage_provider", "s3" );
-//        properties.put( "storage_info", storage_info );
+    @Test
+    public void exportGetWrongUUID() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
+        try {
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/export/" + fake )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals( Status.BAD_REQUEST, responseStatus );
+    }
 //
+    @Test
+    public void exportPostApplicationNullPointer() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+
+        HashMap<String, Object> payload = new HashMap<String, Object>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        Map<String, Object> storage_info = new HashMap<String, Object>();
+        //TODO: always put dummy values here and ignore this test.
+        //TODO: add a ret for when s3 values are invalid.
+        storage_info.put( "bucket_location", "insert bucket name here" );
+
+
+        properties.put( "storage_provider", "s3" );
+        properties.put( "storage_info", storage_info );
+
+        payload.put( "path", "test-organization/test-app" );
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals( Status.BAD_REQUEST, responseStatus );
+    }
 //
-//        try {
-//            node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
-//                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-//                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            responseStatus = uie.getResponse().getClientResponseStatus();
-//        }
-//        assertEquals( Status.BAD_REQUEST, responseStatus );
-//    }
+    @Test
+    public void exportPostCollectionNullPointer() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+
+        HashMap<String, Object> payload = new HashMap<String, Object>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        Map<String, Object> storage_info = new HashMap<String, Object>();
+        //TODO: always put dummy values here and ignore this test.
+        //TODO: add a ret for when s3 values are invalid.
+        storage_info.put( "bucket_location", "insert bucket name here" );
+
+
+        properties.put( "storage_provider", "s3" );
+        properties.put( "storage_info", storage_info );
+
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals( Status.BAD_REQUEST, responseStatus );
+    }
 //
 //
-//    @Test
-//    public void exportGetCollectionUnauthorized() throws Exception {
-//        JsonNode node = null;
-//        Status responseStatus = Status.OK;
-//        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
-//        try {
-//            node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export/" + fake )
-//                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-//                             .get( JsonNode.class );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            responseStatus = uie.getResponse().getClientResponseStatus();
-//        }
-//        assertEquals( Status.UNAUTHORIZED, responseStatus );
-//    }
+    @Test
+    public void exportGetCollectionUnauthorized() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
+        try {
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export/" + fake )
+                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                             .get( JsonNode.class );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals( Status.UNAUTHORIZED, responseStatus );
+    }
 //
-//    @Test
-//    public void exportGetApplicationUnauthorized() throws Exception {
-//        JsonNode node = null;
-//        Status responseStatus = Status.OK;
-//        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
-//        try {
-//            node = resource().path( "/management/orgs/test-organization/apps/test-app/export/" + fake )
-//                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-//                             .get( JsonNode.class );
-//        }
-//        catch ( UniformInterfaceException uie ) {
-//            responseStatus = uie.getResponse().getClientResponseStatus();
-//        }
-//        assertEquals( Status.UNAUTHORIZED, responseStatus );
-//    }
+    @Test
+    public void exportGetApplicationUnauthorized() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
+        try {
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/export/" + fake )
+                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                             .get( JsonNode.class );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals( Status.UNAUTHORIZED, responseStatus );
+    }
 
 
     /*Creates fake payload for testing purposes.*/

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9e716a6f/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 6703df7..4bc307d 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
@@ -388,7 +388,7 @@ public class ExportServiceImpl implements ExportService {
             //could support queries, just need to implement that in the rest endpoint.
             for ( String collectionName : metadata.keySet() ) {
                 //if the collection you are looping through doesn't match the name of the one you want. Don't export it.
-                if ( collectionName.equals( (UUID) config.get("collectionName")) ) {
+                if ( collectionName.equals( (String) config.get("collectionName")) ) {
                     //Query entity manager for the entities in a collection
                     Query query = new Query();
                     query.setLimit( MAX_ENTITY_FETCH );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9e716a6f/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 b4c07ad..8734dbc 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
@@ -36,6 +36,8 @@ import org.apache.usergrid.management.export.S3ExportImpl;
 import org.apache.usergrid.persistence.CredentialsInfo;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.entities.Export;
 import org.apache.usergrid.persistence.entities.JobData;
 import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.security.AuthPrincipalType;
@@ -743,92 +745,95 @@ public class ManagementServiceIT {
     }
 //
 //
-//    //Tests to make sure we can call the job with mock data and it runs.
-//    @Test //Connections won't save when run with maven, but on local builds it will.
-//    public void testConnectionsOnCollectionExport() throws Exception {
-//
-//        File f = null;
-//        int indexCon = 0;
-//
-//
-//        try {
-//            f = new File( "testFileConnections.json" );
-//            f.delete();
-//        }
-//        catch ( Exception e ) {
-//            //consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
-//        }
-//
-//
-//        S3Export s3Export = new MockS3ExportImpl();
-//        s3Export.setFilename( "testFileConnections.json" );
-//
-//        ExportService exportService = setup.getExportService();
-//        HashMap<String, Object> payload = payloadBuilder();
-//
+    //Tests to make sure we can call the job with mock data and it runs.
+    @Test //Connections won't save when run with maven, but on local builds it will.
+    public void testConnectionsOnCollectionExport() throws Exception {
+
+        File f = null;
+        int indexCon = 0;
+
+
+        try {
+            f = new File( "testFileConnections.json" );
+            f.delete();
+        }
+        catch ( Exception e ) {
+            //consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
+        }
+
+
+        S3Export s3Export = new MockS3ExportImpl();
+        s3Export.setFilename( "testFileConnections.json" );
+
+        ExportService exportService = setup.getExportService();
+        HashMap<String, Object> payload = payloadBuilder();
+
 //        ExportInfo exportInfo = new ExportInfo( payload );
 //        exportInfo.setOrganizationId( organization.getUuid() );
 //        exportInfo.setApplicationId( applicationId );
 //        exportInfo.setCollection( "users" );
-//
-//        EntityManager em = setup.getEmf().getEntityManager( applicationId );
-//        //intialize user object to be posted
-//        Map<String, Object> userProperties = null;
-//        Entity[] entity;
-//        entity = new Entity[2];
-//        //creates entities
-//        for ( int i = 0; i < 2; i++ ) {
-//            userProperties = new LinkedHashMap<String, Object>();
-//            userProperties.put( "username", "meatIsGreat" + i );
-//            userProperties.put( "email", "grey" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
-//
-//            entity[i] = em.create( "users", userProperties );
-//        }
-//        //creates connections
-//        em.createConnection( em.getRef( entity[0].getUuid() ), "Vibrations", em.getRef( entity[1].getUuid() ) );
-//        em.createConnection( em.getRef( entity[1].getUuid() ), "Vibrations", em.getRef( entity[0].getUuid() ) );
-//
-//        UUID exportUUID = exportService.schedule( exportInfo );
-//        exportService.setS3Export( s3Export );
-//
-//        //create and initialize jobData returned in JobExecution.
-//        JobData jobData = new JobData();
-//        jobData.setProperty( "jobName", "exportJob" );
-//        jobData.setProperty( "exportInfo", exportInfo );
-//        jobData.setProperty( "exportId", exportUUID );
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        exportService.doExport( exportInfo, jobExecution );
-//
-//        JSONParser parser = new JSONParser();
-//
-//        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
-//        //assertEquals(2, a.size() );
-//
-//        for(indexCon  = 0; indexCon < a.size(); indexCon++) {
-//            JSONObject jObj = ( JSONObject ) a.get( indexCon );
-//            JSONObject data = ( JSONObject ) jObj.get( "Metadata" );
-//            String uuid = (String) data.get( "uuid" );
-//            if ( entity[0].getUuid().toString().equals( uuid )) {
-//                break;
-//            }
-//
-//        }
-//
-//        org.json.simple.JSONObject objEnt = ( org.json.simple.JSONObject ) a.get( indexCon );
-//        org.json.simple.JSONObject objConnections = ( org.json.simple.JSONObject ) objEnt.get( "connections" );
-//
-//        assertNotNull( objConnections );
-//
-//        org.json.simple.JSONArray objVibrations = ( org.json.simple.JSONArray ) objConnections.get( "Vibrations" );
-//
-//        assertNotNull( objVibrations );
-//
-//        f.delete();
-//    }
-//
+        payload.put( "organizationId",organization.getUuid() );
+        payload.put( "applicationId",applicationId );
+        payload.put("collectionName","users");
+
+        EntityManager em = setup.getEmf().getEntityManager( applicationId );
+        //intialize user object to be posted
+        Map<String, Object> userProperties = null;
+        Entity[] entity;
+        entity = new Entity[2];
+        //creates entities
+        for ( int i = 0; i < 2; i++ ) {
+            userProperties = new LinkedHashMap<String, Object>();
+            userProperties.put( "username", "meatIsGreat" + i );
+            userProperties.put( "email", "grey" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
+
+            entity[i] = em.create( "users", userProperties );
+        }
+        //creates connections
+        em.createConnection( em.getRef( entity[0].getUuid() ), "Vibrations", em.getRef( entity[1].getUuid() ) );
+        em.createConnection( em.getRef( entity[1].getUuid() ), "Vibrations", em.getRef( entity[0].getUuid() ) );
+
+        UUID exportUUID = exportService.schedule( payload );
+        exportService.setS3Export( s3Export );
+
+        //create and initialize jobData returned in JobExecution.
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
+
+        JobExecution jobExecution = mock( JobExecution.class );
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        exportService.doExport( jobExecution );
+
+        JSONParser parser = new JSONParser();
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
+        //assertEquals(2, a.size() );
+
+        for(indexCon  = 0; indexCon < a.size(); indexCon++) {
+            JSONObject jObj = ( JSONObject ) a.get( indexCon );
+            JSONObject data = ( JSONObject ) jObj.get( "Metadata" );
+            String uuid = (String) data.get( "uuid" );
+            if ( entity[0].getUuid().toString().equals( uuid )) {
+                break;
+            }
+
+        }
+
+        org.json.simple.JSONObject objEnt = ( org.json.simple.JSONObject ) a.get( indexCon );
+        org.json.simple.JSONObject objConnections = ( org.json.simple.JSONObject ) objEnt.get( "connections" );
+
+        assertNotNull( objConnections );
+
+        org.json.simple.JSONArray objVibrations = ( org.json.simple.JSONArray ) objConnections.get( "Vibrations" );
+
+        assertNotNull( objVibrations );
+
+        f.delete();
+    }
+
     @Ignore //Connections won't save when run with maven, but on local builds it will.
     public void testConnectionsOnApplicationEndpoint() throws Exception {
 
@@ -918,473 +923,495 @@ public class ManagementServiceIT {
     }
 //
 ////need to add tests for the other endpoint as well.
-//    @Test
-//    public void testValidityOfCollectionExport() throws Exception {
-//
-//        File f = null;
-//
-//        try {
-//            f = new File( "fileValidity.json" );
-//            f.delete();
-//        }
-//        catch ( Exception e ) {
-//            //consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
-//        }
-//
-//        S3Export s3Export = new MockS3ExportImpl();
-//        s3Export.setFilename( "fileValidity.json" );
-//        ExportService exportService = setup.getExportService();
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        ExportInfo exportInfo = new ExportInfo( payload );
-//        exportInfo.setOrganizationId( organization.getUuid() );
-//        exportInfo.setApplicationId( applicationId );
-//        exportInfo.setCollection( "users" );
-//
-//        UUID exportUUID = exportService.schedule( exportInfo );
-//        exportService.setS3Export( s3Export );
-//
-//        JobData jobData = new JobData();
-//        jobData.setProperty( "jobName", "exportJob" );
-//        jobData.setProperty( "exportInfo", exportInfo );
-//        jobData.setProperty( "exportId", exportUUID );
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        exportService.doExport( exportInfo, jobExecution );
-//
-//        JSONParser parser = new JSONParser();
-//
-//        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
-//
-//        for ( int i = 0; i < a.size(); i++ ) {
-//            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject ) a.get( i );
-//            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
-//            assertNotNull( entityData );
-//        }
-//        f.delete();
-//    }
-//
-//    @Test
-//    public void testValidityOfApplicationExport() throws Exception {
-//
-//        File f = null;
-//
-//        try {
-//            f = new File( "testValidityOfApplicationExport.json" );
-//            f.delete();
-//        }
-//        catch ( Exception e ) {
-//            //consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
-//        }
-//
-//        S3Export s3Export = new MockS3ExportImpl();
-//        s3Export.setFilename( "testValidityOfApplicationExport.json" );
-//        ExportService exportService = setup.getExportService();
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        ExportInfo exportInfo = new ExportInfo( payload );
-//        exportInfo.setOrganizationId( organization.getUuid() );
-//        exportInfo.setApplicationId( applicationId );
-//
-//        UUID exportUUID = exportService.schedule( exportInfo );
-//        exportService.setS3Export( s3Export );
-//
-//        JobData jobData = new JobData();
-//        jobData.setProperty( "jobName", "exportJob" );
-//        jobData.setProperty( "exportInfo", exportInfo );
-//        jobData.setProperty( "exportId", exportUUID );
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        exportService.doExport( exportInfo, jobExecution );
-//
-//        JSONParser parser = new JSONParser();
-//
-//        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
-//
-//        for ( int i = 0; i < a.size(); i++ ) {
-//            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject ) a.get( i );
-//            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
-//            assertNotNull( entityData );
-//        }
-//        f.delete();
-//    }
-//
-//    @Test
-//    public void testExportOneOrgCollectionEndpoint() throws Exception {
-//
-//        File f = null;
-//
-//
-//        try {
-//            f = new File( "exportOneOrg.json" );
-//            f.delete();
-//        }
-//        catch ( Exception e ) {
-//            //consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
-//        }
-//        setup.getMgmtSvc()
-//             .createOwnerAndOrganization( "noExport", "junkUserName", "junkRealName", "ugExport@usergrid.com",
-//                     "123456789" );
-//
-//        S3Export s3Export = new MockS3ExportImpl();
-//        s3Export.setFilename("exportOneOrg.json");
-//        ExportService exportService = setup.getExportService();
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        ExportInfo exportInfo = new ExportInfo( payload );
-//        exportInfo.setOrganizationId( organization.getUuid() );
-//        exportInfo.setApplicationId( applicationId );
-//        exportInfo.setCollection( "roles" );
-//
-//        UUID exportUUID = exportService.schedule( exportInfo );
-//        exportService.setS3Export( s3Export );
-//
-//        JobData jobData = new JobData();
-//        jobData.setProperty( "jobName", "exportJob" );
-//        jobData.setProperty( "exportInfo", exportInfo );
-//        jobData.setProperty( "exportId", exportUUID );
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        exportService.doExport( exportInfo, jobExecution );
-//
-//        JSONParser parser = new JSONParser();
-//
-//        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
-//
-//        assertEquals( 3 , a.size() );
-//        for ( int i = 0; i < a.size(); i++ ) {
-//            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject ) a.get( i );
-//            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
-//            String entityName = ( String ) entityData.get( "name" );
-//            // assertNotEquals( "NotEqual","junkRealName",entityName );
-//            assertFalse( "junkRealName".equals( entityName ) );
-//        }
-//        f.delete();
-//    }
-//
-//
-//    @Test
-//    public void testExportOneAppOnCollectionEndpoint() throws Exception {
-//
-//        File f = null;
-//        String orgName = "ed-organization";
-//        String appName = "testAppCollectionTestNotExported";
-//
-//        try {
-//            f = new File( "exportOneApp.json" );
-//            f.delete();
-//        }
-//        catch ( Exception e ) {
-//            //consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
-//        }
-//
-//        UUID appId = setup.getEmf().createApplication( orgName, appName );
-//
-//
-//        EntityManager em = setup.getEmf().getEntityManager( appId );
-//        //intialize user object to be posted
-//        Map<String, Object> userProperties = null;
-//        Entity[] entity;
-//        entity = new Entity[1];
-//        //creates entities
-//        for ( int i = 0; i < 1; i++ ) {
-//            userProperties = new LinkedHashMap<String, Object>();
-//            userProperties.put( "username", "junkRealName");
-//            userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
-//            entity[i] = em.create( "user", userProperties );
-//        }
-//
-//        S3Export s3Export = new MockS3ExportImpl();
-//        s3Export.setFilename( "exportOneApp.json" );
-//        ExportService exportService = setup.getExportService();
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        ExportInfo exportInfo = new ExportInfo( payload );
-//        exportInfo.setOrganizationId( organization.getUuid() );
-//        exportInfo.setApplicationId( applicationId );
-//        exportInfo.setCollection( "roles" ); // <- this line determines if it is a collection back up or a application backup.
-//
-//        UUID exportUUID = exportService.schedule( exportInfo );
-//        exportService.setS3Export( s3Export );
-//
-//        JobData jobData = new JobData();
-//        jobData.setProperty( "jobName", "exportJob" );
-//        jobData.setProperty( "exportInfo", exportInfo );
-//        jobData.setProperty( "exportId", exportUUID );
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        exportService.doExport( exportInfo, jobExecution );
-//
-//        JSONParser parser = new JSONParser();
-//
-//        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
-//
-//        assertEquals( 3 , a.size() );
-//        for ( int i = 0; i < a.size(); i++ ) {
-//            org.json.simple.JSONObject data = ( org.json.simple.JSONObject ) a.get( i );
-//            org.json.simple.JSONObject entityData = ( JSONObject ) data.get( "Metadata" );
-//            String entityName = ( String ) entityData.get( "name" );
-//            assertFalse( "junkRealName".equals( entityName ) );
-//        }
-//        f.delete();
-//    }
-//
-//    @Test
-//    public void testExportOneAppOnApplicationEndpoint() throws Exception {
-//
-//        File f = null;
-//        String orgName = "ed-organization";
-//        String appName = "testAppNotExported";
-//
-//        try {
-//            f = new File( "exportOneApp.json" );
-//            f.delete();
-//        }
-//        catch ( Exception e ) {
-//            //consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
-//        }
-//
-//        UUID appId = setup.getEmf().createApplication( orgName, appName );
-//
-//
-//        EntityManager em = setup.getEmf().getEntityManager( appId );
-//        //intialize user object to be posted
-//        Map<String, Object> userProperties = null;
-//        Entity[] entity;
-//        entity = new Entity[1];
-//        //creates entities
-//        for ( int i = 0; i < 1; i++ ) {
-//            userProperties = new LinkedHashMap<String, Object>();
-//            userProperties.put( "username", "junkRealName");
-//            userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
-//            entity[i] = em.create( "users", userProperties );
-//        }
-//
-//        S3Export s3Export = new MockS3ExportImpl();
-//        s3Export.setFilename( "exportOneApp.json" );
-//        ExportService exportService = setup.getExportService();
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        ExportInfo exportInfo = new ExportInfo( payload );
-//        exportInfo.setOrganizationId( organization.getUuid() );
-//        exportInfo.setApplicationId( applicationId );
-//
-//        UUID exportUUID = exportService.schedule( exportInfo );
-//        exportService.setS3Export( s3Export );
-//
-//        JobData jobData = new JobData();
-//        jobData.setProperty( "jobName", "exportJob" );
-//        jobData.setProperty( "exportInfo", exportInfo );
-//        jobData.setProperty( "exportId", exportUUID );
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        exportService.doExport( exportInfo, jobExecution );
-//
-//        JSONParser parser = new JSONParser();
-//
-//        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
-//
-//        //assertEquals( 3 , a.size() );
-//        for ( int i = 0; i < a.size(); i++ ) {
-//            org.json.simple.JSONObject data = ( org.json.simple.JSONObject ) a.get( i );
-//            org.json.simple.JSONObject entityData = ( JSONObject ) data.get( "Metadata" );
-//            String entityName = ( String ) entityData.get( "name" );
-//            assertFalse( "junkRealName".equals( entityName ) );
-//        }
-//        f.delete();
-//    }
-//
-//    @Test
-//    public void testExportOneCollection() throws Exception {
-//
-//        File f = null;
-//        int entitiesToCreate = 10000;
-//
-//        try {
-//            f = new File( "exportOneCollection.json" );
-//            f.delete();
-//        }
-//        catch ( Exception e ) {
-//            //consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
-//        }
-//
-//        EntityManager em = setup.getEmf().getEntityManager( applicationId);
-//        em.createApplicationCollection( "baconators" );
-//        //intialize user object to be posted
-//        Map<String, Object> userProperties = null;
-//        Entity[] entity;
-//        entity = new Entity[entitiesToCreate];
-//        //creates entities
-//        for ( int i = 0; i < entitiesToCreate; i++ ) {
-//            userProperties = new LinkedHashMap<String, Object>();
-//            userProperties.put( "username", "billybob" + i );
-//            userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
-//            entity[i] = em.create( "baconators", userProperties );
-//        }
-//
-//        S3Export s3Export = new MockS3ExportImpl();
-//        s3Export.setFilename( "exportOneCollection.json" );
-//        ExportService exportService = setup.getExportService();
-//        HashMap<String, Object> payload = payloadBuilder();
-//
-//        ExportInfo exportInfo = new ExportInfo( payload );
-//        exportInfo.setOrganizationId( organization.getUuid() );
-//        exportInfo.setApplicationId( applicationId );
-//        exportInfo.setCollection( "baconators" );
-//
-//        UUID exportUUID = exportService.schedule( exportInfo );
-//        exportService.setS3Export( s3Export );
-//
-//        JobData jobData = new JobData();
-//        jobData.setProperty( "jobName", "exportJob" );
-//        jobData.setProperty( "exportInfo", exportInfo );
-//        jobData.setProperty( "exportId", exportUUID );
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        exportService.doExport( exportInfo, jobExecution );
-//
-//        JSONParser parser = new JSONParser();
-//
-//        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
-//
-//        assertEquals( entitiesToCreate , a.size() );
-//        f.delete();
-//    }
-//
-//
-//    //only handles the DoJob Code , different tests for DoExport
     @Test
-    public void testExportDoJob() throws Exception {
+    public void testValidityOfCollectionExport() throws Exception {
+
+        File f = null;
+
+        try {
+            f = new File( "fileValidity.json" );
+            f.delete();
+        }
+        catch ( Exception e ) {
+            //consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
+        }
 
+        S3Export s3Export = new MockS3ExportImpl();
+        s3Export.setFilename( "fileValidity.json" );
+        ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
 
 //        ExportInfo exportInfo = new ExportInfo( payload );
 //        exportInfo.setOrganizationId( organization.getUuid() );
 //        exportInfo.setApplicationId( applicationId );
+//        exportInfo.setCollection( "users" );
+
         payload.put( "organizationId",organization.getUuid() );
         payload.put( "applicationId",applicationId);
+        payload.put( "collectionName","users");
 
+        UUID exportUUID = exportService.schedule( payload );
+        exportService.setS3Export( s3Export );
 
         JobData jobData = new JobData();
         jobData.setProperty( "jobName", "exportJob" );
-        jobData.setProperty( "exportInfo", payload ); //this needs to be populated with properties of export info
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
 
         JobExecution jobExecution = mock( JobExecution.class );
-
         when( jobExecution.getJobData() ).thenReturn( jobData );
 
-        ExportJob job = new ExportJob();
-        ExportService eS = mock( ExportService.class );
-        job.setExportService( eS );
+        exportService.doExport( jobExecution );
+
+        JSONParser parser = new JSONParser();
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
+
+        for ( int i = 0; i < a.size(); i++ ) {
+            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject ) a.get( i );
+            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
+            assertNotNull( entityData );
+        }
+        f.delete();
+    }
+//
+    @Test
+    public void testValidityOfApplicationExport() throws Exception {
+
+        File f = null;
+
         try {
-            job.doJob( jobExecution );
+            f = new File( "testValidityOfApplicationExport.json" );
+            f.delete();
         }
         catch ( Exception e ) {
-            assert ( false );
+            //consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
         }
-        assert ( true );
-    }
-//
-//    @Test
-//    public void testExportDoExportOnApplicationEndpoint() throws Exception {
-//
-//        EntityManagerFactory emf = setup.getEmf();
-//        EntityManager em = emf.getEntityManager( applicationId );
-//        HashMap<String, Object> payload = payloadBuilder();
-//        ExportService eS = setup.getExportService();
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//
+
+        S3Export s3Export = new MockS3ExportImpl();
+        s3Export.setFilename( "testValidityOfApplicationExport.json" );
+        ExportService exportService = setup.getExportService();
+        HashMap<String, Object> payload = payloadBuilder();
+
 //        ExportInfo exportInfo = new ExportInfo( payload );
 //        exportInfo.setOrganizationId( organization.getUuid() );
 //        exportInfo.setApplicationId( applicationId );
+
+        payload.put( "organizationId",organization.getUuid() );
+        payload.put( "applicationId",applicationId);
+
+        UUID exportUUID = exportService.schedule( payload );
+        exportService.setS3Export( s3Export );
+
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
+
+        JobExecution jobExecution = mock( JobExecution.class );
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        exportService.doExport( jobExecution );
+
+        JSONParser parser = new JSONParser();
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
+
+        for ( int i = 0; i < a.size(); i++ ) {
+            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject ) a.get( i );
+            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
+            assertNotNull( entityData );
+        }
+        f.delete();
+    }
 //
-//        UUID entityExportUUID = eS.schedule( exportInfo );
-//
-//
-//        JobData jobData = new JobData();
-//        jobData.setProperty( "jobName", "exportJob" );
-//        jobData.setProperty( "exportInfo", exportInfo );
-//        jobData.setProperty( "exportId", entityExportUUID );
-//
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        //Exportem.get(entityExport);
-//        Export exportEntity = ( Export ) em.get( entityExportUUID );
-//        assertNotNull( exportEntity );
-//        String derp = exportEntity.getState().name();
-//        assertEquals( "SCHEDULED", exportEntity.getState().name() );
-//        try {
-//            eS.doExport( exportInfo, jobExecution );
-//        }
-//        catch ( Exception e ) {
-//            //throw e;
-//            assert(false);
-//        }
-//        exportEntity = ( Export ) em.get( entityExportUUID );
-//        assertNotNull( exportEntity );
-//        assertEquals( "FINISHED", exportEntity.getState().name() );
-//    }
-//
-//    //tests that with empty job data, the export still runs.
-//    @Test
-//    public void testExportEmptyJobData() throws Exception {
-//
-//        JobData jobData = new JobData();
-//
-//        JobExecution jobExecution = mock( JobExecution.class );
-//
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
-//
-//        ExportJob job = new ExportJob();
-//        S3Export s3Export = mock( S3Export.class );
-//        setup.getExportService().setS3Export( s3Export );
-//        job.setExportService( setup.getExportService() );
-//        try {
-//            job.doJob( jobExecution );
-//        }
-//        catch ( Exception e ) {
-//            assert ( false );
-//        }
-//        assert ( true );
-//    }
-//
-//
-//    @Test
-//    public void testNullJobExecution() {
+    @Test
+    public void testExportOneOrgCollectionEndpoint() throws Exception {
+
+        File f = null;
+
+
+        try {
+            f = new File( "exportOneOrg.json" );
+            f.delete();
+        }
+        catch ( Exception e ) {
+            //consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
+        }
+        setup.getMgmtSvc()
+             .createOwnerAndOrganization( "noExport", "junkUserName", "junkRealName", "ugExport@usergrid.com",
+                     "123456789" );
+
+        S3Export s3Export = new MockS3ExportImpl();
+        s3Export.setFilename("exportOneOrg.json");
+        ExportService exportService = setup.getExportService();
+        HashMap<String, Object> payload = payloadBuilder();
+
+//        ExportInfo exportInfo = new ExportInfo( payload );
+//        exportInfo.setOrganizationId( organization.getUuid() );
+//        exportInfo.setApplicationId( applicationId );
+//        exportInfo.setCollection( "roles" );
+
+        payload.put( "organizationId",organization.getUuid() );
+        payload.put( "applicationId",applicationId);
+        payload.put( "collectionName","roles");
+
+        UUID exportUUID = exportService.schedule( payload );
+        exportService.setS3Export( s3Export );
+
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
+
+        JobExecution jobExecution = mock( JobExecution.class );
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        exportService.doExport( jobExecution );
+
+        JSONParser parser = new JSONParser();
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
+
+        assertEquals( 3 , a.size() );
+        for ( int i = 0; i < a.size(); i++ ) {
+            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject ) a.get( i );
+            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
+            String entityName = ( String ) entityData.get( "name" );
+            // assertNotEquals( "NotEqual","junkRealName",entityName );
+            assertFalse( "junkRealName".equals( entityName ) );
+        }
+        f.delete();
+    }
 //
-//        JobData jobData = new JobData();
 //
-//        JobExecution jobExecution = mock( JobExecution.class );
+    @Test
+    public void testExportOneAppOnCollectionEndpoint() throws Exception {
+
+        File f = null;
+        String orgName = "ed-organization";
+        String appName = "testAppCollectionTestNotExported";
+
+        try {
+            f = new File( "exportOneApp.json" );
+            f.delete();
+        }
+        catch ( Exception e ) {
+            //consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
+        }
+
+        UUID appId = setup.getEmf().createApplication( orgName, appName );
+
+
+        EntityManager em = setup.getEmf().getEntityManager( appId );
+        //intialize user object to be posted
+        Map<String, Object> userProperties = null;
+        Entity[] entity;
+        entity = new Entity[1];
+        //creates entities
+        for ( int i = 0; i < 1; i++ ) {
+            userProperties = new LinkedHashMap<String, Object>();
+            userProperties.put( "username", "junkRealName");
+            userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
+            entity[i] = em.create( "user", userProperties );
+        }
+
+        S3Export s3Export = new MockS3ExportImpl();
+        s3Export.setFilename( "exportOneApp.json" );
+        ExportService exportService = setup.getExportService();
+        HashMap<String, Object> payload = payloadBuilder();
+
+//        ExportInfo exportInfo = new ExportInfo( payload );
+//        exportInfo.setOrganizationId( organization.getUuid() );
+//        exportInfo.setApplicationId( applicationId );
+//        exportInfo.setCollection( "roles" ); // <- this line determines if it is a collection back up or a application backup.
+
+        payload.put( "organizationId",organization.getUuid() );
+        payload.put( "applicationId",applicationId);
+
+        UUID exportUUID = exportService.schedule( payload );
+        exportService.setS3Export( s3Export );
+
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
+
+        JobExecution jobExecution = mock( JobExecution.class );
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        exportService.doExport( jobExecution );
+
+        JSONParser parser = new JSONParser();
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
+
+        assertEquals( 3 , a.size() );
+        for ( int i = 0; i < a.size(); i++ ) {
+            org.json.simple.JSONObject data = ( org.json.simple.JSONObject ) a.get( i );
+            org.json.simple.JSONObject entityData = ( JSONObject ) data.get( "Metadata" );
+            String entityName = ( String ) entityData.get( "name" );
+            assertFalse( "junkRealName".equals( entityName ) );
+        }
+        f.delete();
+    }
 //
-//        when( jobExecution.getJobData() ).thenReturn( jobData );
+    @Test
+    public void testExportOneAppOnApplicationEndpoint() throws Exception {
+
+        File f = null;
+        String orgName = "ed-organization";
+        String appName = "testAppNotExported";
+
+        try {
+            f = new File( "exportOneApp.json" );
+            f.delete();
+        }
+        catch ( Exception e ) {
+            //consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
+        }
+
+        UUID appId = setup.getEmf().createApplication( orgName, appName );
+
+
+        EntityManager em = setup.getEmf().getEntityManager( appId );
+        //intialize user object to be posted
+        Map<String, Object> userProperties = null;
+        Entity[] entity;
+        entity = new Entity[1];
+        //creates entities
+        for ( int i = 0; i < 1; i++ ) {
+            userProperties = new LinkedHashMap<String, Object>();
+            userProperties.put( "username", "junkRealName");
+            userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
+            entity[i] = em.create( "users", userProperties );
+        }
+
+        S3Export s3Export = new MockS3ExportImpl();
+        s3Export.setFilename( "exportOneApp.json" );
+        ExportService exportService = setup.getExportService();
+        HashMap<String, Object> payload = payloadBuilder();
+
+//        ExportInfo exportInfo = new ExportInfo( payload );
+//        exportInfo.setOrganizationId( organization.getUuid() );
+//        exportInfo.setApplicationId( applicationId );
+
+        payload.put( "organizationId",organization.getUuid() );
+        payload.put( "applicationId",applicationId);
+
+        UUID exportUUID = exportService.schedule( payload );
+        exportService.setS3Export( s3Export );
+
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
+
+        JobExecution jobExecution = mock( JobExecution.class );
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        exportService.doExport( jobExecution );
+
+        JSONParser parser = new JSONParser();
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
+
+        //assertEquals( 3 , a.size() );
+        for ( int i = 0; i < a.size(); i++ ) {
+            org.json.simple.JSONObject data = ( org.json.simple.JSONObject ) a.get( i );
+            org.json.simple.JSONObject entityData = ( JSONObject ) data.get( "Metadata" );
+            String entityName = ( String ) entityData.get( "name" );
+            assertFalse( "junkRealName".equals( entityName ) );
+        }
+        f.delete();
+    }
 //
-//        ExportJob job = new ExportJob();
-//        S3Export s3Export = mock( S3Export.class );
-//        setup.getExportService().setS3Export( s3Export );
-//        job.setExportService( setup.getExportService() );
-//        try {
-//            job.doJob( jobExecution );
-//        }
-//        catch ( Exception e ) {
-//            assert ( false );
-//        }
-//        assert ( true );
-//    }
+    @Test
+    public void testExportOneCollection() throws Exception {
+
+        File f = null;
+        int entitiesToCreate = 10000;
+
+        try {
+            f = new File( "exportOneCollection.json" );
+            f.delete();
+        }
+        catch ( Exception e ) {
+            //consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
+        }
+
+        EntityManager em = setup.getEmf().getEntityManager( applicationId);
+        em.createApplicationCollection( "baconators" );
+        //intialize user object to be posted
+        Map<String, Object> userProperties = null;
+        Entity[] entity;
+        entity = new Entity[entitiesToCreate];
+        //creates entities
+        for ( int i = 0; i < entitiesToCreate; i++ ) {
+            userProperties = new LinkedHashMap<String, Object>();
+            userProperties.put( "username", "billybob" + i );
+            userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
+            entity[i] = em.create( "baconators", userProperties );
+        }
+
+        S3Export s3Export = new MockS3ExportImpl();
+        s3Export.setFilename( "exportOneCollection.json" );
+        ExportService exportService = setup.getExportService();
+        HashMap<String, Object> payload = payloadBuilder();
+
+//        ExportInfo exportInfo = new ExportInfo( payload );
+//        exportInfo.setOrganizationId( organization.getUuid() );
+//        exportInfo.setApplicationId( applicationId );
+//        exportInfo.setCollection( "baconators" );
+        payload.put( "organizationId",organization.getUuid() );
+        payload.put( "applicationId",applicationId);
+        payload.put( "collectionName","baconators");
+
+        UUID exportUUID = exportService.schedule( payload );
+        exportService.setS3Export( s3Export );
+
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
+
+        JobExecution jobExecution = mock( JobExecution.class );
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        exportService.doExport( jobExecution );
+
+        JSONParser parser = new JSONParser();
+
+        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
+
+        assertEquals( entitiesToCreate , a.size() );
+        f.delete();
+    }
 //
 //
+//    //only handles the DoJob Code , different tests for DoExport
+    @Test
+    public void testExportDoJob() throws Exception {
+
+        HashMap<String, Object> payload = payloadBuilder();
+
+//        ExportInfo exportInfo = new ExportInfo( payload );
+//        exportInfo.setOrganizationId( organization.getUuid() );
+//        exportInfo.setApplicationId( applicationId );
+        payload.put( "organizationId",organization.getUuid() );
+        payload.put( "applicationId",applicationId);
+
+
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload ); //this needs to be populated with properties of export info
+
+        JobExecution jobExecution = mock( JobExecution.class );
+
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        ExportJob job = new ExportJob();
+        ExportService eS = mock( ExportService.class );
+        job.setExportService( eS );
+        try {
+            job.doJob( jobExecution );
+        }
+        catch ( Exception e ) {
+            assert ( false );
+        }
+        assert ( true );
+    }
+
+    @Test
+    public void testExportDoExportOnApplicationEndpoint() throws Exception {
+
+        EntityManagerFactory emf = setup.getEmf();
+        EntityManager em = emf.getEntityManager( applicationId );
+        HashMap<String, Object> payload = payloadBuilder();
+        ExportService eS = setup.getExportService();
+
+        JobExecution jobExecution = mock( JobExecution.class );
+
+//        ExportInfo exportInfo = new ExportInfo( payload );
+//        exportInfo.setOrganizationId( organization.getUuid() );
+//        exportInfo.setApplicationId( applicationId );
+        payload.put("organizationId",organization.getUuid());
+        payload.put("applicationId",applicationId);
+
+        UUID entityExportUUID = eS.schedule( payload);
+
+
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", entityExportUUID );
+
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        //Exportem.get(entityExport);
+        Export exportEntity = ( Export ) em.get( entityExportUUID );
+        assertNotNull( exportEntity );
+        String derp = exportEntity.getState().name();
+        assertEquals( "SCHEDULED", exportEntity.getState().name() );
+        try {
+            eS.doExport( jobExecution );
+        }
+        catch ( Exception e ) {
+            //throw e;
+            assert(false);
+        }
+        exportEntity = ( Export ) em.get( entityExportUUID );
+        assertNotNull( exportEntity );
+        assertEquals( "FINISHED", exportEntity.getState().name() );
+    }
+
+    //tests that with empty job data, the export still runs.
+    @Test
+    public void testExportEmptyJobData() throws Exception {
+
+        JobData jobData = new JobData();
+
+        JobExecution jobExecution = mock( JobExecution.class );
+
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        ExportJob job = new ExportJob();
+        S3Export s3Export = mock( S3Export.class );
+        setup.getExportService().setS3Export( s3Export );
+        job.setExportService( setup.getExportService() );
+        try {
+            job.doJob( jobExecution );
+        }
+        catch ( Exception e ) {
+            assert ( false );
+        }
+        assert ( true );
+    }
+
+
+    @Test
+    public void testNullJobExecution() {
+
+        JobData jobData = new JobData();
+
+        JobExecution jobExecution = mock( JobExecution.class );
+
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        ExportJob job = new ExportJob();
+        S3Export s3Export = mock( S3Export.class );
+        setup.getExportService().setS3Export( s3Export );
+        job.setExportService( setup.getExportService() );
+        try {
+            job.doJob( jobExecution );
+        }
+        catch ( Exception e ) {
+            assert ( false );
+        }
+        assert ( true );
+    }
+
+
     @Ignore //For this test please input your s3 credentials into payload builder.
     public void testIntegration100EntitiesOn() throws Exception {