--- /dev/null
+package org.collectionspace.services.client.test;\r
+\r
+import org.collectionspace.services.client.CollectionSpaceClient;\r
+import org.collectionspace.services.client.CollectionSpaceCommonListPoxProxy;\r
+import org.collectionspace.services.client.PayloadInputPart;\r
+import org.collectionspace.services.client.PoxPayloadIn;\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+import org.jboss.resteasy.client.ClientResponse;\r
+import org.testng.Assert;\r
+\r
+/*\r
+ * CPT - Common Part Type\r
+ */\r
+public abstract class AbstractGenericServiceTestImpl<CPT> extends AbstractServiceTestImpl {\r
+ public CPT getCommonTypeInstance() {\r
+ CPT result = null;\r
+ return result;\r
+ }\r
+ \r
+ public CPT extractCommonPartValue(ClientResponse<String> res)\r
+ throws Exception {\r
+ CollectionSpaceClient<AbstractCommonList, CollectionSpaceCommonListPoxProxy> client = this.getClientInstance();\r
+ PayloadInputPart payloadInputPart = extractPart(res, client.getCommonPartName());\r
+ Object obj = null;\r
+ if (payloadInputPart != null) {\r
+ obj = payloadInputPart.getBody();\r
+ }\r
+ Assert.assertNotNull(obj,\r
+ "Body of " + client.getCommonPartName() + " part was unexpectedly null.");\r
+ CPT commonPartTypeInstance = (CPT) obj;\r
+ Assert.assertNotNull(commonPartTypeInstance,\r
+ client.getCommonPartName() + " part was unexpectedly null.");\r
+ return commonPartTypeInstance;\r
+ }\r
+ \r
+ private PayloadInputPart extractPart(ClientResponse<String> res, String partLabel)\r
+ throws Exception {\r
+ if (getLogger().isDebugEnabled()) {\r
+ getLogger().debug("Reading part " + partLabel + " ...");\r
+ }\r
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());\r
+ PayloadInputPart payloadInputPart = input.getPart(partLabel);\r
+ Assert.assertNotNull(payloadInputPart,\r
+ "Part " + partLabel + " was unexpectedly null.");\r
+ return payloadInputPart;\r
+ }\r
+ \r
+ \r
+}\r