public void createItem(String testName) throws Exception {
// Perform setup.
setupCreate();
-
String newID = createItemInAuthority((AuthorityClient) getClientInstance(), knownResourceId, getTestAuthorityItemShortId());
// Store the ID returned from the first item resource created
}
}
}
+
+ @Test(dataProvider = "testName", dependsOnMethods = {"readItem", "CRUDTests"})
+ public void checkAuthorityWorkflowTransitions(String testName) throws Exception {
+ //
+ // First check to see if the authority supports synchronization -i.e., the "cs_replicating" lifecycle policy.
+ //
+ assertSupportsSync();
+
+ String itemCsid = createItemInAuthority((AuthorityClient) getClientInstance(), knownResourceId, getTestAuthorityItemShortId() + testName);
+ // Add workflow states
+ updateItemLifeCycleState(testName, knownResourceId, itemCsid, WorkflowClient.WORKFLOWTRANSITION_REPLICATE, WorkflowClient.WORKFLOWSTATE_REPLICATED);
+ updateItemLifeCycleState(testName, knownResourceId, itemCsid, WorkflowClient.WORKFLOWTRANSITION_DEPRECATE, WorkflowClient.WORKFLOWSTATE_REPLICATED_DEPRECATED);
+ updateItemLifeCycleState(testName, knownResourceId, itemCsid, WorkflowClient.WORKFLOWTRANSITION_DELETE, WorkflowClient.WORKFLOWSTATE_REPLICATED_DEPRECATED_DELETED);
+ // Substract workflow states
+ updateItemLifeCycleState(testName, knownResourceId, itemCsid, WorkflowClient.WORKFLOWTRANSITION_UNREPLICATE, WorkflowClient.WORKFLOWSTATE_DEPRECATED_DELETED);
+ updateItemLifeCycleState(testName, knownResourceId, itemCsid, WorkflowClient.WORKFLOWTRANSITION_UNDELETE, WorkflowClient.WORKFLOWSTATE_DEPRECATED);
+ updateItemLifeCycleState(testName, knownResourceId, itemCsid, WorkflowClient.WORKFLOWTRANSITION_UNDEPRECATE, WorkflowClient.WORKFLOWSTATE_PROJECT);
+ // Add other workflow states
+ updateItemLifeCycleState(testName, knownResourceId, itemCsid, WorkflowClient.WORKFLOWTRANSITION_DELETE, WorkflowClient.WORKFLOWSTATE_DELETED);
+ updateItemLifeCycleState(testName, knownResourceId, itemCsid, WorkflowClient.WORKFLOWTRANSITION_REPLICATE, WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED);
+ }
+
/**
* Verify that we can test synchronization with this authority. Otherwise, we skip the test.
@SuppressWarnings("rawtypes")
- protected void updateLifeCycleState(String testName, String resourceId, String workflowTransition, String lifeCycleState) throws Exception {
+ protected void updateLifeCycleState(String testName, String resourceId, String workflowTransition, String expectedLifeCycleState) throws Exception {
//
// Read the existing object
//
// Mark it for a soft delete.
//
logger.debug("Current workflow state:" + objectAsXmlString(workflowCommons, WorkflowCommon.class));
- workflowCommons.setCurrentLifeCycleState(lifeCycleState);
+ workflowCommons.setCurrentLifeCycleState(expectedLifeCycleState);
PoxPayloadOut output = new PoxPayloadOut(WorkflowClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(WorkflowClient.SERVICE_COMMONPART_NAME, workflowCommons);
//
updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
Assert.assertNotNull(workflowCommons);
String currentWorkflowState = updatedWorkflowCommons.getCurrentLifeCycleState();
- if (currentWorkflowState.equalsIgnoreCase(lifeCycleState)) {
- logger.debug("Expected workflow state found: " + lifeCycleState);
+ if (currentWorkflowState.equalsIgnoreCase(expectedLifeCycleState)) {
+ logger.debug("Expected workflow state found: " + expectedLifeCycleState);
break;
}
} finally {
//
// Finally, assert the state change happened as expected.
//
- Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), lifeCycleState);
+ Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), expectedLifeCycleState);
}
private CollectionSpacePoxClient assertPoxClient() throws Exception {
}
}
- protected void updateItemLifeCycleState(String testName, String parentCsid, String itemCsid, String workflowTransition, String lifeCycleState) throws Exception {
+ protected String updateItemLifeCycleState(String testName, String parentCsid, String itemCsid, String workflowTransition, String expectedLifeCycleState) throws Exception {
//
// Read the existing object
//
Response res = client.readItemWorkflow(parentCsid, itemCsid);
WorkflowCommon workflowCommons = null;
try {
+ setupRead();
assertStatusCode(res, testName);
logger.debug("Got object to update life cycle state with ID: " + itemCsid);
PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
//
// Mark it for a state change.
//
- workflowCommons.setCurrentLifeCycleState(lifeCycleState);
+ workflowCommons.setCurrentLifeCycleState(expectedLifeCycleState);
PoxPayloadOut output = new PoxPayloadOut(WorkflowClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(WorkflowClient.SERVICE_COMMONPART_NAME, workflowCommons);
//
res = client.updateItemWorkflowWithTransition(parentCsid, itemCsid, workflowTransition);
WorkflowCommon updatedWorkflowCommons = null;
try {
+ setupUpdate();
assertStatusCode(res, testName);
PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
int trials = 0;
boolean passed = false;
+ setupRead();
while (trials < 30) { //wait to see if the lifecycle transition will happen
//
// Read the updated object and make sure it was updated correctly.
updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
Assert.assertNotNull(workflowCommons);
String currentState = updatedWorkflowCommons.getCurrentLifeCycleState();
- if (currentState.equalsIgnoreCase(lifeCycleState)) {
- logger.debug("Expected workflow state found: " + lifeCycleState);
+ if (currentState.equalsIgnoreCase(expectedLifeCycleState)) {
+ logger.debug("Expected workflow state found: " + expectedLifeCycleState);
break;
}
logger.debug("Workflow state not yet updated for object with id: " + itemCsid + " state is=" +
//
// Finally check to see if the state change was updated as expected.
//
- Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), lifeCycleState);
+ Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), expectedLifeCycleState);
+ return updatedWorkflowCommons.getCurrentLifeCycleState();
}
}