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 javax.ws.rs.core.Response;
27 import org.collectionspace.services.client.CollectionSpaceClient;
28 import org.collectionspace.services.client.PayloadOutputPart;
29 import org.collectionspace.services.client.PoxPayloadIn;
30 import org.collectionspace.services.client.PoxPayloadOut;
31 import org.collectionspace.services.jaxb.AbstractCommonList;
32 import org.collectionspace.services.workflow.WorkflowCommon;
33 import org.collectionspace.services.client.DimensionClient;
34 import org.collectionspace.services.client.workflow.WorkflowClient;
35 import org.collectionspace.services.dimension.DimensionsCommon;
36 import org.jboss.resteasy.client.ClientResponse;
37 import org.testng.Assert;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
42 * ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
43 * $LastChangedRevision: $
46 public class WorkflowServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, WorkflowCommon> {
48 private final String CLASS_NAME = WorkflowServiceTest.class.getName();
49 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
50 private String knownResourceId = null;
53 public String getServicePathComponent() {
54 return WorkflowClient.SERVICE_PATH_COMPONENT;
58 protected String getServiceName() {
59 return WorkflowClient.SERVICE_NAME;
63 protected CollectionSpaceClient getClientInstance() {
64 return new DimensionClient();
72 public void create(String testName) throws Exception {
73 String csid = this.createTestObject(testName);
74 if (this.knownResourceId == null) {
75 this.knownResourceId = csid;
80 public void read(String testName) throws Exception {
82 DimensionClient client = new DimensionClient();
83 Response res = client.getWorkflow(knownResourceId);
85 assertStatusCode(res, testName);
86 PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
87 WorkflowCommon workflowsCommon = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
88 if (logger.isDebugEnabled() == true) {
89 logger.debug("Workflow payload is: " + input.getXmlPayload());
91 Assert.assertNotNull(workflowsCommon);
100 // FIXME: REM - This test should be a subclass of BaseServiceTest and *not* AbstractPoxServiceTestImpl
104 public void update(String testName) throws Exception {
106 updateLifeCycleState(testName, knownResourceId, WorkflowClient.WORKFLOWTRANSITION_DELETE, WorkflowClient.WORKFLOWSTATE_DELETED);
110 public void delete(String testName) throws Exception {
114 public void searchWorkflowDeleted(String testName) throws Exception {
119 public void readList(String testName) throws Exception {
124 public void readPaginatedList(String testName) throws Exception {
129 public void CRUDTests(String testName) {
130 // TODO Auto-generated method stub
134 protected WorkflowCommon updateInstance(WorkflowCommon commonPartObject) {
135 // TODO Auto-generated method stub
140 protected void compareUpdatedInstances(WorkflowCommon original,
141 WorkflowCommon updated) throws Exception {
142 // TODO Auto-generated method stub
148 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
151 public void createList(String testName) throws Exception {
155 public void testSubmitRequest() {
159 // ---------------------------------------------------------------
160 // Utility methods used by tests above
161 // ---------------------------------------------------------------
164 protected PoxPayloadOut createInstance(String identifier) {
165 String dimensionsCommonPartName = new DimensionClient().getCommonPartName();
166 return createInstance(identifier, dimensionsCommonPartName);
170 protected PoxPayloadOut createInstance(String commonPartName,
172 return createDimensionInstance(commonPartName, identifier);
176 * We're using a DimensionsCommon instance to test the workflow service.
178 private PoxPayloadOut createDimensionInstance(String dimensionValue) {
179 String commonPartName = new DimensionClient().getCommonPartName();
180 return createDimensionInstance(commonPartName, dimensionValue);
184 * We're using a DimensionsCommon instance to test the workflow service.
186 private PoxPayloadOut createDimensionInstance(String commonPartName,
187 String dimensionValue) {
188 String measurementUnit = "measurementUnit-" + dimensionValue;
189 DimensionsCommon dimensionsCommon = new DimensionsCommon();
191 dimensionsCommon.setMeasurementUnit(measurementUnit);
192 PoxPayloadOut multipart = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
193 PayloadOutputPart commonPart = multipart.addPart(commonPartName, dimensionsCommon);
195 if (logger.isDebugEnabled()) {
196 logger.debug("To be created, Dimensions common: " + commonPart.asXML());
197 logger.debug(objectAsXmlString(dimensionsCommon, DimensionsCommon.class));