]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5564: Added a test to the report service that creates a new Acquisition report...
authorRichard Millet <richard.millet@berkeley.edu>
Wed, 23 Jan 2013 23:13:28 +0000 (15:13 -0800)
committerRichard Millet <richard.millet@berkeley.edu>
Wed, 23 Jan 2013 23:13:28 +0000 (15:13 -0800)
services/acquisition/client/pom.xml
services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java
services/acquisition/jaxb/pom.xml
services/report/client/pom.xml
services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java

index 4b525679371095a47025dd095cd9d2d695e46203..ee2f64bc07a5201f475b3d4dbb71b2c989f49521 100644 (file)
@@ -9,7 +9,6 @@
     </parent>\r
 \r
     <modelVersion>4.0.0</modelVersion>\r
-    <groupId>org.collectionspace.services</groupId>\r
     <artifactId>org.collectionspace.services.acquisition.client</artifactId>\r
     <name>services.acquisition.client</name>\r
     <packaging>jar</packaging>\r
index 77fff67dfd6037b9668ceb27689131402e05c2d0..52814b637e8a73e57691ac54579c3e9017ba227d 100644 (file)
@@ -1,8 +1,5 @@
 package org.collectionspace.services.client;
 
-import org.jboss.resteasy.client.ClientResponse;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-
 /**
  * An AcquisitionClient.
 
index 75c9486f5618297c6f77936fa3f1185f37919b55..807085dd2f6c812f5d9fcdb181f47539c7b74bf8 100644 (file)
@@ -9,7 +9,6 @@
     </parent>
     
     <modelVersion>4.0.0</modelVersion>
-    <groupId>org.collectionspace.services</groupId>
     <artifactId>org.collectionspace.services.acquisition.jaxb</artifactId>
     <name>services.acquisition.jaxb</name>
     
index b5c239a6cfe63617c41cf6378b648bfd44cb7404..ac3abe89448f1b2f523e65e9d275386a541f24e6 100644 (file)
@@ -9,7 +9,6 @@
     </parent>\r
 \r
     <modelVersion>4.0.0</modelVersion>\r
-    <groupId>org.collectionspace.services</groupId>\r
     <artifactId>org.collectionspace.services.report.client</artifactId>\r
     <name>services.report.client</name>\r
     \r
             <artifactId>org.collectionspace.services.person.client</artifactId>\r
             <version>${project.version}</version>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.acquisition.client</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.acquisition.jaxb</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.organization.client</artifactId>\r
@@ -84,7 +93,6 @@
         <dependency>\r
             <groupId>commons-httpclient</groupId>\r
             <artifactId>commons-httpclient</artifactId>\r
-            <version>3.1</version>\r
         </dependency>\r
     </dependencies>\r
     \r
index 6b69486a56c92685c84edb58db44f37db139e6df..b893e68d476a008fe58187787467c3e88cab1f78 100644 (file)
  */
 package org.collectionspace.services.client.test;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import org.collectionspace.services.acquisition.AcquisitionSourceList;
+import org.collectionspace.services.acquisition.AcquisitionsCommon;
+import org.collectionspace.services.acquisition.StructuredDateGroup;
 import org.collectionspace.services.client.AbstractCommonListUtils;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.PayloadOutputPart;
@@ -35,6 +40,7 @@ import org.collectionspace.services.client.ReportClient;
 import org.collectionspace.services.common.invocable.InvocationContext;
 import org.collectionspace.services.report.ReportsCommon;
 import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.client.AcquisitionClient;
 
 import org.jboss.resteasy.client.ClientResponse;
 import org.testng.Assert;
@@ -62,15 +68,56 @@ public class ReportServiceTest extends AbstractPoxServiceTestImpl<AbstractCommon
     // Instance variables specific to this test.    
     private String testDocType = "Acquisition";
 
+    private String createAquisitionResource() {
+       String result = null;
+       
+       AcquisitionClient acquisitionClient = new AcquisitionClient();
+       AcquisitionsCommon acquisitionsCommon = new AcquisitionsCommon();
+       acquisitionsCommon.setAcquisitionReason("It was nice.");
+       acquisitionsCommon.setOriginalObjectPurchasePriceValue(new BigDecimal(500));
+       acquisitionsCommon.setAcquisitionReferenceNumber("2013.003.0004");
+       
+       AcquisitionSourceList asl = new AcquisitionSourceList();
+       List<String> sourceList = asl.getAcquisitionSource();
+       sourceList.add("The Jim Henson Legacy");
+       acquisitionsCommon.setAcquisitionSources(asl);
+       
+       StructuredDateGroup sdg = new StructuredDateGroup();
+       sdg.setDateDisplayDate("12/12/2012");
+       acquisitionsCommon.setAccessionDateGroup(sdg);
+       
+        PoxPayloadOut poxPayloadOut = new PoxPayloadOut(AcquisitionClient.SERVICE_PAYLOAD_NAME);
+        PayloadOutputPart commonPart = poxPayloadOut.addPart(acquisitionClient.getCommonPartName(), acquisitionsCommon);
+        ClientResponse<Response> res = acquisitionClient.create(poxPayloadOut);
+       try {
+            setupCreate();
+               int statusCode = res.getStatus();
+               if (logger.isDebugEnabled()) {
+                   logger.debug(this.getClass().getCanonicalName() + ": HTTP status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, testExpectedStatusCode);
+       
+               result = extractId(res);
+               // Store the IDs from every resource created by tests,
+               // so they can be deleted after tests have been run.
+               allResourceIdsCreated.add(result);
+       } finally {
+               res.releaseConnection();
+       }
+       
+       return result;
+    }
+    
     @Test(dataProvider = "testName", dependsOnMethods = {"create"})    
     public void publishReportInstance(String testName) throws Exception {
         // Perform setup.
-        setupCreate();
 
         // Submit the request to the service and store the response.
         ReportClient client = (ReportClient)this.getClientInstance();
-        
-        createReportInstance()
+        String reportCsid = createResource(testName, this.getKnowResourceIdentifier());
+       String acquisitionCsid = createAquisitionResource();
        
        //
        // Hard coded for now, but need to create this test in the Integration test area where
@@ -79,11 +126,11 @@ public class ReportServiceTest extends AbstractPoxServiceTestImpl<AbstractCommon
        InvocationContext invocationContext = new InvocationContext();
        invocationContext.setDocType("Acquisition");
        invocationContext.setMode("single");
-       invocationContext.setSingleCSID("34abdc63-944c-421d-a585");
+       invocationContext.setSingleCSID(acquisitionCsid);
        
-       String reportCsid = "8680d49c-99b8-4788-aa45";
         ClientResponse<Response> res = client.publishReport(reportCsid, invocationContext);
         int statusCode = res.getStatus();
+        setupCreate();
 
         // Check the status code of the response: does it match
         // the expected response(s)?