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();
68 protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
69 return new DimensionClient(clientPropertiesFilename);
77 public void create(String testName) throws Exception {
78 String csid = this.createTestObject(testName);
79 if (this.knownResourceId == null) {
80 this.knownResourceId = csid;
85 public void read(String testName) throws Exception {
87 DimensionClient client = new DimensionClient();
88 Response res = client.getWorkflow(knownResourceId);
90 assertStatusCode(res, testName);
91 PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
92 WorkflowCommon workflowsCommon = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
93 if (logger.isDebugEnabled() == true) {
94 logger.debug("Workflow payload is: " + input.getXmlPayload());
96 Assert.assertNotNull(workflowsCommon);
105 // FIXME: REM - This test should be a subclass of BaseServiceTest and *not* AbstractPoxServiceTestImpl
109 public void update(String testName) throws Exception {
111 updateLifeCycleState(testName, knownResourceId, WorkflowClient.WORKFLOWTRANSITION_DELETE, WorkflowClient.WORKFLOWSTATE_DELETED);
115 public void delete(String testName) throws Exception {
119 public void searchWorkflowDeleted(String testName) throws Exception {
124 public void readList(String testName) throws Exception {
129 public void readPaginatedList(String testName) throws Exception {
134 public void CRUDTests(String testName) {
135 // TODO Auto-generated method stub
139 protected WorkflowCommon updateInstance(WorkflowCommon commonPartObject) {
140 // TODO Auto-generated method stub
145 protected void compareUpdatedInstances(WorkflowCommon original,
146 WorkflowCommon updated) throws Exception {
147 // TODO Auto-generated method stub
153 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
156 public void createList(String testName) throws Exception {
160 public void testSubmitRequest() {
164 // ---------------------------------------------------------------
165 // Utility methods used by tests above
166 // ---------------------------------------------------------------
169 protected PoxPayloadOut createInstance(String identifier) {
170 String dimensionsCommonPartName = new DimensionClient().getCommonPartName();
171 return createInstance(identifier, dimensionsCommonPartName);
175 protected PoxPayloadOut createInstance(String commonPartName,
177 return createDimensionInstance(commonPartName, identifier);
181 * We're using a DimensionsCommon instance to test the workflow service.
183 private PoxPayloadOut createDimensionInstance(String dimensionValue) {
184 String commonPartName = new DimensionClient().getCommonPartName();
185 return createDimensionInstance(commonPartName, dimensionValue);
189 * We're using a DimensionsCommon instance to test the workflow service.
191 private PoxPayloadOut createDimensionInstance(String commonPartName,
192 String dimensionValue) {
193 String measurementUnit = "measurementUnit-" + dimensionValue;
194 DimensionsCommon dimensionsCommon = new DimensionsCommon();
196 dimensionsCommon.setMeasurementUnit(measurementUnit);
197 PoxPayloadOut multipart = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
198 PayloadOutputPart commonPart = multipart.addPart(commonPartName, dimensionsCommon);
200 if (logger.isDebugEnabled()) {
201 logger.debug("To be created, Dimensions common: " + commonPart.asXML());
202 logger.debug(objectAsXmlString(dimensionsCommon, DimensionsCommon.class));