You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/02/12 00:03:41 UTC
incubator-usergrid git commit: Fixes incorrect return type
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o-import fb8a1f09b -> be7789e4f
Fixes incorrect return type
Fixes incorrect assertion in test wait loop
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/be7789e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/be7789e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/be7789e4
Branch: refs/heads/two-dot-o-import
Commit: be7789e4f5a78af7feeb452ded44f1680f18b54c
Parents: fb8a1f0
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Feb 11 16:03:39 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Feb 11 16:03:39 2015 -0700
----------------------------------------------------------------------
.../management/importer/ImportService.java | 2 +-
.../management/importer/ImportServiceImpl.java | 22 +++++++++++---------
.../management/importer/ImportCollectionIT.java | 4 ++--
.../management/importer/ImportServiceIT.java | 21 +++++++++----------
4 files changed, 25 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/be7789e4/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java
index d63c076..0fd4092 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java
@@ -112,7 +112,7 @@ public interface ImportService {
* @param uuid Job UUID
* @return State of Job
*/
- String getState(UUID uuid) throws Exception;
+ Import.State getState( UUID uuid ) throws Exception;
/**
* Returns error message for the job with UUID
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/be7789e4/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
index 6662c0e..e7609e7 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
@@ -420,11 +420,10 @@ public class ImportServiceImpl implements ImportService {
* Query Entity Manager for the state of the Import Entity. This corresponds to the GET /import
*/
@Override
- public String getState(UUID uuid) throws Exception {
- if (uuid == null) {
- logger.error("getState(): UUID passed in cannot be null.");
- return "UUID passed in cannot be null";
- }
+ public Import.State getState( UUID uuid ) throws Exception {
+
+ Preconditions.checkNotNull( uuid, "uuid cannot be null" );
+
EntityManager rootEm = emf.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
@@ -432,10 +431,10 @@ public class ImportServiceImpl implements ImportService {
Import importUG = rootEm.get(uuid, Import.class);
if (importUG == null) {
- logger.error("getState(): no entity with that uuid was found");
- return "No Such Element found";
+ throw new EntityNotFoundException( "Could not find entity with uuid " + uuid );
}
- return importUG.getState().toString();
+
+ return importUG.getState();
}
/**
@@ -804,10 +803,13 @@ public class ImportServiceImpl implements ImportService {
logger.debug("{} Got importEntity {}", randTag, importEntity.getUuid());
EntityManager emMgmtApp = emf.getEntityManager( CpNamingUtils.MANAGEMENT_APPLICATION_ID );
- Query query = Query.fromQL("select *");
- query.setEntityType("file_import");
+
+
+ Query query = new Query();
+ query.setEntityType(Schema.getDefaultSchema().getEntityType( FileImport.class ));
query.setConnectionType( IMPORT_FILE_INCLUDES_CONNECTION );
query.setLimit(MAX_FILE_IMPORTS);
+
Results entities = emMgmtApp.searchConnectedEntities(importEntity, query);
PagingResultsIterator itr = new PagingResultsIterator(entities);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/be7789e4/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index 0d20ea1..54bfc1a 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@ -441,8 +441,8 @@ public class ImportCollectionIT {
int maxRetries = 120;
int retries = 0;
- while ( (!importService.getState( importEntity.getUuid() ).equals( "FINISHED" ) ||
- !importService.getState( importEntity.getUuid() ).equals( "FAILED" )) && retries++ < maxRetries ) {
+ while ( (!importService.getState( importEntity.getUuid() ).equals( Import.State.FAILED) &&
+ !importService.getState( importEntity.getUuid() ).equals( Import.State.FINISHED )) && retries++ < maxRetries ) {
logger.debug("Waiting for import...");
Thread.sleep(1000);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/be7789e4/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
index b4d9a80..45862de 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
@@ -38,6 +38,7 @@ import org.apache.usergrid.management.export.S3ExportImpl;
import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.Import;
import org.apache.usergrid.persistence.entities.JobData;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
import org.apache.usergrid.persistence.index.query.Query.Level;
import org.apache.usergrid.persistence.index.utils.UUIDUtils;
@@ -326,7 +327,7 @@ public class ImportServiceIT {
//import the all application files for the organization and wait for the import to finish
importService.doImport(jobExecution);
- while ( !importService.getState( importUUID ).equals( "FINISHED" ) ) {
+ while ( !importService.getState( importUUID ).equals( Import.State.FINISHED ) ) {
;
}
@@ -405,27 +406,25 @@ public class ImportServiceIT {
/**
* Test to get state of a job with null UUID
*/
- @Test
+ @Test(expected = NullPointerException.class)
public void testGetStateWithNullUUID() throws Exception {
UUID uuid= null;
ImportService importService = setup.getImportService();
- String state = importService.getState(uuid);
+ Import.State state = importService.getState( uuid );
- assertEquals(state,"UUID passed in cannot be null");
}
/**
* Test to get state of a job with fake UUID
*/
- @Test
+ @Test(expected = EntityNotFoundException.class)
public void testGetStateWithFakeUUID() throws Exception {
UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
ImportService importService = setup.getImportService();
- String state = importService.getState(fake);
+ Import.State state = importService.getState( fake );
- assertEquals(state,"No Such Element found");
}
@@ -476,7 +475,7 @@ public class ImportServiceIT {
when( jobExecution.getJobData() ).thenReturn( jobData );
importService.doImport(jobExecution);
- assertEquals(importService.getState(importUUID),"FAILED");
+ assertEquals(importService.getState(importUUID),Import.State.FAILED);
}
/**
@@ -506,7 +505,7 @@ public class ImportServiceIT {
//import the all application files for the organization and wait for the import to finish
importService.doImport(jobExecution);
- assertEquals("FAILED", importService.getState(importUUID));
+ assertEquals(Import.State.FAILED, importService.getState(importUUID));
}
/**
@@ -538,7 +537,7 @@ public class ImportServiceIT {
//import the application files for the organization and wait for the import to finish
importService.doImport(jobExecution);
- assertEquals("FAILED", importService.getState(importUUID));
+ assertEquals(Import.State.FAILED, importService.getState(importUUID));
}
/**
@@ -571,7 +570,7 @@ public class ImportServiceIT {
//import the all collection files for the organization-application and wait for the import to finish
importService.doImport(jobExecution);
- assertEquals(importService.getState(importUUID),"FAILED");
+ assertEquals(importService.getState(importUUID),Import.State.FAILED);
}
/*Creates fake payload for testing purposes.*/