* @return the multipart output
*/
protected PoxPayloadOut createDimensionInstance(String commonPartName, String identifier) {
- final String DIMENSION_VALUE = "78.306";
+ final String dimensionValue = Long.toString(System.currentTimeMillis());
return createDimensionInstance(commonPartName,
"dimensionType-" + identifier,
- DIMENSION_VALUE,
+ dimensionValue,
"entryDate-" + identifier);
}
@Test void deleteCollectionObjectRelationshipToLockedDimension() {
+ // First create a CollectionObject
+ CollectionobjectsCommon co = new CollectionobjectsCommon();
+ fillCollectionObject(co, createIdentifier());
+ PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
+
+ // Make the "create" call and check the response
+ ClientResponse<Response> response = collectionObjectClient.create(multipart);
+ String collectionObjectCsid = null;
+ try {
+ Assert.assertEquals(response.getStatus(), Response.Status.CREATED
+ .getStatusCode());
+ collectionObjectCsid = extractId(response);
+ } finally {
+ response.releaseConnection();
+ }
+
+ // Create a new dimension record
+ multipart = this.createDimensionInstance(createIdentifier());
+ // Make the call to create and check the response
+ response = dimensionClient.create(multipart);
+ String dimensionCsid1 = null;
+ try {
+ Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+ dimensionCsid1 = extractId(response);
+ } finally {
+ response.releaseConnection();
+ }
+
+ // Relate the entities, by creating a new relation object
+ RelationsCommon relation = new RelationsCommon();
+ fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
+ dimensionCsid1, DimensionsCommon.class.getSimpleName(),
+ "collectionobject-dimension");
+ // Create the part and fill it with the relation object
+ multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
+ commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
+ // Create the relationship
+ response = relationClient.create(multipart);
+ String relationCsid1 = null;
+ try {
+ Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+ relationCsid1 = extractId(response);
+ } finally {
+ response.releaseConnection();
+ }
+
+ // Now lock the dimension record.
+
+ @SuppressWarnings("unused")
+ ClientResponse<String> workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
+ System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
+
+ // Finally, try to delete the relationship
+
+ // Try to delete the relationship -should fail because we don't allow delete if one of the sides is locked.
+ response = relationClient.delete(relationCsid1);
+ try {
+ Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ response.releaseConnection();
+ }
+
+ // Also, try to soft-delete. This should also fail.
+ workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_DELETE);
+ System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
+ }
+
+ @Test void createCollectionObjectRelationshipToManyDimensions() {
//
// First create a CollectionObject
//
CollectionobjectsCommon co = new CollectionobjectsCommon();
- fillCollectionObject(co, createIdentifier());
-
- // Next, create a part object
+ fillCollectionObject(co, createIdentifier());
PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
response.releaseConnection();
}
- //Next, create two Dimension records to relate the collection object to
+ //Next, create the first of three Dimension records to relate the collection object record
multipart = this.createDimensionInstance(createIdentifier());
// Make the call to create and check the response
response = dimensionClient.create(multipart);
} finally {
response.releaseConnection();
}
+
//Next, create a the second Dimension record
multipart = this.createDimensionInstance(createIdentifier());
// Make the call to create and check the response
} finally {
response.releaseConnection();
}
+
//Next, create a the 3rd Dimension record
multipart = this.createDimensionInstance(createIdentifier());
// Make the call to create and check the response
// Relate the entities, by creating a new relation object
RelationsCommon relation = new RelationsCommon();
- fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
- dimensionCsid1, DimensionsCommon.class.getSimpleName(),
+ fillRelation(relation,
+ collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
+ dimensionCsid1, DimensionsCommon.class.getSimpleName(), // the object of the relationship
"collectionobject-dimension");
// Create the part and fill it with the relation object
multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
} finally {
response.releaseConnection();
}
- // Create the second relationship
+ // Wait 1 second and create the second relationship
+ try {
+ Thread.sleep(1001);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
relation = new RelationsCommon();
- fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
- dimensionCsid2, DimensionsCommon.class.getSimpleName(),
+ fillRelation(relation,
+ collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
+ dimensionCsid2, DimensionsCommon.class.getSimpleName(), // the object of the relationship
"collectionobject-dimension");
// Create the part and fill it with the relation object
multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
} finally {
response.releaseConnection();
}
- // Create the 3rd relationship - but invert it this time
+ // Wait 1 second and create the 3rd relationship
+ try {
+ Thread.sleep(1001);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
relation = new RelationsCommon();
fillRelation(relation,
- dimensionCsid3, DimensionsCommon.class.getSimpleName(),
- collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
+ collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
+ dimensionCsid3, DimensionsCommon.class.getSimpleName(), // the object of the relationship
"collectionobject-dimension");
// Create the part and fill it with the relation object
multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
relationCsid3 = extractId(response);
} finally {
response.releaseConnection();
- }
-
-
- // Now lock the dimension record.
-
- @SuppressWarnings("unused")
- ClientResponse<String> workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
- System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
-
- // Finally, try to delete the relationship
-
- // Try to delete the relationship -should fail because we don't allow delete if one of the sides is locked.
- response = relationClient.delete(relationCsid1);
- try {
- Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
- } finally {
- response.releaseConnection();
- }
-
- // Also, try to soft-delete. This should also fail.
- workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_DELETE);
- System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
- }
-
+ }
+ }
@Test void releteCollectionObjectToLockedDimension() {
//