]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6301: Added 'undelete' tests in a base test class.
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 13 Feb 2014 05:08:01 +0000 (21:08 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 13 Feb 2014 05:08:01 +0000 (21:08 -0800)
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/client/src/main/java/org/collectionspace/services/client/workflow/WorkflowClient.java

index d7c7b723df1d4e187442bf573bfc76c643e59335..9a1abdaaf8bb4bfaa36f7ce885e1b688d8de94f8 100644 (file)
@@ -563,6 +563,47 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
             }
             Assert.assertEquals(result, STATUS_NOT_FOUND);
 
+            //
+            // Undelete the soft-deleted record
+            //
+            this.setupUpdate();
+            this.updateLifeCycleState(testName, csid, WorkflowClient.WORKFLOWTRANSITION_UNDELETE, WorkflowClient.WORKFLOWSTATE_PROJECT);
+
+            //
+            // Read the list of existing non-deleted records, to verify that
+            // the undeleted record is once again returned in that list.
+            //
+            updatedTotal = readIncludeDeleted(testName, Boolean.FALSE);
+            Assert.assertEquals(updatedTotal, existingRecords + OBJECTS_TO_CREATE, "Expected item is missing from list results.");
+
+            //
+            // Next, test that a GET with WorkflowClient.WORKFLOWSTATE_DELETED query param set to 'false' returns a 200;
+            // that the formerly 'Not Found' record is once again being found.
+            //
+            trials = 0;
+            result = 0;
+            while (trials < 30) {
+                   CollectionSpacePoxClient client = this.assertPoxClient();
+                   ClientResponse<String> res = client.readIncludeDeleted(csid, Boolean.FALSE);
+                   result = res.getStatus();
+                   if (result == STATUS_OK) {
+                       logger.info("Workflow transition to 'project' is complete");
+                       break;
+                   } else {
+                       /*
+                        * This should never happen, but if it does we need a full stack trace to help track it down.
+                        */
+                       try {
+                               throw new RuntimeException(ERROR_WORKFLOW_TRANSITION);
+                       } catch (RuntimeException e) {
+                               logger.info(ERROR_WORKFLOW_TRANSITION, e);
+                       }
+                   }
+                   trials++;
+            }
+            Assert.assertEquals(result, STATUS_OK);
+
+
         } catch (UnsupportedOperationException e) {
             logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method.  No workflow tests performed.");
             return;
index 1d72d0fb5a8f991a5a39a7e9cce43419f7a04a99..60e0d4435c83cece65dc6c0b4c0f17811fe1b00c 100644 (file)
@@ -44,6 +44,7 @@ public class WorkflowClient extends AbstractCommonListPoxServiceClientImpl<Workf
        public static final String WORKFLOWSTATE_DELETED = "deleted";
        
        public static final String WORKFLOWSTATE_ACTIVE = "active";
+       public static final String WORKFLOWSTATE_PROJECT = "project";
        
        public static final String WORKFLOWTRANSITION_LOCK = "lock";
        public static final String WORKFLOWSTATE_LOCKED = "locked";