2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright © 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 package org.collectionspace.services.client.test;
25 import org.collectionspace.services.client.CollectionSpaceClient;
26 import org.collectionspace.services.client.PayloadOutputPart;
27 import org.collectionspace.services.client.PoxPayloadIn;
28 import org.collectionspace.services.client.PoxPayloadOut;
30 import org.collectionspace.services.jaxb.AbstractCommonList;
31 import org.collectionspace.services.workflow.WorkflowCommon;
32 import org.collectionspace.services.client.DimensionClient;
33 import org.collectionspace.services.client.workflow.WorkflowClient;
34 import org.collectionspace.services.dimension.DimensionsCommon;
36 import org.jboss.resteasy.client.ClientResponse;
38 import org.testng.Assert;
40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory;
44 * ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
45 * $LastChangedRevision: $
48 public class WorkflowServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, WorkflowCommon> {
50 private final String CLASS_NAME = WorkflowServiceTest.class.getName();
51 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
52 private String knownResourceId = null;
55 public String getServicePathComponent() {
56 return WorkflowClient.SERVICE_PATH_COMPONENT;
60 protected String getServiceName() {
61 return WorkflowClient.SERVICE_NAME;
65 protected CollectionSpaceClient getClientInstance() {
66 return new DimensionClient();
74 public void create(String testName) throws Exception {
75 String csid = this.createTestObject(testName);
76 if (this.knownResourceId == null) {
77 this.knownResourceId = csid;
82 public void read(String testName) throws Exception {
84 DimensionClient client = new DimensionClient();
85 ClientResponse<String> res = client.getWorkflow(knownResourceId);
87 assertStatusCode(res, testName);
88 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
89 WorkflowCommon workflowsCommon = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
90 if (logger.isDebugEnabled() == true) {
91 logger.debug("Workflow payload is: " + input.getXmlPayload());
93 Assert.assertNotNull(workflowsCommon);
96 res.releaseConnection();
102 // FIXME: REM - This test should be a subclass of BaseServiceTest and *not* AbstractPoxServiceTestImpl
106 public void update(String testName) throws Exception {
108 updateLifeCycleState(testName, knownResourceId, WorkflowClient.WORKFLOWTRANSITION_DELETE, WorkflowClient.WORKFLOWSTATE_DELETED);
112 public void delete(String testName) throws Exception {
116 public void searchWorkflowDeleted(String testName) throws Exception {
121 public void readList(String testName) throws Exception {
126 public void readPaginatedList(String testName) throws Exception {
131 public void CRUDTests(String testName) {
132 // TODO Auto-generated method stub
136 protected WorkflowCommon updateInstance(WorkflowCommon commonPartObject) {
137 // TODO Auto-generated method stub
142 protected void compareUpdatedInstances(WorkflowCommon original,
143 WorkflowCommon updated) throws Exception {
144 // TODO Auto-generated method stub
150 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
153 public void createList(String testName) throws Exception {
157 public void testSubmitRequest() {
161 // ---------------------------------------------------------------
162 // Utility methods used by tests above
163 // ---------------------------------------------------------------
166 protected PoxPayloadOut createInstance(String identifier) {
167 String dimensionsCommonPartName = new DimensionClient().getCommonPartName();
168 return createInstance(identifier, dimensionsCommonPartName);
172 protected PoxPayloadOut createInstance(String commonPartName,
174 return createDimensionInstance(commonPartName, identifier);
178 * We're using a DimensionsCommon instance to test the workflow service.
180 private PoxPayloadOut createDimensionInstance(String dimensionValue) {
181 String commonPartName = new DimensionClient().getCommonPartName();
182 return createDimensionInstance(commonPartName, dimensionValue);
186 * We're using a DimensionsCommon instance to test the workflow service.
188 private PoxPayloadOut createDimensionInstance(String commonPartName,
189 String dimensionValue) {
190 String measurementUnit = "measurementUnit-" + dimensionValue;
191 DimensionsCommon dimensionsCommon = new DimensionsCommon();
193 dimensionsCommon.setMeasurementUnit(measurementUnit);
194 PoxPayloadOut multipart = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
195 PayloadOutputPart commonPart = multipart.addPart(commonPartName, dimensionsCommon);
197 if (logger.isDebugEnabled()) {
198 logger.debug("To be created, Dimensions common: " + commonPart.asXML());
199 logger.debug(objectAsXmlString(dimensionsCommon, DimensionsCommon.class));