From a2d4719938c64ca52e197a6676fd5173c8960eb5 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Wed, 13 Jun 2012 13:52:32 -0700 Subject: [PATCH] CSPACE-5036: Since we can't seem to get paging on CMIS queries working, we need to update the paging info in the list results to show meaning statistics. --- .../test/RelationIntegrationTest.java | 137 +++++++++++++----- .../client/java/RepositoryJavaClientImpl.java | 14 ++ 2 files changed, 113 insertions(+), 38 deletions(-) diff --git a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java index b9e546010..ba1707657 100644 --- a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java +++ b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java @@ -128,22 +128,89 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { * @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 = 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 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); @@ -158,7 +225,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { 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); @@ -169,6 +236,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { } finally { response.releaseConnection(); } + //Next, create a the second Dimension record multipart = this.createDimensionInstance(createIdentifier()); // Make the call to create and check the response @@ -180,6 +248,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { } finally { response.releaseConnection(); } + //Next, create a the 3rd Dimension record multipart = this.createDimensionInstance(createIdentifier()); // Make the call to create and check the response @@ -194,8 +263,9 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { // 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); @@ -209,10 +279,17 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { } 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); @@ -227,11 +304,17 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { } 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); @@ -245,30 +328,8 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest { relationCsid3 = extractId(response); } finally { response.releaseConnection(); - } - - - // Now lock the dimension record. - - @SuppressWarnings("unused") - ClientResponse 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() { // diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java index 34ad39969..7bf986185 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java @@ -837,6 +837,20 @@ public class RepositoryJavaClientImpl implements RepositoryClient docFilter.getPageSize()) { + docFilter.setPageSize(totalSize); + ((DocumentModelListImpl)result).setTotalSize(totalSize); + } + } + return result; } -- 2.47.3