</service:uriPath>-->
<service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
<service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>displayName</service:element>
+ <service:xpath>displayName</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
<service:object xmlns:service="http://collectionspace.org/services/common/service" name="Contact" version="0.1">
<service:part id="0" control_group="Managed" versionable="true" auditable="false" label="contacts-system" updated="" order="0">
<service:content contentType="application/xml">
<xs:element name="csid" type="xs:string" />
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="inItem" type="xs:string" />
+ <xs:element name="displayName" type="xs:string" />
+
+ <xs:element name="emailGroupList" type="emailGroupList"/>
+ <xs:element name="telephoneNumberGroupList" type="telephoneNumberGroupList"/>
+ <xs:element name="faxNumberGroupList" type="faxNumberGroupList"/>
+ <xs:element name="webAddressGroupList" type="webAddressGroupList"/>
+ <xs:element name="addressGroupList" type="addressGroupList"/>
+
+ <xs:complexType name="emailGroupList">
+ <xs:sequence>
+ <xs:element name="emailGroup" type="emailGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
- <xs:element name="addressType" type="xs:string"/>
- <xs:element name="addressPlace" type="xs:string"/>
- <!-- FIXME After release 1.0, four additional fields are introduced here, -->
- <!-- and these fields, plus addressType and addressPlace, constitute a -->
- <!-- repeatable group. -->
+ <xs:complexType name="emailGroup">
+ <xs:sequence>
+ <xs:element name="email" type="xs:string"/>
+ <xs:element name="emailType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="telephoneNumberGroupList">
+ <xs:sequence>
+ <xs:element name="telephoneNumberGroup" type="telephoneNumberGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="telephoneNumberGroup">
+ <xs:sequence>
+ <xs:element name="telephoneNumber" type="xs:string"/>
+ <xs:element name="telephoneNumberType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="faxNumberGroupList">
+ <xs:sequence>
+ <xs:element name="faxNumberGroup" type="faxNumberGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="faxNumberGroup">
+ <xs:sequence>
+ <xs:element name="faxNumber" type="xs:string"/>
+ <xs:element name="faxNumberType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="webAddressGroupList">
+ <xs:sequence>
+ <xs:element name="webAddressGroup" type="webAddressGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="webAddressGroup">
+ <xs:sequence>
+ <xs:element name="webAddress" type="xs:string"/>
+ <xs:element name="webAddressType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="addressGroupList">
+ <xs:sequence>
+ <xs:element name="addressGroup" type="addressGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
- <xs:element name="web" type="xs:string"/>
- <xs:element name="email" type="xs:string"/>
- <xs:element name="telephoneNumber" type="xs:string"/>
- <xs:element name="faxNumber" type="xs:string"/>
+ <xs:complexType name="addressGroup">
+ <xs:sequence>
+ <xs:element name="addressPlace1" type="xs:string"/>
+ <xs:element name="addressPlace2" type="xs:string"/>
+ <xs:element name="addressMunicipality" type="xs:string"/>
+ <xs:element name="addressStateOrProvince" type="xs:string"/>
+ <xs:element name="addressPostCode" type="xs:string"/>
+ <xs:element name="addressCountry" type="xs:string"/>
+ <xs:element name="addressType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
</xs:schema>
<artifactId>org.collectionspace.services.client</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- External dependencies -->
<dependency>
<groupId>dom4j</groupId>
\r
import javax.ws.rs.core.Response;\r
\r
-import org.collectionspace.services.contact.ContactsCommonList;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
import org.jboss.resteasy.client.ClientResponse;\r
\r
* @param itemcsid the itemcsid\r
* @return the client response\r
*/\r
- public ClientResponse<ContactsCommonList> readContactList(String parentcsid,\r
+ public ClientResponse<AbstractCommonList> readContactList(String parentcsid,\r
String itemcsid);\r
\r
/**\r
* @param itemspecifier (shortIdentifier)\r
* @return the client response\r
*/\r
- public ClientResponse<ContactsCommonList> readContactListForNamedItem(\r
+ public ClientResponse<AbstractCommonList> readContactListForNamedItem(\r
String parentcsid,\r
String itemspecifier);\r
\r
* @param itemcsid\r
* @return the client response\r
*/\r
- public ClientResponse<ContactsCommonList> readContactListForItemInNamedAuthority(\r
+ public ClientResponse<AbstractCommonList> readContactListForItemInNamedAuthority(\r
String parentspecifier,\r
String itemcsid);\r
\r
* @param itemspecifier (shortIdentifier)\r
* @return the client response\r
*/\r
- public ClientResponse<ContactsCommonList> readContactListForNamedItemInNamedAuthority(\r
+ public ClientResponse<AbstractCommonList> readContactListForNamedItemInNamedAuthority(\r
String parentspecifier,\r
String itemspecifier);\r
\r
import javax.ws.rs.core.Response;\r
import org.jboss.resteasy.client.ClientResponse;\r
\r
-import org.collectionspace.services.contact.ContactsCommonList;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
\r
/*\r
* @return the client response\r
*/\r
@Override\r
- public ClientResponse<ContactsCommonList> readContactList(String parentcsid,\r
+ public ClientResponse<AbstractCommonList> readContactList(String parentcsid,\r
String itemcsid) {\r
return getProxy().readContactList(parentcsid, itemcsid);\r
}\r
* @return the client response\r
*/\r
@Override\r
- public ClientResponse<ContactsCommonList> readContactListForNamedItem(\r
+ public ClientResponse<AbstractCommonList> readContactListForNamedItem(\r
String parentcsid,\r
String itemspecifier){\r
return getProxy().readContactList(parentcsid, itemspecifier);\r
* @return the client response\r
*/\r
@Override\r
- public ClientResponse<ContactsCommonList> readContactListForItemInNamedAuthority(\r
+ public ClientResponse<AbstractCommonList> readContactListForItemInNamedAuthority(\r
String parentspecifier,\r
String itemcsid){\r
return getProxy().readContactList(parentspecifier, itemcsid);\r
* @return the client response\r
*/\r
@Override\r
- public ClientResponse<ContactsCommonList> readContactListForNamedItemInNamedAuthority(\r
+ public ClientResponse<AbstractCommonList> readContactListForNamedItemInNamedAuthority(\r
String parentspecifier,\r
String itemspecifier){\r
return getProxy().readContactList(parentspecifier, itemspecifier);\r
import javax.ws.rs.Produces;\r
import javax.ws.rs.core.Response;\r
\r
-import org.collectionspace.services.contact.ContactsCommonList;\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
import org.jboss.resteasy.client.ClientResponse;\r
\r
/*\r
@GET\r
@Produces({"application/xml"})\r
@Path("/{parentcsid}/items/{itemcsid}/contacts/")\r
- public ClientResponse<ContactsCommonList> readContactList(\r
+ public ClientResponse<AbstractCommonList> readContactList(\r
@PathParam("parentcsid") String parentcsid,\r
@PathParam("itemcsid") String itemcsid);\r
\r
@GET\r
@Produces({"application/xml"})\r
@Path("/{parentcsid}/items/urn:cspace:name({itemspecifier})/contacts/")\r
- ClientResponse<ContactsCommonList> readContactListForNamedItem(\r
+ ClientResponse<AbstractCommonList> readContactListForNamedItem(\r
@PathParam("parentcsid") String parentcsid,\r
@PathParam("itemspecifier") String itemspecifier);\r
\r
@GET\r
@Produces({"application/xml"})\r
@Path("/urn:cspace:name({parentspecifier})/items/{itemcsid}/contacts/")\r
- ClientResponse<ContactsCommonList> readContactListForItemInNamedAuthority(\r
+ ClientResponse<AbstractCommonList> readContactListForItemInNamedAuthority(\r
@PathParam("parentspecifier") String parentspecifier,\r
@PathParam("itemcsid") String itemcsid);\r
@GET\r
@Produces({"application/xml"})\r
@Path("/urn:cspace:name({parentspecifier})/items/urn:cspace:name({itemspecifier})/contacts/")\r
- ClientResponse<ContactsCommonList> readContactListForNamedItemInNamedAuthority(\r
+ ClientResponse<AbstractCommonList> readContactListForNamedItemInNamedAuthority(\r
@PathParam("parentspecifier") String parentspecifier,\r
@PathParam("itemspecifier") String itemspecifier);\r
\r
*/
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
-import org.collectionspace.services.contact.ContactsCommonList;
-
/**
* ContactClient.java
*
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-
-public class ContactClient extends AbstractPoxServiceClientImpl<ContactsCommonList, ContactProxy> {
- public static final String SERVICE_NAME = "contacts";
- public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
- public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
- public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
- public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+public class ContactClient extends AbstractCommonListPoxServiceClientImpl<ContactProxy> {
- @Override
- public String getServiceName() {
- return SERVICE_NAME;
- }
-
- @Override
- public String getServicePathComponent() {
- return SERVICE_PATH_COMPONENT;
- }
+ public static final String SERVICE_NAME = "contacts";
+ public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
+ public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+ public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
+ public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+
+ @Override
+ public String getServiceName() {
+ return SERVICE_NAME;
+ }
- @Override
- public Class<ContactProxy> getProxyClass() {
- return ContactProxy.class;
- }
+ @Override
+ public String getServicePathComponent() {
+ return SERVICE_PATH_COMPONENT;
+ }
- /*
- * Service calls
- */
-
- /**
- * @return
- * @see org.collectionspace.services.client.Contact#getContact()
- */
- public ClientResponse<ContactsCommonList> readList() {
- return getProxy().readList();
+ @Override
+ public Class<ContactProxy> getProxyClass() {
+ return ContactProxy.class;
}
}
package org.collectionspace.services.client;
+import java.util.List;
import javax.ws.rs.core.MediaType;
import org.collectionspace.services.client.ContactClient;
+import org.collectionspace.services.contact.AddressGroup;
+import org.collectionspace.services.contact.AddressGroupList;
import org.collectionspace.services.contact.ContactsCommon;
-//import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+import org.collectionspace.services.contact.EmailGroup;
+import org.collectionspace.services.contact.EmailGroupList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return createContactInstance(
inAuthority,
inItem,
+ "email-" + identifier,
"addressType-" + identifier,
"addressPlace-" + identifier,
- "emakl-" + identifier,
headerLabel);
}
return createContactInstance(
inAuthority,
inItem,
+ "email-" + identifier,
"addressType-" + identifier,
"addressPlace-" + identifier,
- "emakl-" + identifier,
headerLabel);
}
public static PoxPayloadOut createContactInstance(
- String inAuthority, String inItem, String addressType,
- String addressPlace, String email, String headerLabel) {
+ String inAuthority, String inItem, String email,
+ String addressType, String addressPlace, String headerLabel) {
ContactsCommon contact = new ContactsCommon();
+
contact.setInAuthority(inAuthority);
contact.setInItem(inItem);
- contact.setAddressType(addressType);
- contact.setAddressPlace(addressPlace);
- contact.setEmail(email);
+
+ EmailGroupList emailGroupList = new EmailGroupList();
+ List<EmailGroup> emailGroups = emailGroupList.getEmailGroup();
+ EmailGroup emailGroup = new EmailGroup();
+ emailGroup.setEmail(email);
+ emailGroups.add(emailGroup);
+ contact.setEmailGroupList(emailGroupList);
+
+ AddressGroupList addressGroupList = new AddressGroupList();
+ List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
+ AddressGroup addressGroup = new AddressGroup();
+ addressGroup.setAddressType(addressType);
+ addressGroup.setAddressPlace1(addressPlace);
+ addressGroups.add(addressGroup);
+ contact.setAddressGroupList(addressGroupList);
+
PoxPayloadOut multipart = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
@SuppressWarnings("deprecation")
PayloadOutputPart commonPart =
// ContactClient client = new ContactClient();
commonPart.setLabel(headerLabel);
- if(logger.isDebugEnabled()){
- logger.debug("to be created, contact common");
- // logger.debug(objectAsXmlString(contact, ContactsCommon.class));
- }
-
return multipart;
}
-
}
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright (c) 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ */
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.contact.ContactsCommonList;
/**
- * @version $Revision:$
+ * ContactProxy.java
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
*/
@Path(ContactClient.SERVICE_PATH_PROXY)
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public interface ContactProxy extends CollectionSpacePoxProxy<ContactsCommonList> {
- @GET
- ClientResponse<ContactsCommonList> readList();
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<ContactsCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<ContactsCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+public interface ContactProxy extends CollectionSpaceCommonListPoxProxy {
}
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
+import org.collectionspace.services.contact.AddressGroup;
+import org.collectionspace.services.contact.AddressGroupList;
import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
+import org.collectionspace.services.contact.EmailGroup;
+import org.collectionspace.services.contact.EmailGroupList;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
-//import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
public class ContactServiceTest extends AbstractServiceTestImpl {
+
private final String CLASS_NAME = ContactServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(ContactServiceTest.class);
-
// Instance variables specific to this test.
// final String SERVICE_PATH_COMPONENT = "contacts";
-
private String knownResourceId = null;
- @Override
- public String getServicePathComponent() {
- return ContactClient.SERVICE_PATH_COMPONENT;
- }
+ @Override
+ public String getServicePathComponent() {
+ return ContactClient.SERVICE_PATH_COMPONENT;
+ }
+
+ @Override
+ protected String getServiceName() {
+ return ContactClient.SERVICE_NAME;
+ }
- @Override
- protected String getServiceName() {
- return ContactClient.SERVICE_NAME;
- }
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
protected CollectionSpaceClient getClientInstance() {
- return new ContactClient();
+ return new ContactClient();
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(ContactsCommonList.class);
+ protected AbstractCommonList getAbstractCommonList(
+ ClientResponse<AbstractCommonList> response) {
+ return response.getEntity(AbstractCommonList.class);
}
// @Override
// ContactClientUtils.createContactInstance(identifier, client.getCommonPartName());
// return multipart;
// }
-
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
if (logger.isDebugEnabled()) {
ContactClient client = new ContactClient();
String identifier = createIdentifier();
PoxPayloadOut multipart =
- ContactClientUtils.createContactInstance(identifier, client.getCommonPartName());
+ ContactClientUtils.createContactInstance(identifier, client.getCommonPartName());
ClientResponse<Response> res = client.create(multipart);
int statusCode = res.getStatus();
// Specifically:
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// Store the ID returned from the first resource created
// for additional tests below.
- if (knownResourceId == null){
+ if (knownResourceId == null) {
knownResourceId = extractId(res);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
- for(int i = 0; i < 3; i++){
+ for (int i = 0; i < 3; i++) {
create(testName);
}
}
// See Issue CSPACE-401.
@Override
public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
@Override
public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty??
+ //Should this really be empty??
}
@Override
public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty??
+ //Should this really be empty??
}
/*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody(testName, logger);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("createWithEmptyEntityBody url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupCreateWithEmptyEntityBody(testName, logger);
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = "";
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithEmptyEntityBody url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupCreateWithMalformedXml();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = MALFORMED_XML_DATA; // Constant from base class.
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema(testName, logger);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupCreateWithWrongXmlSchema(testName, logger);
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = WRONG_XML_SCHEMA_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
*/
-
// ---------------------------------------------------------------
// CRUD tests : READ tests
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// Failure outcomes
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"read"})
public void readNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"read"})
public void readList(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
ContactClient client = new ContactClient();
- ClientResponse<ContactsCommonList> res = client.readList();
- ContactsCommonList list = res.getEntity();
+ ClientResponse<AbstractCommonList> res = client.readList();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = false;
- if(iterateThroughList && logger.isDebugEnabled()){
- List<ContactsCommonList.ContactListItem> items =
- list.getContactListItem();
- int i = 0;
- for(ContactsCommonList.ContactListItem item : items){
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(testName + ": list-item[" + i + "] objectNumber=" +
- item.getAddressPlace());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- i++;
- }
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"read"})
public void update(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
ContactClient client = new ContactClient();
ClientResponse<String> res = client.read(knownResourceId);
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": read status = " + res.getStatus());
}
Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
ContactsCommon contact = (ContactsCommon) extractPart(input,
client.getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(contact);
-
- // Update the content of this resource.
- contact.setAddressType("updated-" + contact.getAddressType());
- contact.setAddressPlace("updated-" + contact.getAddressPlace());
- contact.setEmail("updated-" + contact.getEmail());
+
if(logger.isDebugEnabled()){
+ logger.debug("contact common before updating");
+ logger.debug(BaseServiceTest.objectAsXmlString(contact, ContactsCommon.class));
+ }
+
+ // Verify the contents of this resource
+ EmailGroupList emailGroupList = contact.getEmailGroupList();
+ Assert.assertNotNull(emailGroupList);
+ List<EmailGroup> emailGroups = emailGroupList.getEmailGroup();
+ Assert.assertNotNull(emailGroups);
+ Assert.assertTrue(emailGroups.size() > 0);
+ String email = emailGroups.get(0).getEmail();
+ Assert.assertNotNull(email);
+
+ AddressGroupList addressGroupList = contact.getAddressGroupList();
+ Assert.assertNotNull(addressGroupList);
+ List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
+ Assert.assertNotNull(addressGroups);
+ Assert.assertTrue(addressGroups.size() > 0);
+ String addressType = addressGroups.get(0).getAddressType();
+ String addressPlace1 = addressGroups.get(0).getAddressPlace1();
+ Assert.assertNotNull(addressType);
+ Assert.assertNotNull(addressPlace1);
+
+ // Update the contents of this resource.
+ emailGroups.get(0).setEmail("updated-" + email);
+ contact.setEmailGroupList(emailGroupList);
+
+ addressGroups.get(0).setAddressType("updated-" + addressType);
+ addressGroups.get(0).setAddressPlace1("updated-" + addressPlace1);
+ contact.setAddressGroupList(addressGroupList);
+
+ if (logger.isDebugEnabled()) {
logger.debug("to be updated object");
- logger.debug(objectAsXmlString(contact, ContactsCommon.class));
+ logger.debug(BaseServiceTest.objectAsXmlString(contact, ContactsCommon.class));
}
+
// Submit the request to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
res = client.update(knownResourceId, output);
int statusCode = res.getStatus();
// Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
input = new PoxPayloadIn(res.getEntity());
ContactsCommon updatedContact =
(ContactsCommon) extractPart(input,
- client.getCommonPartName(), ContactsCommon.class);
+ client.getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(updatedContact);
-
- Assert.assertEquals(updatedContact.getEmail(),
- contact.getEmail(),
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("object after update");
+ logger.debug(objectAsXmlString(updatedContact, ContactsCommon.class));
+ }
+
+ Assert.assertNotNull(updatedContact.getEmailGroupList().getEmailGroup().get(0));
+ Assert.assertEquals(updatedContact.getEmailGroupList().getEmailGroup().get(0).getEmail(),
+ contact.getEmailGroupList().getEmailGroup().get(0).getEmail(),
"Data in updated object did not match submitted data.");
}
// See Issue CSPACE-401.
@Override
public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty??
+ //Should this really be empty??
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
*/
@Override
public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty??
+ //Should this really be empty??
}
@Override
public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty??
+ //Should this really be empty??
}
/*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
+ dependsOnMethods = {"create", "update", "testSubmitRequest"})
public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupUpdateWithEmptyEntityBody();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = "";
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
+ dependsOnMethods = {"create", "update", "testSubmitRequest"})
public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupUpdateWithMalformedXml();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = MALFORMED_XML_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
+ dependsOnMethods = {"create", "update", "testSubmitRequest"})
public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithWrongXmlSchema(testName, logger);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdateWithWrongXmlSchema(testName, logger);
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = WRONG_XML_SCHEMA_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
*/
-
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"update", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
public void delete(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// Failure outcomes
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testSubmitRequest: url=" + url +
- " status=" + statusCode);
+ if (logger.isDebugEnabled()) {
+ logger.debug("testSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
*
*/
public interface ContactJAXBSchema {
+
final static String CONTACTS_COMMON = "contacts_common";
final static String CSID = "csid";
- final static String IN_AUTHORITY = "inAuthority";
- final static String IN_ITEM ="inItem";
+ final static String IN_AUTHORITY = "inAuthority";
+ final static String IN_ITEM = "inItem";
+ final static String DISPLAY_NAME = "displayName";
+
+ final static String EMAIL_GROUP_LIST = "emailGroupList";
+ final static String EMAIL = "email";
+ final static String TELEPHONE_NUMBER_GROUP_LIST = "telephoneNumberGroupList";
+ final static String TELEPHONE_NUMBER = "telephoneNumber";
+ final static String FAX_NUMBER = "faxNumber";
+ final static String WEB = "web";
+ final static String ADDRESS_GROUP_LIST = "addressGroupList";
final static String ADDRESS_TYPE = "addressType";
- final static String ADDRESS_PLACE = "addressPlace";
- final static String WEB = "web";
- final static String EMAIL = "email";
- final static String TELEPHONE_NUMBER = "telephoneNumber";
- final static String FAX_NUMBER = "faxNumber";
+ final static String ADDRESS_PLACE_1 = "addressPlace1";
}
-
-
<xs:element name="csid" type="xs:string" />
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="inItem" type="xs:string" />
- <xs:element name="addressType" type="xs:string"/>
- <xs:element name="addressPlace" type="xs:string"/>
- <xs:element name="web" type="xs:string"/>
- <xs:element name="email" type="xs:string"/>
- <xs:element name="telephoneNumber" type="xs:string"/>
- <xs:element name="faxNumber" type="xs:string"/>
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="emailGroupList" type="emailGroupList"/>
+ <xs:element name="telephoneNumberGroupList" type="telephoneNumberGroupList"/>
+ <xs:element name="faxNumberGroupList" type="faxNumberGroupList"/>
+ <xs:element name="webAddressGroupList" type="webAddressGroupList"/>
+ <xs:element name="addressGroupList" type="addressGroupList"/>
</xs:sequence>
</xs:complexType>
</xs:element>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
+
+ <xs:complexType name="emailGroupList">
+ <xs:sequence>
+ <xs:element name="emailGroup" type="emailGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="emailGroup">
+ <xs:sequence>
+ <xs:element name="email" type="xs:string"/>
+ <xs:element name="emailType" type="xs:string"/>
+ </xs:sequence>
</xs:complexType>
- <!-- contact records, as in Nuxeo repository -->
- <xs:element name="contacts-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="contact-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="addressPlace" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrive contact details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
+ <xs:complexType name="telephoneNumberGroupList">
+ <xs:sequence>
+ <xs:element name="telephoneNumberGroup" type="telephoneNumberGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="telephoneNumberGroup">
+ <xs:sequence>
+ <xs:element name="telephoneNumber" type="xs:string"/>
+ <xs:element name="telephoneNumberType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="faxNumberGroupList">
+ <xs:sequence>
+ <xs:element name="faxNumberGroup" type="faxNumberGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="faxNumberGroup">
+ <xs:sequence>
+ <xs:element name="faxNumber" type="xs:string"/>
+ <xs:element name="faxNumberType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="webAddressGroupList">
+ <xs:sequence>
+ <xs:element name="webAddressGroup" type="webAddressGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="webAddressGroup">
+ <xs:sequence>
+ <xs:element name="webAddress" type="xs:string"/>
+ <xs:element name="webAddressType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="addressGroupList">
+ <xs:sequence>
+ <xs:element name="addressGroup" type="addressGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="addressGroup">
+ <xs:sequence>
+ <xs:element name="addressPlace1" type="xs:string"/>
+ <xs:element name="addressPlace2" type="xs:string"/>
+ <xs:element name="addressMunicipality" type="xs:string"/>
+ <xs:element name="addressStateOrProvince" type="xs:string"/>
+ <xs:element name="addressPostCode" type="xs:string"/>
+ <xs:element name="addressCountry" type="xs:string"/>
+ <xs:element name="addressType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
</xs:schema>
import org.collectionspace.services.common.document.DocumentHandler;
import org.collectionspace.services.contact.ContactResource;
import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.contact.ContactJAXBSchema;
import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
+import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.util.HttpResponseCodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Consumes("application/xml")
@Produces("application/xml")
public abstract class AuthorityResourceWithContacts<AuthCommon, AuthItemHandler> extends //FIXME: REM - Why is this resource in this package instead of somewhere in 'common'?
- AuthorityResource<AuthCommon, AuthItemHandler> {
+ AuthorityResource<AuthCommon, AuthItemHandler> {
private ContactResource contactResource = new ContactResource(); // Warning: ContactResource is a singleton.
-
final Logger logger = LoggerFactory.getLogger(AuthorityResourceWithContacts.class);
- public AuthorityResourceWithContacts(
- Class<AuthCommon> authCommonClass, Class<?> resourceClass,
- String authorityCommonSchemaName, String authorityItemCommonSchemaName) {
- super(authCommonClass, resourceClass,
- authorityCommonSchemaName, authorityItemCommonSchemaName);
- }
+ public AuthorityResourceWithContacts(
+ Class<AuthCommon> authCommonClass, Class<?> resourceClass,
+ String authorityCommonSchemaName, String authorityItemCommonSchemaName) {
+ super(authCommonClass, resourceClass,
+ authorityCommonSchemaName, authorityItemCommonSchemaName);
+ }
- public abstract String getItemServiceName();
+ public abstract String getItemServiceName();
public String getContactServiceName() {
return contactResource.getServiceName();
}
private DocumentHandler createContactDocumentHandler(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String inAuthority,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String inAuthority,
String inItem) throws Exception {
- ContactDocumentModelHandler docHandler = (ContactDocumentModelHandler)createDocumentHandler(
- ctx,
- ctx.getCommonPartLabel(getContactServiceName()),
- ContactsCommon.class);
+ ContactDocumentModelHandler docHandler = (ContactDocumentModelHandler) createDocumentHandler(
+ ctx,
+ ctx.getCommonPartLabel(getContactServiceName()),
+ ContactsCommon.class);
docHandler.setInAuthority(inAuthority);
docHandler.setInItem(inItem);
return docHandler;
/*************************************************************************
* Contact parts - this is a sub-resource of the AuthorityItem
- * @param parentspecifier either a CSID or one of the urn forms
- * @param itemspecifier either a CSID or one of the urn forms
+ * @param parentspecifier either a CSID or one of the urn forms
+ * @param itemspecifier either a CSID or one of the urn forms
* @return contact
*************************************************************************/
@POST
@PathParam("itemcsid") String itemspecifier,
String xmlPayload) {
try {
- PoxPayloadIn input = new PoxPayloadIn(xmlPayload);
+ PoxPayloadIn input = new PoxPayloadIn(xmlPayload);
String parentcsid = lookupParentCSID(parentspecifier, "createContact(authority)", "CREATE_ITEM_CONTACT", null);
ServiceContext itemCtx = createServiceContext(getItemServiceName());
// Note that we have to create the service context and document
// handler for the Contact service, not the main service.
- ServiceContext ctx = createServiceContext(getContactServiceName(), input);
+ ServiceContext ctx = createServiceContext(getContactServiceName(), input);
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
String csid = getRepositoryClient(ctx).create(ctx, handler);
UriBuilder path = UriBuilder.fromResource(resourceClass);
return response;
} catch (Exception e) {
throw bigReThrow(e,
- "Create Contact failed; one of the requested specifiers for authority:"
- +parentspecifier+": and item:"+itemspecifier+": was not found.",
- itemspecifier);
+ "Create Contact failed; one of the requested specifiers for authority:"
+ + parentspecifier + ": and item:" + itemspecifier + ": was not found.",
+ itemspecifier);
}
}
/**
* Gets the contact list.
*
- * @param parentspecifier either a CSID or one of the urn forms
- * @param itemspecifier either a CSID or one of the urn forms
+ * @param parentspecifier either a CSID or one of the urn forms
+ * @param itemspecifier either a CSID or one of the urn forms
* @param ui the ui
*
* @return the contact list
@GET
@Produces({"application/xml"})
@Path("{parentcsid}/items/{itemcsid}/contacts/")
- public ContactsCommonList getContactList(
+ public AbstractCommonList getContactList(
@PathParam("parentcsid") String parentspecifier,
@PathParam("itemcsid") String itemspecifier,
@Context UriInfo ui) {
- ContactsCommonList contactObjectList = new ContactsCommonList();
+ AbstractCommonList contactObjectList = new AbstractCommonList();
try {
String parentcsid = lookupParentCSID(parentspecifier, "getContactList(parent)", "GET_CONTACT_LIST", null);
String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getContactList(item)", "GET_CONTACT_LIST", itemCtx);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- ServiceContext ctx = createServiceContext(getContactServiceName(), queryParams);
+ ServiceContext ctx = createServiceContext(getContactServiceName(), queryParams);
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
DocumentFilter myFilter = handler.getDocumentFilter(); //new DocumentFilter();
- myFilter.appendWhereClause(ContactJAXBSchema.CONTACTS_COMMON + ":" +
- ContactJAXBSchema.IN_AUTHORITY +
- "='" + parentcsid + "'" +
- IQueryManager.SEARCH_QUALIFIER_AND +
- ContactJAXBSchema.CONTACTS_COMMON + ":" +
- ContactJAXBSchema.IN_ITEM +
- "='" + itemcsid + "'",
- IQueryManager.SEARCH_QUALIFIER_AND); // "AND" this clause to any existing
+ myFilter.appendWhereClause(ContactJAXBSchema.CONTACTS_COMMON + ":"
+ + ContactJAXBSchema.IN_AUTHORITY
+ + "='" + parentcsid + "'"
+ + IQueryManager.SEARCH_QUALIFIER_AND
+ + ContactJAXBSchema.CONTACTS_COMMON + ":"
+ + ContactJAXBSchema.IN_ITEM
+ + "='" + itemcsid + "'",
+ IQueryManager.SEARCH_QUALIFIER_AND); // "AND" this clause to any existing
getRepositoryClient(ctx).getFiltered(ctx, handler);
- contactObjectList = (ContactsCommonList) handler.getCommonPartList();
+ contactObjectList = (AbstractCommonList) handler.getCommonPartList();
} catch (Exception e) {
throw bigReThrow(e,
- "Get ContactList failed; one of the requested specifiers for authority:"
- +parentspecifier+": and item:"+itemspecifier+": was not found.",
- itemspecifier);
+ "Get ContactList failed; one of the requested specifiers for authority:"
+ + parentspecifier + ": and item:" + itemspecifier + ": was not found.",
+ itemspecifier);
}
return contactObjectList;
}
/**
* Gets the contact.
*
- * @param parentspecifier either a CSID or one of the urn forms
- * @param itemspecifier either a CSID or one of the urn forms
+ * @param parentspecifier either a CSID or one of the urn forms
+ * @param itemspecifier either a CSID or one of the urn forms
* @param csid the csid
*
* @return the contact
@PathParam("parentcsid") String parentspecifier,
@PathParam("itemcsid") String itemspecifier,
@PathParam("csid") String csid) {
- PoxPayloadOut result = null;
+ PoxPayloadOut result = null;
try {
String parentcsid = lookupParentCSID(parentspecifier, "getContact(parent)", "GET_ITEM_CONTACT", null);
String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getContact(item)", "GET_ITEM_CONTACT", itemCtx);
// Note that we have to create the service context and document handler for the Contact service, not the main service.
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getContactServiceName());
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getContactServiceName());
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = ctx.getOutput();
} catch (Exception e) {
- throw bigReThrow(e, "Get failed, the requested Contact CSID:" + csid +
- ": or one of the specifiers for authority:"+parentspecifier+
- ": and item:"+itemspecifier+": was not found.",
- csid);
+ throw bigReThrow(e, "Get failed, the requested Contact CSID:" + csid
+ + ": or one of the specifiers for authority:" + parentspecifier
+ + ": and item:" + itemspecifier + ": was not found.",
+ csid);
}
if (result == null) {
- Response response = Response.status(Response.Status.NOT_FOUND)
- .entity("Get failed, the requested Contact CSID:" + csid + ": was not found.")
- .type("text/plain").build();
+ Response response = Response.status(Response.Status.NOT_FOUND).entity("Get failed, the requested Contact CSID:" + csid + ": was not found.").type("text/plain").build();
throw new WebApplicationException(response);
}
return result.toXML();
/**
* Update contact.
*
- * @param parentspecifier either a CSID or one of the urn forms
- * @param itemspecifier either a CSID or one of the urn forms
+ * @param parentspecifier either a CSID or one of the urn forms
+ * @param itemspecifier either a CSID or one of the urn forms
* @param csid the csid
*
* @return the multipart output
@PathParam("itemcsid") String itemspecifier,
@PathParam("csid") String csid,
String xmlPayload) {
- PoxPayloadOut result = null;
+ PoxPayloadOut result = null;
try {
- PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload);
- String parentcsid = lookupParentCSID(parentspecifier, "updateContact(authority)", "UPDATE_CONTACT", null);
+ PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload);
+ String parentcsid = lookupParentCSID(parentspecifier, "updateContact(authority)", "UPDATE_CONTACT", null);
ServiceContext itemCtx = createServiceContext(getItemServiceName());
String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "updateContact(item)", "UPDATE_CONTACT", itemCtx);
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
// Note that we have to create the service context and document handler for the Contact service, not the main service.
- ctx = createServiceContext(getContactServiceName(), theUpdate);
+ ctx = createServiceContext(getContactServiceName(), theUpdate);
DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
getRepositoryClient(ctx).update(ctx, csid, handler);
result = ctx.getOutput();
} catch (Exception e) {
- throw bigReThrow(e, "Update failed, the requested Contact CSID:" + csid +
- ": or one of the specifiers for authority:"+parentspecifier+
- ": and item:"+itemspecifier+": was not found.",
- csid);
+ throw bigReThrow(e, "Update failed, the requested Contact CSID:" + csid
+ + ": or one of the specifiers for authority:" + parentspecifier
+ + ": and item:" + itemspecifier + ": was not found.",
+ csid);
}
return result.toXML();
}
/**
* Delete contact.
*
- * @param parentspecifier either a CSID or one of the urn forms
- * @param itemspecifier either a CSID or one of the urn forms
+ * @param parentspecifier either a CSID or one of the urn forms
+ * @param itemspecifier either a CSID or one of the urn forms
* @param csid the csid
*
* @return the response
@PathParam("itemcsid") String itemspecifier,
@PathParam("csid") String csid) {
try {
- String parentcsid = lookupParentCSID(parentspecifier, "deleteContact(authority)", "DELETE_CONTACT", null);
+ String parentcsid = lookupParentCSID(parentspecifier, "deleteContact(authority)", "DELETE_CONTACT", null);
ServiceContext itemCtx = createServiceContext(getItemServiceName());
String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "deleteContact(item)", "DELETE_CONTACT", itemCtx);
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
// Note that we have to create the service context for the Contact service, not the main service.
- ctx = createServiceContext(getContactServiceName());
+ ctx = createServiceContext(getContactServiceName());
getRepositoryClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
- } catch (Exception e) {
- throw bigReThrow(e, "DELETE failed, the requested Contact CSID:" + csid +
- ": or one of the specifiers for authority:"+parentspecifier+
- ": and item:"+itemspecifier+": was not found.", csid);
+ } catch (Exception e) {
+ throw bigReThrow(e, "DELETE failed, the requested Contact CSID:" + csid
+ + ": or one of the specifiers for authority:" + parentspecifier
+ + ": and item:" + itemspecifier + ": was not found.", csid);
}
}
-
}
*/
package org.collectionspace.services.contact.nuxeo;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import org.collectionspace.services.contact.ContactJAXBSchema;
-import org.collectionspace.services.common.document.DocumentHandler.Action;
import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
import org.collectionspace.services.common.service.ObjectPartType;
-import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
-import org.collectionspace.services.contact.ContactsCommonList.ContactListItem;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* The Class ContactDocumentModelHandler.
*/
public class ContactDocumentModelHandler
- extends RemoteDocumentModelHandlerImpl<ContactsCommon, ContactsCommonList> {
+ extends DocHandlerBase<ContactsCommon> {
- /** The logger. */
private final Logger logger = LoggerFactory.getLogger(ContactDocumentModelHandler.class);
-
- /** The contact. */
- private ContactsCommon contact;
-
- /** The contact list. */
- private ContactsCommonList contactList;
-
- /** The in authority. */
+ private static final String COMMON_PART_LABEL = "contacts_common";
private String inAuthority;
-
- /**
+ private String inItem;
+
+ /**
* Gets the in authority.
*
* @return the in authority
/**
* Sets the in authority.
*
- * @param inAuthority the new in authority
+ * @param inAuthority the new in item
*/
public void setInAuthority(String inAuthority) {
this.inAuthority = inAuthority;
}
- /** The in item. */
- private String inItem;
-
/**
* Gets the in item.
*
*/
@Override
public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- // first fill all the parts of the document
- super.handleCreate(wrapDoc);
- handleInAuthority(wrapDoc.getWrappedObject());
+ // first fill all the parts of the document
+ super.handleCreate(wrapDoc);
+ handleInAuthority(wrapDoc.getWrappedObject());
+ // handleDisplayNames(wrapDoc.getWrappedObject());
}
-
+
/**
* Check the logic around the parent pointer. Note that we only need do this on
* create, since we have logic to make this read-only on update.
* @throws Exception the exception
*/
private void handleInAuthority(DocumentModel docModel) throws Exception {
- String commonPartLabel = getServiceContext().getCommonPartLabel("contacts");
- docModel.setProperty(commonPartLabel,
- ContactJAXBSchema.IN_AUTHORITY, inAuthority);
- docModel.setProperty(commonPartLabel,
- ContactJAXBSchema.IN_ITEM, inItem);
+ String commonPartLabel = getServiceContext().getCommonPartLabel("contacts");
+ docModel.setProperty(commonPartLabel,
+ ContactJAXBSchema.IN_AUTHORITY, inAuthority);
+ docModel.setProperty(commonPartLabel,
+ ContactJAXBSchema.IN_ITEM, inItem);
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPart()
- */
- @Override
- public ContactsCommon getCommonPart() {
- return contact;
+ private void handleDisplayNames(DocumentModel docModel) throws Exception {
+ String commonPartLabel = getServiceContext().getCommonPartLabel("contacts");
+ String email = getStringValueInPrimaryRepeatingComplexProperty(
+ docModel, commonPartLabel, ContactJAXBSchema.EMAIL_GROUP_LIST,
+ ContactJAXBSchema.EMAIL);
+ String telephoneNumber = getStringValueInPrimaryRepeatingComplexProperty(
+ docModel, commonPartLabel, ContactJAXBSchema.TELEPHONE_NUMBER_GROUP_LIST,
+ ContactJAXBSchema.TELEPHONE_NUMBER);
+ String addressPlace1 = getStringValueInPrimaryRepeatingComplexProperty(
+ docModel, commonPartLabel, ContactJAXBSchema.ADDRESS_GROUP_LIST,
+ ContactJAXBSchema.ADDRESS_PLACE_1);
+ String displayName = prepareDefaultDisplayName(email, telephoneNumber, addressPlace1);
+ docModel.setProperty(commonPartLabel, ContactJAXBSchema.DISPLAY_NAME,
+ displayName);
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPart(java.lang.Object)
- */
- @Override
- public void setCommonPart(ContactsCommon contact) {
- this.contact = contact;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPartList()
- */
- @Override
- public ContactsCommonList getCommonPartList() {
- return contactList;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
- */
- @Override
- public void setCommonPartList(ContactsCommonList contactList) {
- this.contactList = contactList;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public ContactsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public void fillCommonPart(ContactsCommon contactObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
+ /**
+ * Produces a default displayName from the basic name and foundingPlace fields.
+ * @see OrgAuthorityClientUtils.prepareDefaultDisplayName() which
+ * duplicates this logic, until we define a service-general utils package
+ * that is neither client nor service specific.
+ * @param shortName
+ * @param foundingPlace
+ * @return
+ * @throws Exception
*/
- @Override
- public ContactsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- ContactsCommonList coList = extractPagingInfo(new ContactsCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("addressPlace|uri|csid");
- List<ContactsCommonList.ContactListItem> list = coList.getContactListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- ContactListItem clistItem = new ContactListItem();
- // TODO Revisit which information unit(s) should be returned
- // in each entry, in a list of contact information.
- // See CSPACE-1018
- clistItem.setAddressPlace((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- ContactJAXBSchema.ADDRESS_PLACE));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- clistItem.setUri(getServiceContextPath() + id);
- clistItem.setCsid(id);
- list.add(clistItem);
+ private static String prepareDefaultDisplayName(String email,
+ String telephoneNumber, String addressPlace1) throws Exception {
+
+ final int MAX_DISPLAY_NAME_LENGTH = 30;
+
+ StringBuilder newStr = new StringBuilder("");
+ final String sep = " ";
+ boolean firstAdded = false;
+
+ if (! email.isEmpty()) {
+ newStr.append(email);
+ firstAdded = true;
+ }
+
+ if (! telephoneNumber.isEmpty() && newStr.length() <= MAX_DISPLAY_NAME_LENGTH) {
+ if (firstAdded) {
+ newStr.append(sep);
+ } else {
+ firstAdded = true;
+ }
+ newStr.append(telephoneNumber);
+ }
+
+ if (! addressPlace1.isEmpty() && newStr.length() <= MAX_DISPLAY_NAME_LENGTH) {
+ if (firstAdded) {
+ newStr.append(sep);
+ }
+ newStr.append(addressPlace1);
+ }
+
+ if (newStr.length() > MAX_DISPLAY_NAME_LENGTH) {
+ return newStr.toString().substring(0, MAX_DISPLAY_NAME_LENGTH) + "...";
+ } else {
+ return newStr.toString();
}
-
- return coList;
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String)
- */
- @Override
- public String getQProperty(String prop) {
- return ContactConstants.NUXEO_SCHEMA_NAME + ":" + prop;
- }
-
/**
* Filters out ContactJAXBSchema.IN_AUTHORITY, and IN_ITEM, to ensure that
* the parent links remains untouched.
+ * Also remove the display name, as this is always computed.
* @param objectProps the properties parsed from the update payload
* @param partMeta metadata for the object to fill
*/
@Override
public void filterReadOnlyPropertiesForPart(
- Map<String, Object> objectProps, ObjectPartType partMeta) {
- super.filterReadOnlyPropertiesForPart(objectProps, partMeta);
- objectProps.remove(ContactJAXBSchema.IN_AUTHORITY);
- objectProps.remove(ContactJAXBSchema.IN_ITEM);
+ Map<String, Object> objectProps, ObjectPartType partMeta) {
+ super.filterReadOnlyPropertiesForPart(objectProps, partMeta);
+ objectProps.remove(ContactJAXBSchema.IN_AUTHORITY);
+ objectProps.remove(ContactJAXBSchema.IN_ITEM);
+ objectProps.remove(ContactJAXBSchema.DISPLAY_NAME);
}
-
}
-
import org.collectionspace.services.LocationJAXBSchema;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.ContactClient;
-import org.collectionspace.services.client.ContactClientUtils;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.AbstractCommonListUtils;
-import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.client.LocationAuthorityClient;
import org.collectionspace.services.client.LocationAuthorityClientUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.AbstractCommonListUtils;
+import org.collectionspace.services.contact.AddressGroup;
+import org.collectionspace.services.contact.AddressGroupList;
import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.client.OrgAuthorityClient;
import org.collectionspace.services.client.OrgAuthorityClientUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
private final String REFNAME = "refName";
private final String DISPLAYNAME = "displayName";
- @Override
- public String getServicePathComponent() {
- return OrgAuthorityClient.SERVICE_PATH_COMPONENT;
- }
+ @Override
+ public String getServicePathComponent() {
+ return OrgAuthorityClient.SERVICE_PATH_COMPONENT;
+ }
- @Override
- protected String getServiceName() {
- return OrgAuthorityClient.SERVICE_NAME;
- }
-
+ @Override
+ protected String getServiceName() {
+ return OrgAuthorityClient.SERVICE_NAME;
+ }
/** The test organization shortname. */
private final String TEST_ORG_SHORTNAME = "Test Org";
-
/** The test organization founding place. */
private final String TEST_ORG_FOUNDING_PLACE = "Anytown, USA";
-
// Hold some values for a recently created item to verify upon read.
private String knownResourceId = null;
private String knownResourceShortIdentifer = null;
private String knownResourceRefName = null;
private String knownItemResourceId = null;
private String knownItemResourceShortIdentifer = null;
-
/** The known contact resource id. */
private String knownContactResourceId = null;
-
/** The n items to create in list. */
private int nItemsToCreateInList = 3;
-
/** The all item resource ids created. */
private Map<String, String> allItemResourceIdsCreated =
- new HashMap<String, String>();
-
+ new HashMap<String, String>();
/** The all contact resource ids created. */
private Map<String, String> allContactResourceIdsCreated =
- new HashMap<String, String>();
-
- protected void setKnownResource( String id, String shortIdentifer,
- String refName ) {
- knownResourceId = id;
- knownResourceShortIdentifer = shortIdentifer;
- knownResourceRefName = refName;
+ new HashMap<String, String>();
+
+ protected void setKnownResource(String id, String shortIdentifer,
+ String refName) {
+ knownResourceId = id;
+ knownResourceShortIdentifer = shortIdentifer;
+ knownResourceRefName = refName;
}
- protected void setKnownItemResource( String id, String shortIdentifer ) {
- knownItemResourceId = id;
- knownItemResourceShortIdentifer = shortIdentifer;
+ protected void setKnownItemResource(String id, String shortIdentifer) {
+ knownItemResourceId = id;
+ knownItemResourceShortIdentifer = shortIdentifer;
}
/* (non-Javadoc)
*/
@Override
protected CollectionSpaceClient getClientInstance() {
- return new OrgAuthorityClient();
+ return new OrgAuthorityClient();
}
-
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"create"})
public void create(String testName) throws Exception {
if (logger.isDebugEnabled()) {
OrgAuthorityClient client = new OrgAuthorityClient();
String shortId = createIdentifier();
String displayName = "displayName-" + shortId;
- String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null);
- PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
- displayName, shortId, client.getCommonPartName());
-
- String newID = null;
- ClientResponse<Response> res = client.create(multipart);
+ String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null);
+ PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
+ displayName, shortId, client.getCommonPartName());
+
+ String newID = null;
+ ClientResponse<Response> res = client.create(multipart);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- newID = OrgAuthorityClientUtils.extractId(res);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ //
+ // Specifically:
+ // Does it fall within the set of valid status codes?
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ newID = OrgAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
// Store the ID returned from the first resource created
// for additional tests below.
- if (knownResourceId == null){
- setKnownResource( newID, shortId, baseRefName );
+ if (knownResourceId == null) {
+ setKnownResource(newID, shortId, baseRefName);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
@Override
protected PoxPayloadOut createInstance(String identifier) {
- OrgAuthorityClient client = new OrgAuthorityClient();
+ OrgAuthorityClient client = new OrgAuthorityClient();
String displayName = "displayName-" + identifier;
PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
displayName, identifier, client.getCommonPartName());
return multipart;
}
-
+
@Override
- protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
- String headerLabel = new OrgAuthorityClient().getItemCommonPartName();
+ protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
+ String headerLabel = new OrgAuthorityClient().getItemCommonPartName();
String shortId = "testOrg";
- Map<String, String> testOrgMap = new HashMap<String,String>();
+ Map<String, String> testOrgMap = new HashMap<String, String>();
testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, TEST_ORG_SHORTNAME);
testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization");
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "May 26, 1907");
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, TEST_ORG_FOUNDING_PLACE);
- return OrgAuthorityClientUtils.createOrganizationInstance(identifier, testOrgMap, headerLabel);
+ return OrgAuthorityClientUtils.createOrganizationInstance(identifier, testOrgMap, headerLabel);
}
-
+
/**
* Creates the item.
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"create"}, dependsOnMethods = {"create"})
public void createItem(String testName) {
setupCreate();
String newID = createItemInAuthority(knownResourceId, knownResourceRefName);
private String createItemInAuthority(String vcsid, String authRefName) {
final String testName = "createItemInAuthority";
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ":...");
}
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
String shortId = "testOrg";
- Map<String, String> testOrgMap = new HashMap<String,String>();
+ Map<String, String> testOrgMap = new HashMap<String, String>();
testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, TEST_ORG_SHORTNAME);
testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization");
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "May 26, 1907");
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, TEST_ORG_FOUNDING_PLACE);
-
- Map<String, List<String>> testOrgRepeatablesMap = new HashMap<String,List<String>>();
+
+ Map<String, List<String>> testOrgRepeatablesMap = new HashMap<String, List<String>>();
List<String> testOrgContactNames = new ArrayList<String>();
testOrgContactNames.add("joe@example.org");
testOrgContactNames.add("sally@example.org");
testOrgRepeatablesMap.put(OrganizationJAXBSchema.CONTACT_NAMES, testOrgContactNames);
-
+
MainBodyGroupList mainBodyList = new MainBodyGroupList();
List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
MainBodyGroup mainBodyGroup = new MainBodyGroup();
mainBodyGroups.add(mainBodyGroup);
String newID = OrgAuthorityClientUtils.createItemInAuthority(
- vcsid, authRefName, testOrgMap, testOrgRepeatablesMap, mainBodyList, client);
-
+ vcsid, authRefName, testOrgMap, testOrgRepeatablesMap, mainBodyList, client);
+
// Store the ID returned from the first item resource created
// for additional tests below.
- if (knownItemResourceId == null){
- setKnownItemResource(newID, shortId);
+ if (knownItemResourceId == null) {
+ setKnownItemResource(newID, shortId);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
}
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"createItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"create"}, dependsOnMethods = {"createItem"})
public void createContact(String testName) {
setupCreate();
String newID = createContactInItem(knownResourceId, knownItemResourceId);
}
- /**
- * Creates the contact in item.
- *
- * @param parentcsid the parentcsid
- * @param itemcsid the itemcsid
- * @return the string
- */
- private String createContactInItem(String parentcsid, String itemcsid) {
+ /**
+ * Creates the contact in item.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @return the string
+ */
+ private String createContactInItem(String parentcsid, String itemcsid) {
final String testName = "createContactInItem";
if (logger.isDebugEnabled()) {
OrgAuthorityClient client = new OrgAuthorityClient();
String identifier = createIdentifier();
PoxPayloadOut multipart =
- ContactClientUtils.createContactInstance(parentcsid,
- itemcsid, identifier, new ContactClient().getCommonPartName());
-
+ ContactClientUtils.createContactInstance(parentcsid,
+ itemcsid, identifier, new ContactClient().getCommonPartName());
+
String newID = null;
ClientResponse<Response> res =
- client.createContact(parentcsid, itemcsid, multipart);
+ client.createContact(parentcsid, itemcsid, multipart);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- newID = OrgAuthorityClientUtils.extractId(res);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ newID = OrgAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
// Store the ID returned from the first contact resource created
// for additional tests below.
- if (knownContactResourceId == null){
+ if (knownContactResourceId == null) {
knownContactResourceId = newID;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownContactResourceId=" + knownContactResourceId);
}
// Failure outcomes
-
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
/* (non-Javadoc)
*/
@Override
public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
-/*
+ /*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
+ groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()) {
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupCreateWithEmptyEntityBody();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = "";
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()) {
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
+ groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupCreateWithMalformedXml();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = MALFORMED_XML_DATA; // Constant from base class.
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
+ groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-*/
-
+ // Perform setup.
+ setupCreateWithWrongXmlSchema();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = WRONG_XML_SCHEMA_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+ */
// ---------------------------------------------------------------
// CRUD tests : CREATE LIST tests
// ---------------------------------------------------------------
// Success outcomes
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
-@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnGroups = {"create"})
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"createList"}, dependsOnGroups = {"create"})
public void createList(String testName) throws Exception {
for (int i = 0; i < nItemsToCreateInList; i++) {
create(testName);
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"createList"}, dependsOnMethods = {"createList"})
public void createItemList(String testName) throws Exception {
// Add items to the initially-created, known parent record.
for (int j = 0; j < nItemsToCreateInList; j++) {
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createItemList"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"createList"}, dependsOnMethods = {"createItemList"})
public void createContactList(String testName) throws Exception {
// Add contacts to the initially-created, known item record.
for (int j = 0; j < nItemsToCreateInList; j++) {
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnGroups = {"create"})
public void read(String testName) throws Exception {
- readInternal(testName, knownResourceId, null);
+ readInternal(testName, knownResourceId, null);
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
- public void readByName(String testName) throws Exception {
- readInternal(testName, null, knownResourceShortIdentifer);
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnGroups = {"create"})
+ public void readByName(String testName) throws Exception {
+ readInternal(testName, null, knownResourceShortIdentifer);
}
-
+
protected void readInternal(String testName, String CSID, String shortId) {
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res = null;
- if(CSID!=null) {
+ if (CSID != null) {
res = client.read(CSID);
- } else if(shortId!=null) {
- res = client.readByName(shortId);
+ } else if (shortId != null) {
+ res = client.readByName(shortId);
} else {
- Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
+ Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- //FIXME: remove the following try catch once Aron fixes signatures
- try {
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
- new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class);
- Assert.assertNotNull(orgAuthority);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ //FIXME: remove the following try catch once Aron fixes signatures
+ try {
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+ new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class);
+ if (logger.isDebugEnabled()) {
+ logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
+ }
+ Assert.assertNotNull(orgAuthority);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnGroups = {"read"})
public void readItem(String testName) throws Exception {
readItemInternal(testName, knownResourceId, null, knownItemResourceId, null);
}
* @param testName the test name
* @throws Exception the exception
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
+ groups = {"readItem"}, dependsOnGroups = {"read"})
public void readItemInNamedAuth(String testName) throws Exception {
- readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
+ readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
}
*/
-
/**
* Read named item.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnGroups = {"read"})
public void readNamedItem(String testName) throws Exception {
readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnGroups = {"read"})
public void readNamedItemInNamedAuth(String testName) throws Exception {
readItemInternal(testName, null, knownResourceShortIdentifer, null, knownItemResourceShortIdentifer);
}
- protected void readItemInternal(String testName,
- String authCSID, String authShortId, String itemCSID, String itemShortId)
- throws Exception {
+ protected void readItemInternal(String testName,
+ String authCSID, String authShortId, String itemCSID, String itemShortId)
+ throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res = null;
- if(authCSID!=null) {
- if(itemCSID!=null) {
+ if (authCSID != null) {
+ if (itemCSID != null) {
res = client.readItem(authCSID, itemCSID);
- } else if(itemShortId!=null) {
- res = client.readNamedItem(authCSID, itemShortId);
+ } else if (itemShortId != null) {
+ res = client.readNamedItem(authCSID, itemShortId);
} else {
- Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
+ Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
- } else if(authShortId!=null) {
- if(itemCSID!=null) {
+ } else if (authShortId != null) {
+ if (itemCSID != null) {
res = client.readItemInNamedAuthority(authShortId, itemCSID);
- } else if(itemShortId!=null) {
- res = client.readNamedItemInNamedAuthority(authShortId, itemShortId);
+ } else if (itemShortId != null) {
+ res = client.readNamedItemInNamedAuthority(authShortId, itemShortId);
} else {
- Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
+ Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
} else {
- Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
+ Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
}
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether we've received a organization.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(organization);
- boolean showFull = true;
- if(showFull && logger.isDebugEnabled()){
- logger.debug(testName + ": returned payload:");
- logger.debug(objectAsXmlString(organization, OrganizationsCommon.class));
- }
-
- // Check that the organization item is within the expected OrgAuthority.
- Assert.assertEquals(organization.getInAuthority(), knownResourceId);
-
- // Verify the number and contents of values in a repeatable field,
- // as created in the instance record used for testing.
- List<String> contactNames = organization.getContactNames().getContactName();
- Assert.assertTrue(contactNames.size() > 0);
- Assert.assertNotNull(contactNames.get(0));
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether we've received a organization.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+ client.getItemCommonPartName(), OrganizationsCommon.class);
+ Assert.assertNotNull(organization);
+ boolean showFull = true;
+ if (showFull && logger.isDebugEnabled()) {
+ logger.debug(testName + ": returned payload:");
+ logger.debug(objectAsXmlString(organization, OrganizationsCommon.class));
+ }
+
+ // Check that the organization item is within the expected OrgAuthority.
+ Assert.assertEquals(organization.getInAuthority(), knownResourceId);
+
+ // Verify the number and contents of values in a repeatable field,
+ // as created in the instance record used for testing.
+ List<String> contactNames = organization.getContactNames().getContactName();
+ Assert.assertTrue(contactNames.size() > 0);
+ Assert.assertNotNull(contactNames.get(0));
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"readItem", "updateItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"readItem", "updateItem"})
public void verifyItemDisplayName(String testName) throws Exception {
if (logger.isDebugEnabled()) {
PoxPayloadIn input = null;
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether organization has expected displayName.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether organization has expected displayName.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(organization);
String displayName = organization.getDisplayName();
// Make sure displayName matches computed form
- String expectedDisplayName =
- OrgAuthorityClientUtils.prepareDefaultDisplayName(
+ String expectedDisplayName =
+ OrgAuthorityClientUtils.prepareDefaultDisplayName(
TEST_ORG_SHORTNAME, TEST_ORG_FOUNDING_PLACE);
Assert.assertNotNull(displayName, expectedDisplayName);
-
+
// Update the shortName and verify the computed name is updated.
organization.setCsid(null);
organization.setDisplayNameComputed(true);
mainBodyGroups.add(mainBodyGroup);
organization.setMainBodyGroupList(mainBodyList);
- expectedDisplayName =
- OrgAuthorityClientUtils.prepareDefaultDisplayName(
- updatedShortName, TEST_ORG_FOUNDING_PLACE);
+ expectedDisplayName =
+ OrgAuthorityClientUtils.prepareDefaultDisplayName(
+ updatedShortName, TEST_ORG_FOUNDING_PLACE);
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
commonPart.setLabel(client.getItemCommonPartName());
res = client.updateItem(knownResourceId, knownItemResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
OrganizationsCommon updatedOrganization =
(OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
+ client.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(updatedOrganization);
// Verify that the updated resource received the correct data.
// Verify that the updated resource computes the right displayName.
Assert.assertEquals(updatedOrganization.getDisplayName(), expectedDisplayName,
- "Updated ShortName in Organization not reflected in computed DisplayName.");
+ "Updated ShortName in Organization not reflected in computed DisplayName.");
// Now Update the displayName, not computed and verify the computed name is overriden.
organization.setDisplayNameComputed(false);
commonPart.setLabel(client.getItemCommonPartName());
res = client.updateItem(knownResourceId, knownItemResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
updatedOrganization =
(OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
+ client.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(updatedOrganization);
// Verify that the updated resource received the correct data.
"Updated displayNameComputed in Organization did not match submitted data.");
// Verify that the updated resource computes the right displayName.
Assert.assertEquals(updatedOrganization.getDisplayName(),
- expectedDisplayName,
+ expectedDisplayName,
"Updated DisplayName (not computed) in Organization not stored.");
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"verifyItemDisplayName"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"verifyItemDisplayName"})
public void verifyIllegalItemDisplayName(String testName) throws Exception {
if (logger.isDebugEnabled()) {
}
// Perform setup.
testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
- // setupUpdateWithWrongXmlSchema(testName, logger);
+ // setupUpdateWithWrongXmlSchema(testName, logger);
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
-
- // Check whether organization has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(organization);
- // Try to Update with computed false and no displayName
- organization.setDisplayNameComputed(false);
- organization.setDisplayName(null);
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+
+ // Check whether organization has expected displayName.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+ client.getItemCommonPartName(), OrganizationsCommon.class);
+ Assert.assertNotNull(organization);
+ // Try to Update with computed false and no displayName
+ organization.setDisplayNameComputed(false);
+ organization.setDisplayName(null);
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(client.getItemCommonPartName());
+ res.releaseConnection();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readItem"})
public void readContact(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res =
- client.readContact(knownResourceId, knownItemResourceId,
- knownContactResourceId);
+ client.readContact(knownResourceId, knownItemResourceId,
+ knownContactResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether we've received a contact.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- ContactsCommon contact = (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(contact);
- boolean showFull = true;
- if(showFull && logger.isDebugEnabled()){
- logger.debug(testName + ": returned payload:");
- logger.debug(objectAsXmlString(contact, ContactsCommon.class));
- }
- Assert.assertEquals(contact.getInAuthority(), knownResourceId);
- Assert.assertEquals(contact.getInItem(), knownItemResourceId);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether we've received a contact.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ ContactsCommon contact = (ContactsCommon) extractPart(input,
+ new ContactClient().getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(contact);
+ boolean showFull = true;
+ if (showFull && logger.isDebugEnabled()) {
+ logger.debug(testName + ": returned payload:");
+ logger.debug(objectAsXmlString(contact, ContactsCommon.class));
+ }
+ Assert.assertEquals(contact.getInAuthority(), knownResourceId);
+ Assert.assertEquals(contact.getInItem(), knownItemResourceId);
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnMethods = {"read"})
public void readNonExistent(String testName) {
if (logger.isDebugEnabled()) {
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res = client.read(NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readItem"})
public void readItemNonExistent(String testName) {
if (logger.isDebugEnabled()) {
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readContact"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readContact"})
public void readContactNonExistent(String testName) {
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res =
- client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
+ client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnGroups = {"createList", "read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readList"}, dependsOnGroups = {"createList", "read"})
public void readList(String testName) throws Exception {
if (logger.isDebugEnabled()) {
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<AbstractCommonList> res = client.readList();
try {
- AbstractCommonList list = res.getEntity();
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- } finally {
- res.releaseConnection();
- }
+ AbstractCommonList list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Optionally output additional data about list members for debugging.
+ if (logger.isTraceEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ }
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<AbstractCommonList> res = null;
- if(vcsid!= null) {
- res = client.readItemList(vcsid, null, null);
- } else if(name!= null) {
- res = client.readItemListForNamedAuthority(name, null, null);
+ if (vcsid != null) {
+ res = client.readItemList(vcsid, null, null);
+ } else if (name != null) {
+ res = client.readItemListForNamedAuthority(name, null, null);
} else {
- Assert.fail("readItemList passed null csid and name!");
+ Assert.fail("readItemList passed null csid and name!");
}
try {
- AbstractCommonList list = res.getEntity();
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
- int nItemsReturned = items.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
- // all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": Expected "
- + nExpectedItems +" items; got: "+nItemsReturned);
- }
- Assert.assertEquals(nItemsReturned, nExpectedItems);
-
+ AbstractCommonList list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
+ int nItemsReturned = items.size();
+ // There will be one item created, associated with a
+ // known parent resource, by the createItem test.
+ //
+ // In addition, there will be 'nItemsToCreateInList'
+ // additional items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList + 1;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Expected "
+ + nExpectedItems + " items; got: " + nItemsReturned);
+ }
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
+
for (AbstractCommonList.ListItem item : items) {
- String value =
- AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
+ String value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
Assert.assertTrue((null != value), "Item refName is null!");
- value =
- AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
+ value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
Assert.assertTrue((null != value), "Item displayName is null!");
}
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ if (logger.isTraceEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
- } finally {
- res.releaseConnection();
- }
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
- ContactsCommonList list = null;
- ClientResponse<ContactsCommonList> res =
+ AbstractCommonList list = null;
+ ClientResponse<AbstractCommonList> res =
client.readContactList(parentcsid, itemcsid);
try {
- list = res.getEntity();
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- List<ContactsCommonList.ContactListItem> listitems =
- list.getContactListItem();
- int nItemsReturned = listitems.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
- // all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": Expected "
- + nExpectedItems +" items; got: "+nItemsReturned);
- }
- Assert.assertEquals(nItemsReturned, nExpectedItems);
-
- int i = 0;
- for (ContactsCommonList.ContactListItem listitem : listitems) {
- // Optionally output additional data about list members for debugging.
- boolean showDetails = false;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
- listitem.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
- listitem.getAddressPlace());
- logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
- listitem.getUri());
- }
- i++;
- }
- } finally {
- res.releaseConnection();
- }
+ list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ List<AbstractCommonList.ListItem> listitems =
+ list.getListItem();
+ int nItemsReturned = listitems.size();
+ // There will be one item created, associated with a
+ // known parent resource, by the createItem test.
+ //
+ // In addition, there will be 'nItemsToCreateInList'
+ // additional items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList + 1;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Expected "
+ + nExpectedItems + " items; got: " + nItemsReturned);
+ }
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
+
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = false;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ }
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
// None at present.
-
// ---------------------------------------------------------------
// CRUD tests : UPDATE tests
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnGroups = {"read", "readList"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnGroups = {"read", "readList"})
public void update(String testName) throws Exception {
if (logger.isDebugEnabled()) {
ClientResponse<String> res =
client.read(knownResourceId);
try {
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), OrgauthoritiesCommon.class);
- Assert.assertNotNull(orgAuthority);
-
- // Update the contents of this resource.
- orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
- orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated OrgAuthority");
- logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res.releaseConnection();
- res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- OrgauthoritiesCommon updatedOrgAuthority =
- (OrgauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), OrgauthoritiesCommon.class);
- Assert.assertNotNull(updatedOrgAuthority);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
- orgAuthority.getDisplayName(),
- "Data in updated object did not match submitted data.");
- } finally {
- res.releaseConnection();
- }
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
+ }
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), OrgauthoritiesCommon.class);
+ Assert.assertNotNull(orgAuthority);
+
+ // Update the contents of this resource.
+ orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
+ orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
+ if (logger.isDebugEnabled()) {
+ logger.debug("to be updated OrgAuthority");
+ logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(client.getCommonPartName());
+ res.releaseConnection();
+ res = client.update(knownResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
+ OrgauthoritiesCommon updatedOrgAuthority =
+ (OrgauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), OrgauthoritiesCommon.class);
+ Assert.assertNotNull(updatedOrgAuthority);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
+ orgAuthority.getDisplayName(),
+ "Data in updated object did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"update"})
public void updateItem(String testName) throws Exception {
if (logger.isDebugEnabled()) {
ClientResponse<String> res =
client.readItem(knownResourceId, knownItemResourceId);
try {
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got Organization to update with ID: " +
- knownItemResourceId +
- " in OrgAuthority: " + knownResourceId );
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(organization);
-
- // Update the contents of this resource.
- organization.setCsid(null);
-
- MainBodyGroupList mainBodyList = organization.getMainBodyGroupList();
- Assert.assertNotNull(mainBodyList);
- List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
- Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
- String updatedShortName = "updated-" + mainBodyGroups.get(0).getShortName();
- mainBodyGroups.get(0).setShortName(updatedShortName);
-
- if(logger.isDebugEnabled()){
- logger.debug("to be updated Organization");
- logger.debug(objectAsXmlString(organization,
- OrganizationsCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- OrganizationsCommon updatedOrganization =
- (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(updatedOrganization);
-
- // Verify that the updated resource received the correct data.
- mainBodyList = organization.getMainBodyGroupList();
- Assert.assertNotNull(mainBodyList);
- Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
- Assert.assertEquals(updatedOrganization.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
- updatedShortName, "Data in updated Organization did not match submitted data.");
- } finally {
- res.releaseConnection();
- }
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got Organization to update with ID: "
+ + knownItemResourceId
+ + " in OrgAuthority: " + knownResourceId);
+ }
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+ client.getItemCommonPartName(), OrganizationsCommon.class);
+ Assert.assertNotNull(organization);
+
+ // Update the contents of this resource.
+ organization.setCsid(null);
+
+ MainBodyGroupList mainBodyList = organization.getMainBodyGroupList();
+ Assert.assertNotNull(mainBodyList);
+ List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
+ Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
+ String updatedShortName = "updated-" + mainBodyGroups.get(0).getShortName();
+ mainBodyGroups.get(0).setShortName(updatedShortName);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("to be updated Organization");
+ logger.debug(objectAsXmlString(organization,
+ OrganizationsCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(client.getItemCommonPartName());
+ res.releaseConnection();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
+ OrganizationsCommon updatedOrganization =
+ (OrganizationsCommon) extractPart(input,
+ client.getItemCommonPartName(), OrganizationsCommon.class);
+ Assert.assertNotNull(updatedOrganization);
+
+ // Verify that the updated resource received the correct data.
+ mainBodyList = organization.getMainBodyGroupList();
+ Assert.assertNotNull(mainBodyList);
+ Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
+ Assert.assertEquals(updatedOrganization.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
+ updatedShortName, "Data in updated Organization did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"updateItem"})
public void updateContact(String testName) throws Exception {
if (logger.isDebugEnabled()) {
ClientResponse<String> res =
client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
try {
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got Contact to update with ID: " +
- knownContactResourceId +
- " in item: " + knownItemResourceId +
- " in parent: " + knownResourceId );
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- ContactsCommon contact = (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(contact);
-
- // Update the contents of this resource.
- contact.setAddressPlace("updated-" + contact.getAddressPlace());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated Contact");
- logger.debug(objectAsXmlString(contact,
- ContactsCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new ContactClient().getCommonPartName());
- res.releaseConnection();
- res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- ContactsCommon updatedContact =
- (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(updatedContact);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedContact.getAddressPlace(),
- contact.getAddressPlace(),
- "Data in updated Contact did not match submitted data.");
- } finally {
- res.releaseConnection();
- }
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got Contact to update with ID: "
+ + knownContactResourceId
+ + " in item: " + knownItemResourceId
+ + " in parent: " + knownResourceId);
+ }
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ ContactsCommon contact = (ContactsCommon) extractPart(input,
+ new ContactClient().getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(contact);
+
+ // Verify the contents of this resource
+ AddressGroupList addressGroupList = contact.getAddressGroupList();
+ Assert.assertNotNull(addressGroupList);
+ List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
+ Assert.assertNotNull(addressGroups);
+ Assert.assertTrue(addressGroups.size() > 0);
+ String addressPlace1 = addressGroups.get(0).getAddressPlace1();
+ Assert.assertNotNull(addressPlace1);
+
+ // Update the contents of this resource.
+ addressGroups.get(0).setAddressPlace1("updated-" + addressPlace1);
+ contact.setAddressGroupList(addressGroupList);
+ if (logger.isDebugEnabled()) {
+ logger.debug("to be updated Contact");
+ logger.debug(objectAsXmlString(contact,
+ ContactsCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(new ContactClient().getCommonPartName());
+ res.releaseConnection();
+ res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
+ ContactsCommon updatedContact =
+ (ContactsCommon) extractPart(input,
+ new ContactClient().getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(updatedContact);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedContact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
+ contact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
+ "Data in updated object did not match submitted data.");
+
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
*/
@Override
public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
-/*
+ /*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
+ groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupUpdateWithEmptyEntityBody();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = "";
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
+ groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- // Perform setup.
- setupUpdateWithWrongXmlSchema(testName, logger);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateWithWrongXmlSchema: url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdateWithMalformedXml();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = MALFORMED_XML_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+ groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
+ public void updateWithWrongXmlSchema(String testName) throws Exception {
+
+ // Perform setup.
+ setupUpdateWithWrongXmlSchema(testName, logger);
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = WRONG_XML_SCHEMA_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithWrongXmlSchema: url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
-*/
+ */
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
-@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Note: The ID used in this 'create' call may be arbitrary.
// The only relevant ID may be the one used in update(), below.
OrgAuthorityClient client = new OrgAuthorityClient();
- PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
- NON_EXISTENT_ID, NON_EXISTENT_ID,
- new OrgAuthorityClient().getCommonPartName());
+ PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
+ NON_EXISTENT_ID, NON_EXISTENT_ID,
+ new OrgAuthorityClient().getCommonPartName());
ClientResponse<String> res =
client.update(NON_EXISTENT_ID, multipart);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
public void updateNonExistentItem(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Note: The ID(s) used when creating the request payload may be arbitrary.
// The only relevant ID may be the one used in update(), below.
OrgAuthorityClient client = new OrgAuthorityClient();
- Map<String, String> nonexOrgMap = new HashMap<String,String>();
+ Map<String, String> nonexOrgMap = new HashMap<String, String>();
nonexOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, "nonExistent");
nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent");
- PoxPayloadOut multipart =
- OrgAuthorityClientUtils.createOrganizationInstance(
- knownResourceRefName,
- nonexOrgMap, client.getItemCommonPartName() );
+ PoxPayloadOut multipart =
+ OrgAuthorityClientUtils.createOrganizationInstance(
+ knownResourceRefName,
+ nonexOrgMap, client.getItemCommonPartName());
ClientResponse<String> res =
client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
public void updateNonExistentContact(String testName) throws Exception {
// Currently a no-op test
}
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
// Success outcomes
-
// Note: delete sub-resources in ascending hierarchical order,
// before deleting their parents.
-
/**
* Delete contact.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
public void deleteContact(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Perform setup.
setupDelete();
- if(logger.isDebugEnabled()){
- logger.debug("parentcsid =" + knownResourceId +
- " itemcsid = " + knownItemResourceId +
- " csid = " + knownContactResourceId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("parentcsid =" + knownResourceId
+ + " itemcsid = " + knownItemResourceId
+ + " csid = " + knownContactResourceId);
}
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res =
- client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
+ client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Delete item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteContact"})
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * Delete item.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteContact"})
public void deleteItem(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Perform setup.
setupDelete();
- if(logger.isDebugEnabled()){
- logger.debug("parentcsid =" + knownResourceId +
- " itemcsid = " + knownItemResourceId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("parentcsid =" + knownResourceId
+ + " itemcsid = " + knownItemResourceId);
}
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteItem"})
public void delete(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Perform setup.
setupDelete();
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("parentcsid =" + knownResourceId);
}
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res = client.delete(knownResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"delete"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteItem"})
public void deleteNonExistentItem(String testName) {
if (logger.isDebugEnabled()) {
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteContact"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteContact"})
public void deleteNonExistentContact(String testName) {
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res =
- client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
+ client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testSubmitRequest: url=" + url +
- " status=" + statusCode);
+ if (logger.isDebugEnabled()) {
+ logger.debug("testSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testItemSubmitRequest: url=" + url +
- " status=" + statusCode);
+ if (logger.isDebugEnabled()) {
+ logger.debug("testItemSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
String url = getContactResourceURL(knownResourceId,
- knownItemResourceId, knownContactResourceId);
+ knownItemResourceId, knownContactResourceId);
int statusCode = submitRequest(method, url);
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testItemSubmitRequest: url=" + url +
- " status=" + statusCode);
+ if (logger.isDebugEnabled()) {
+ logger.debug("testItemSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
}
-
// ---------------------------------------------------------------
// Cleanup of resources created during testing
// ---------------------------------------------------------------
-
/**
* Deletes all resources created by tests, after all tests have been run.
*
* at any point during testing, even if some of those resources
* may be expected to be deleted by certain tests.
*/
-
- @AfterClass(alwaysRun=true)
+ @AfterClass(alwaysRun = true)
@Override
public void cleanUp() {
String noTest = System.getProperty("noTestCleanup");
- if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+ if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
logger.debug("Skipping Cleanup phase ...");
}
return;
- }
+ }
if (logger.isDebugEnabled()) {
logger.debug("Cleaning up temporary resources created for testing ...");
}
-
+
String parentResourceId;
String itemResourceId;
String contactResourceId;
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
ClientResponse<Response> res =
- client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
+ client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
res.releaseConnection();
}
// Clean up item resources.
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
ClientResponse<Response> res =
- client.deleteItem(parentResourceId, itemResourceId);
+ client.deleteItem(parentResourceId, itemResourceId);
res.releaseConnection();
}
// Clean up parent resources.
super.cleanUp();
-
+
}
// ---------------------------------------------------------------
return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
}
-
/**
* Returns the root URL for the contact service.
*
* @return The root URL for the contact service.
*/
protected String getContactServiceRootURL(String parentResourceIdentifier,
- String itemResourceIdentifier) {
- return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/" +
- getContactServicePathComponent();
+ String itemResourceIdentifier) {
+ return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/"
+ + getContactServicePathComponent();
}
/**
* @return The URL of a specific resource managed by a service.
*/
protected String getContactResourceURL(String parentResourceIdentifier,
- String itemResourceIdentifier, String contactResourceIdentifier) {
+ String itemResourceIdentifier, String contactResourceIdentifier) {
return getContactServiceRootURL(parentResourceIdentifier,
- itemResourceIdentifier) + "/" + contactResourceIdentifier;
+ itemResourceIdentifier) + "/" + contactResourceIdentifier;
}
}
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.ContactClientUtils;
import org.collectionspace.services.common.AbstractCommonListUtils;
+import org.collectionspace.services.contact.AddressGroup;
+import org.collectionspace.services.contact.AddressGroupList;
import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.client.PersonAuthorityClient;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
+import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.PersonJAXBSchema;
import org.collectionspace.services.person.PersonauthoritiesCommon;
import org.collectionspace.services.person.PersonsCommon;
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
private final String REFNAME = "refName";
private final String DISPLAYNAME = "displayName";
-
- @Override
- public String getServicePathComponent() {
- return PersonAuthorityClient.SERVICE_PATH_COMPONENT;
- }
-
- @Override
- protected String getServiceName() {
- return PersonAuthorityClient.SERVICE_NAME;
- }
-
+
+ @Override
+ public String getServicePathComponent() {
+ return PersonAuthorityClient.SERVICE_PATH_COMPONENT;
+ }
+
+ @Override
+ protected String getServiceName() {
+ return PersonAuthorityClient.SERVICE_NAME;
+ }
+
public String getItemServicePathComponent() {
return AuthorityClient.ITEMS;
- }
-
+ }
/** The test forename. */
final String TEST_FORE_NAME = "John";
-
/** The test middle name. */
final String TEST_MIDDLE_NAME = null;
-
/** The test surname. */
final String TEST_SUR_NAME = "Wayne";
-
/** The test birthdate. */
final String TEST_BIRTH_DATE = "May 26, 1907";
-
/** The test death date. */
final String TEST_DEATH_DATE = "June 11, 1979";
-
// Hold some values for a recently created item to verify upon read.
private String knownResourceId = null;
private String knownResourceShortIdentifer = null;
private String knownResourceRefName = null;
private String knownItemResourceId = null;
private String knownItemResourceShortIdentifer = null;
-
// The resource ID of an item resource used for partial term matching tests.
private String knownItemPartialTermResourceId = null;
-
/** The known contact resource id. */
private String knownContactResourceId = null;
-
/** The n items to create in list. */
private int nItemsToCreateInList = 3;
-
/** The all item resource ids created. */
private Map<String, String> allItemResourceIdsCreated =
- new HashMap<String, String>();
-
+ new HashMap<String, String>();
/** The all contact resource ids created. */
private Map<String, String> allContactResourceIdsCreated =
- new HashMap<String, String>();
+ new HashMap<String, String>();
- protected void setKnownResource( String id, String shortIdentifer,
- String refName ) {
- knownResourceId = id;
- knownResourceShortIdentifer = shortIdentifer;
- knownResourceRefName = refName;
+ protected void setKnownResource(String id, String shortIdentifer,
+ String refName) {
+ knownResourceId = id;
+ knownResourceShortIdentifer = shortIdentifer;
+ knownResourceRefName = refName;
}
- protected void setKnownItemResource( String id, String shortIdentifer ) {
- knownItemResourceId = id;
- knownItemResourceShortIdentifer = shortIdentifer;
+ protected void setKnownItemResource(String id, String shortIdentifer) {
+ knownItemResourceId = id;
+ knownItemResourceShortIdentifer = shortIdentifer;
}
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
protected CollectionSpaceClient getClientInstance() {
- return new PersonAuthorityClient();
+ return new PersonAuthorityClient();
}
-
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"create"})
public void create(String testName) throws Exception {
-
+
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
}
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
String shortId = createIdentifier();
- String displayName = "displayName-" + shortId;
- String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null);
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonAuthorityInstance(
- displayName, shortId, client.getCommonPartName());
-
- String newID = null;
- ClientResponse<Response> res = client.create(multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
- newID = PersonAuthorityClientUtils.extractId(res);
- } finally {
- res.releaseConnection();
- }
+ String displayName = "displayName-" + shortId;
+ String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null);
+ PoxPayloadOut multipart =
+ PersonAuthorityClientUtils.createPersonAuthorityInstance(
+ displayName, shortId, client.getCommonPartName());
+
+ String newID = null;
+ ClientResponse<Response> res = client.create(multipart);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ //
+ // Specifically:
+ // Does it fall within the set of valid status codes?
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+
+ newID = PersonAuthorityClientUtils.extractId(res);
+ } finally {
+ res.releaseConnection();
+ }
// Save values for additional tests
- if (knownResourceId == null){
- setKnownResource( newID, shortId, baseRefName );
- if (logger.isDebugEnabled()) {
+ if (knownResourceId == null) {
+ setKnownResource(newID, shortId, baseRefName);
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
}
@Override
protected PoxPayloadOut createInstance(String identifier) {
- PersonAuthorityClient client = new PersonAuthorityClient();
+ PersonAuthorityClient client = new PersonAuthorityClient();
String displayName = "displayName-" + identifier;
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
displayName, identifier, client.getCommonPartName());
return multipart;
}
-
+
@Override
protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
- String headerLabel = new PersonAuthorityClient().getItemCommonPartName();
+ String headerLabel = new PersonAuthorityClient().getItemCommonPartName();
HashMap<String, String> personInfo = new HashMap<String, String>();
String shortId = "johnWayneTempActor";
personInfo.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
personInfo.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "JohnWayneTemp");
personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
- return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, headerLabel);
+ return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, headerLabel);
}
-
+
/**
* Creates the item.
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"create"}, dependsOnMethods = {"create"})
public void createItem(String testName) {
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
*
* @param testName the test name
*/
- /*
+ /*
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"create"})
+ groups = {"create"}, dependsOnMethods = {"create"})
public void createItemWithEmptyShortId(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- setupCreate();
-
- // Fill the property map
- String shortId = "";
- Map<String, String> fieldProperties = new HashMap<String,String>();
- fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
- fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME, "Rod Beck");
- fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
- fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "RodBeck");
-
- final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
- String newID = createItemInAuthority(knownResourceId, knownResourceRefName,
- shortId, fieldProperties, NULL_REPEATABLE_FIELD_PROPERTIES);
- allResourceIdsCreated.add(newID);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-*/
-
+ setupCreate();
+
+ // Fill the property map
+ String shortId = "";
+ Map<String, String> fieldProperties = new HashMap<String,String>();
+ fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
+ fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME, "Rod Beck");
+ fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
+ fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "RodBeck");
+
+ final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
+ String newID = createItemInAuthority(knownResourceId, knownResourceRefName,
+ shortId, fieldProperties, NULL_REPEATABLE_FIELD_PROPERTIES);
+ allResourceIdsCreated.add(newID);
+ }
+ */
/**
* Creates an item in an authority, using test data.
*
private String createItemInAuthority(String vcsid, String authRefName) {
final String testName = "createItemInAuthority";
- if(logger.isDebugEnabled()){
- logger.debug(testName + ":"+vcsid+"...");
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ":" + vcsid + "...");
}
- Map<String, String> johnWayneMap = new HashMap<String,String>();
+ Map<String, String> johnWayneMap = new HashMap<String, String>();
//
// Fill the property map
//
johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, TEST_BIRTH_DATE);
johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
johnWayneMap.put(PersonJAXBSchema.DEATH_DATE, TEST_DEATH_DATE);
- johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better" +
- "known by his stage name John Wayne, was an American film actor, director " +
- "and producer. He epitomized rugged masculinity and has become an enduring " +
- "American icon. He is famous for his distinctive voice, walk and height. " +
- "He was also known for his conservative political views and his support in " +
- "the 1950s for anti-communist positions.");
-
- Map<String, List<String>> johnWayneRepeatablesMap = new HashMap<String,List<String>>();
+ johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better"
+ + "known by his stage name John Wayne, was an American film actor, director "
+ + "and producer. He epitomized rugged masculinity and has become an enduring "
+ + "American icon. He is famous for his distinctive voice, walk and height. "
+ + "He was also known for his conservative political views and his support in "
+ + "the 1950s for anti-communist positions.");
+
+ Map<String, List<String>> johnWayneRepeatablesMap = new HashMap<String, List<String>>();
List<String> johnWayneGroups = new ArrayList<String>();
johnWayneGroups.add("Irish");
johnWayneGroups.add("Scottish");
Map itemFieldProperties, Map itemRepeatableFieldProperties) {
final String testName = "createItemInAuthority";
- if(logger.isDebugEnabled()){
- logger.debug(testName + ":"+vcsid+"...");
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ":" + vcsid + "...");
}
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
-
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonInstance(vcsid, authRefName, itemFieldProperties,
- itemRepeatableFieldProperties, client.getItemCommonPartName() );
+
+ PoxPayloadOut multipart =
+ PersonAuthorityClientUtils.createPersonInstance(vcsid, authRefName, itemFieldProperties,
+ itemRepeatableFieldProperties, client.getItemCommonPartName());
String newID = null;
ClientResponse<Response> res = client.createItem(vcsid, multipart);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- newID = PersonAuthorityClientUtils.extractId(res);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ newID = PersonAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
// Store the ID returned from the first item resource created
// for additional tests below.
- if (knownItemResourceId == null){
- setKnownItemResource(newID, shortId);
+ if (knownItemResourceId == null) {
+ setKnownItemResource(newID, shortId);
if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
+ logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
}
}
- if(logger.isDebugEnabled()){
- logger.debug(testName + " (created):"+vcsid+"/("+newID+","+shortId+")");
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + " (created):" + vcsid + "/(" + newID + "," + shortId + ")");
}
// Store the IDs from any item resources created
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"createItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"create"}, dependsOnMethods = {"createItem"})
public void createContact(String testName) {
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
String newID = createContactInItem(knownResourceId, knownItemResourceId);
}
- /**
- * Creates the contact in item.
- *
- * @param parentcsid the parentcsid
- * @param itemcsid the itemcsid
- * @return the string
- */
- private String createContactInItem(String parentcsid, String itemcsid) {
+ /**
+ * Creates the contact in item.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @return the string
+ */
+ private String createContactInItem(String parentcsid, String itemcsid) {
final String testName = "createContactInItem";
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ":...");
}
-
+
setupCreate();
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
String identifier = createIdentifier();
PoxPayloadOut multipart = ContactClientUtils.createContactInstance(parentcsid,
- itemcsid, identifier, new ContactClient().getCommonPartName());
-
+ itemcsid, identifier, new ContactClient().getCommonPartName());
+
String newID = null;
ClientResponse<Response> res =
- client.createContact(parentcsid, itemcsid, multipart);
+ client.createContact(parentcsid, itemcsid, multipart);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- newID = PersonAuthorityClientUtils.extractId(res);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ newID = PersonAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
// Store the ID returned from the first contact resource created
// for additional tests below.
- if (knownContactResourceId == null){
+ if (knownContactResourceId == null) {
knownContactResourceId = newID;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownContactResourceId=" + knownContactResourceId);
}
// Failure outcomes
-
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
/* (non-Javadoc)
*/
@Override
public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
-/*
+ /*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
+ groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()) {
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupCreateWithEmptyEntityBody();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = "";
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()) {
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
+ groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupCreateWithMalformedXml();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = MALFORMED_XML_DATA; // Constant from base class.
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
+ groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-*/
-
+ // Perform setup.
+ setupCreateWithWrongXmlSchema();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = WRONG_XML_SCHEMA_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+ */
/**
* Attempts to create an authority with an short identifier that contains
* non-word characters.
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create", "nonWordCharsInShortId"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"create", "nonWordCharsInShortId"})
public void createWithShortIdNonWordChars(String testName) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
// Create the payload to be included in the body of the request
PersonAuthorityClient client = new PersonAuthorityClient();
String shortId = createIdentifier() + "*" + createIdentifier();
- String displayName = "displayName-" + shortId;
+ String displayName = "displayName-" + shortId;
PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonAuthorityInstance(
- displayName, shortId, client.getCommonPartName());
+ PersonAuthorityClientUtils.createPersonAuthorityInstance(
+ displayName, shortId, client.getCommonPartName());
// Submit the request to the service and store the response.
- ClientResponse<Response> res = client.create(multipart);
+ ClientResponse<Response> res = client.create(multipart);
- // Check the status code of the response: does it match
- // the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
try {
int statusCode = res.getStatus();
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ } finally {
+ res.releaseConnection();
+ }
}
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create", "nonWordCharsInShortId"}, dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"create", "nonWordCharsInShortId"}, dependsOnMethods = {"create"})
public void createItemWithShortIdNonWordChars(String testName) {
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
REQUEST_TYPE = ServiceRequestType.CREATE;
testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
- PersonAuthorityClient client = new PersonAuthorityClient();
+ PersonAuthorityClient client = new PersonAuthorityClient();
// Create the payload to be included in the body of the request
String shortId = "7-Eleven";
- Map<String, String> fieldProperties = new HashMap<String,String>();
+ Map<String, String> fieldProperties = new HashMap<String, String>();
fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME, shortId);
fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
fieldProperties.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonInstance(knownResourceId,
+ PersonAuthorityClientUtils.createPersonInstance(knownResourceId,
knownResourceRefName, fieldProperties,
NULL_REPEATABLE_FIELD_PROPERTIES, client.getItemCommonPartName());
-
+
// Send the request and receive a response
ClientResponse<Response> res = client.createItem(knownResourceId, multipart);
// Check the status code of the response: does it match
- // the expected response(s)?
+ // the expected response(s)?
try {
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
// ---------------------------------------------------------------
// Success outcomes
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+ */
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnGroups = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"createList"}, dependsOnGroups = {"create"})
public void createList(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
+ if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
}
for (int i = 0; i < nItemsToCreateInList; i++) {
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"createList"}, dependsOnMethods = {"createList"})
public void createItemList(String testName) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createItemList"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"createList"}, dependsOnMethods = {"createItemList"})
public void createContactList(String testName) throws Exception {
// Add contacts to the initially-created, known item record.
for (int j = 0; j < nItemsToCreateInList; j++) {
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnGroups = {"create"})
public void read(String testName) throws Exception {
- readInternal(testName, knownResourceId, null);
+ readInternal(testName, knownResourceId, null);
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
- public void readByName(String testName) throws Exception {
- readInternal(testName, null, knownResourceShortIdentifer);
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnMethods = {"read"})
+ public void readByName(String testName) throws Exception {
+ readInternal(testName, null, knownResourceShortIdentifer);
}
-
+
protected void readInternal(String testName, String CSID, String shortId) {
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<String> res = null;
- if(CSID!=null) {
+ if (CSID != null) {
res = client.read(CSID);
- } else if(shortId!=null) {
- res = client.readByName(shortId);
+ } else if (shortId != null) {
+ res = client.readByName(shortId);
} else {
- Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
+ Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- //FIXME: remove the following try catch once Aron fixes signatures
- try {
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), PersonauthoritiesCommon.class);
- Assert.assertNotNull(personAuthority);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ //FIXME: remove the following try catch once Aron fixes signatures
+ try {
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), PersonauthoritiesCommon.class);
+ Assert.assertNotNull(personAuthority);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnGroups = {"read"})
public void readItem(String testName) throws Exception {
readItemInternal(testName, knownResourceId, null, knownItemResourceId, null);
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readItem"})
public void readItemInNamedAuth(String testName) throws Exception {
readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readItem"})
public void readNamedItem(String testName) throws Exception {
readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readItem"})
public void readNamedItemInNamedAuth(String testName) throws Exception {
readItemInternal(testName, null, knownResourceShortIdentifer, null, knownItemResourceShortIdentifer);
}
- protected void readItemInternal(String testName,
- String authCSID, String authShortId, String itemCSID, String itemShortId)
- throws Exception {
+ protected void readItemInternal(String testName,
+ String authCSID, String authShortId, String itemCSID, String itemShortId)
+ throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
- logger.debug("Reading:"+((authCSID!=null)?authCSID:authShortId)+"/"+
- ((itemCSID!=null)?authCSID:itemShortId));
+ logger.debug("Reading:" + ((authCSID != null) ? authCSID : authShortId) + "/"
+ + ((itemCSID != null) ? authCSID : itemShortId));
}
// Perform setup.
setupRead();
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<String> res = null;
- if(authCSID!=null) {
- if(itemCSID!=null) {
+ if (authCSID != null) {
+ if (itemCSID != null) {
res = client.readItem(authCSID, itemCSID);
- } else if(itemShortId!=null) {
- res = client.readNamedItem(authCSID, itemShortId);
+ } else if (itemShortId != null) {
+ res = client.readNamedItem(authCSID, itemShortId);
} else {
- Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
+ Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
- } else if(authShortId!=null) {
- if(itemCSID!=null) {
+ } else if (authShortId != null) {
+ if (itemCSID != null) {
res = client.readItemInNamedAuthority(authShortId, itemCSID);
- } else if(itemShortId!=null) {
- res = client.readNamedItemInNamedAuthority(authShortId, itemShortId);
+ } else if (itemShortId != null) {
+ res = client.readNamedItemInNamedAuthority(authShortId, itemShortId);
} else {
- Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
+ Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
} else {
- Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
+ Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
}
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether we've received a person.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PersonsCommon person = (PersonsCommon) extractPart(input,
- client.getItemCommonPartName(), PersonsCommon.class);
- Assert.assertNotNull(person);
- boolean showFull = true;
- if(showFull && logger.isDebugEnabled()){
- logger.debug(testName + ": returned payload:");
- logger.debug(objectAsXmlString(person, PersonsCommon.class));
- }
-
- // Check that the person item is within the expected Person Authority.
- Assert.assertEquals(person.getInAuthority(), knownResourceId);
-
- // Verify the number and contents of values in a repeatable field,
- // as created in the instance record used for testing.
- List<String> groups = person.getGroups().getGroup();
- Assert.assertTrue(groups.size() > 0);
- Assert.assertNotNull(groups.get(0));
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether we've received a person.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PersonsCommon person = (PersonsCommon) extractPart(input,
+ client.getItemCommonPartName(), PersonsCommon.class);
+ Assert.assertNotNull(person);
+ boolean showFull = true;
+ if (showFull && logger.isDebugEnabled()) {
+ logger.debug(testName + ": returned payload:");
+ logger.debug(objectAsXmlString(person, PersonsCommon.class));
+ }
+
+ // Check that the person item is within the expected Person Authority.
+ Assert.assertEquals(person.getInAuthority(), knownResourceId);
+
+ // Verify the number and contents of values in a repeatable field,
+ // as created in the instance record used for testing.
+ List<String> groups = person.getGroups().getGroup();
+ Assert.assertTrue(groups.size() > 0);
+ Assert.assertNotNull(groups.get(0));
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"updateItem"})
public void verifyItemDisplayNames(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
+
+ if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
}
// Perform setup.
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
- PoxPayloadIn input =null;
+ PoxPayloadIn input = null;
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether person has expected displayName.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether person has expected displayName.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
PersonsCommon person = (PersonsCommon) extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(person);
String displayName = person.getDisplayName();
// Make sure displayName matches computed form
- String expectedDisplayName =
- PersonAuthorityClientUtils.prepareDefaultDisplayName(
- TEST_FORE_NAME, null, TEST_SUR_NAME,
- TEST_BIRTH_DATE, TEST_DEATH_DATE);
+ String expectedDisplayName =
+ PersonAuthorityClientUtils.prepareDefaultDisplayName(
+ TEST_FORE_NAME, null, TEST_SUR_NAME,
+ TEST_BIRTH_DATE, TEST_DEATH_DATE);
Assert.assertFalse(displayName.equals(expectedDisplayName));
-
+
String shortDisplayName = person.getShortDisplayName();
// Make sure displayName matches computed form
- String expectedShortDisplayName =
- PersonAuthorityClientUtils.prepareDefaultDisplayName(
- TEST_FORE_NAME, null, TEST_SUR_NAME,null, null);
+ String expectedShortDisplayName =
+ PersonAuthorityClientUtils.prepareDefaultDisplayName(
+ TEST_FORE_NAME, null, TEST_SUR_NAME, null, null);
Assert.assertFalse(expectedShortDisplayName.equals(shortDisplayName));
-
+
// Update the forename and verify the computed name is updated.
person.setCsid(null);
person.setDisplayNameComputed(true);
person.setShortDisplayNameComputed(true);
person.setForeName("updated-" + TEST_FORE_NAME);
- expectedDisplayName =
- PersonAuthorityClientUtils.prepareDefaultDisplayName(
- "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME,
- TEST_BIRTH_DATE, TEST_DEATH_DATE);
- expectedShortDisplayName =
- PersonAuthorityClientUtils.prepareDefaultDisplayName(
- "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME,null, null);
+ expectedDisplayName =
+ PersonAuthorityClientUtils.prepareDefaultDisplayName(
+ "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME,
+ TEST_BIRTH_DATE, TEST_DEATH_DATE);
+ expectedShortDisplayName =
+ PersonAuthorityClientUtils.prepareDefaultDisplayName(
+ "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME, null, null);
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
commonPart.setLabel(client.getItemCommonPartName());
res = client.updateItem(knownResourceId, knownItemResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
PersonsCommon updatedPerson =
(PersonsCommon) extractPart(input,
- client.getItemCommonPartName(), PersonsCommon.class);
+ client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(updatedPerson);
// Verify that the updated resource received the correct data.
Assert.assertEquals(updatedPerson.getForeName(), person.getForeName(),
- "Updated ForeName in Person did not match submitted data.");
+ "Updated ForeName in Person did not match submitted data.");
// Verify that the updated resource computes the right displayName.
Assert.assertEquals(updatedPerson.getDisplayName(), expectedDisplayName,
- "Updated ForeName in Person not reflected in computed DisplayName.");
+ "Updated ForeName in Person not reflected in computed DisplayName.");
// Verify that the updated resource computes the right displayName.
Assert.assertEquals(updatedPerson.getShortDisplayName(), expectedShortDisplayName,
- "Updated ForeName in Person not reflected in computed ShortDisplayName.");
+ "Updated ForeName in Person not reflected in computed ShortDisplayName.");
// Now Update the displayName, not computed and verify the computed name is overriden.
person.setDisplayNameComputed(false);
commonPart.setLabel(client.getItemCommonPartName());
res = client.updateItem(knownResourceId, knownItemResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- } finally {
- res.releaseConnection();
- }
-
- updatedPerson =
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
+ } finally {
+ res.releaseConnection();
+ }
+
+ updatedPerson =
(PersonsCommon) extractPart(input,
- client.getItemCommonPartName(), PersonsCommon.class);
+ client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(updatedPerson);
// Verify that the updated resource received the correct data.
"Updated displayNameComputed in Person did not match submitted data.");
// Verify that the updated resource computes the right displayName.
Assert.assertEquals(updatedPerson.getDisplayName(),
- expectedDisplayName,
+ expectedDisplayName,
"Updated DisplayName (not computed) in Person not stored.");
// Verify that the updated resource received the correct data.
Assert.assertEquals(updatedPerson.isShortDisplayNameComputed(), false,
"Updated shortDisplayNameComputed in Person did not match submitted data.");
// Verify that the updated resource computes the right displayName.
Assert.assertEquals(updatedPerson.getShortDisplayName(),
- expectedDisplayName,
+ expectedDisplayName,
"Updated ShortDisplayName (not computed) in Person not stored.");
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"verifyItemDisplayNames"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"verifyItemDisplayNames"})
public void verifyIllegalItemDisplayName(String testName) throws Exception {
if (logger.isDebugEnabled()) {
}
// Perform setup.
testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
- // setupUpdateWithWrongXmlSchema(testName);
+ // setupUpdateWithWrongXmlSchema(testName);
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
-
- // Check whether Person has expected displayName.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+
+ // Check whether Person has expected displayName.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
PersonsCommon person = (PersonsCommon) extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(person);
commonPart.setLabel(client.getItemCommonPartName());
res = client.updateItem(knownResourceId, knownItemResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
-
+
/**
* Read contact.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readItem"})
public void readContact(String testName) throws Exception {
-
+
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
}
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
ClientResponse<String> res =
- client.readContact(knownResourceId, knownItemResourceId,
- knownContactResourceId);
+ client.readContact(knownResourceId, knownItemResourceId,
+ knownContactResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether we've received a contact.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether we've received a contact.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
ContactsCommon contact = (ContactsCommon) extractPart(input,
new ContactClient().getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(contact);
boolean showFull = true;
- if(showFull && logger.isDebugEnabled()){
+ if (showFull && logger.isDebugEnabled()) {
logger.debug(testName + ": returned payload:");
logger.debug(objectAsXmlString(contact, ContactsCommon.class));
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnMethods = {"read"})
public void readNonExistent(String testName) {
if (logger.isDebugEnabled()) {
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<String> res = client.read(NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readItem"})
public void readItemNonExistent(String testName) {
if (logger.isDebugEnabled()) {
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readContact"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readItem"}, dependsOnMethods = {"readContact"})
public void readContactNonExistent(String testName) {
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<String> res =
- client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
+ client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnGroups = {"createList", "read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readList"}, dependsOnGroups = {"createList", "read"})
public void readList(String testName) throws Exception {
if (logger.isDebugEnabled()) {
AbstractCommonList list = null;
ClientResponse<AbstractCommonList> res = client.readList();
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ list = res.getEntity();
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
// Optionally output additional data about list members for debugging.
// Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ if (logger.isTraceEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
/**
* Read item list.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnMethods = {"readList"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readList"}, dependsOnMethods = {"readList"})
public void readItemList(String testName) {
readItemList(knownResourceId, null, testName);
}
/**
* Read item list by authority name.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnMethods = {"readItemList"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"readList"}, dependsOnMethods = {"readItemList"})
public void readItemListByAuthorityName(String testName) {
readItemList(null, knownResourceShortIdentifer, testName);
}
-
+
/**
* Read item list.
*
// Perform setup.
setupReadList();
-
- // Submit the request to the service and store the response.
+
+ // Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<AbstractCommonList> res = null;
- if (vcsid!= null) {
- res = client.readItemList(vcsid, null, null);
- } else if (name!= null) {
- res = client.readItemListForNamedAuthority(name, null, null);
+ if (vcsid != null) {
+ res = client.readItemList(vcsid, null, null);
+ } else if (name != null) {
+ res = client.readItemListForNamedAuthority(name, null, null);
} else {
- Assert.fail("readItemList passed null csid and name!");
+ Assert.fail("readItemList passed null csid and name!");
}
AbstractCommonList list = null;
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ list = res.getEntity();
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
List<AbstractCommonList.ListItem> items =
- list.getListItem();
+ list.getListItem();
int nItemsReturned = items.size();
// There will be one item created, associated with a
// known parent resource, by the createItem test.
// additional items created by the createItemList test,
// all associated with the same parent resource.
int nExpectedItems = nItemsToCreateInList + 1;
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": Expected "
- + nExpectedItems +" items; got: "+nItemsReturned);
+ + nExpectedItems + " items; got: " + nItemsReturned);
}
Assert.assertEquals(nItemsReturned, nExpectedItems);
for (AbstractCommonList.ListItem item : items) {
- String value =
- AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
+ String value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
Assert.assertTrue((null != value), "Item refName is null!");
- value =
- AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
+ value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
Assert.assertTrue((null != value), "Item displayName is null!");
}
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ if (logger.isTraceEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
- ContactsCommonList list = null;
- ClientResponse<ContactsCommonList> res =
+ AbstractCommonList list = null;
+ ClientResponse<AbstractCommonList> res =
client.readContactList(parentcsid, itemcsid);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ list = res.getEntity();
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
- List<ContactsCommonList.ContactListItem> listitems =
- list.getContactListItem();
+
+ List<AbstractCommonList.ListItem> listitems =
+ list.getListItem();
int nItemsReturned = listitems.size();
// There will be one item created, associated with a
// known parent resource, by the createItem test.
// additional items created by the createItemList test,
// all associated with the same parent resource.
int nExpectedItems = nItemsToCreateInList + 1;
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": Expected "
- + nExpectedItems +" items; got: "+nItemsReturned);
+ + nExpectedItems + " items; got: " + nItemsReturned);
}
Assert.assertEquals(nItemsReturned, nExpectedItems);
-
- int i = 0;
- for (ContactsCommonList.ContactListItem listitem : listitems) {
- // Optionally output additional data about list members for debugging.
- boolean showDetails = false;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
- listitem.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
- listitem.getAddressPlace());
- logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
- listitem.getUri());
- }
- i++;
+
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = false;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
// Failure outcomes
-
// There are no failure outcome tests at present.
-
// ---------------------------------------------------------------
// CRUD tests : UPDATE tests
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnGroups = {"readItem", "readList"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnGroups = {"readItem", "readList"})
public void update(String testName) throws Exception {
if (logger.isDebugEnabled()) {
PoxPayloadIn input = null;
ClientResponse<String> res = client.read(knownResourceId);
try {
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
- }
- input = new PoxPayloadIn(res.getEntity());
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
+ }
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
client.getCommonPartName(), PersonauthoritiesCommon.class);
Assert.assertNotNull(personAuthority);
// Update the contents of this resource.
personAuthority.setDisplayName("updated-" + personAuthority.getDisplayName());
personAuthority.setVocabType("updated-" + personAuthority.getVocabType());
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("to be updated PersonAuthority");
logger.debug(objectAsXmlString(personAuthority, PersonauthoritiesCommon.class));
}
commonPart.setLabel(client.getCommonPartName());
res = client.update(knownResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
PersonauthoritiesCommon updatedPersonAuthority =
(PersonauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), PersonauthoritiesCommon.class);
+ client.getCommonPartName(), PersonauthoritiesCommon.class);
Assert.assertNotNull(updatedPersonAuthority);
// Verify that the updated resource received the correct data.
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"update"})
public void updateItem(String testName) throws Exception {
if (logger.isDebugEnabled()) {
ClientResponse<String> res =
client.readItem(knownResourceId, knownItemResourceId);
try {
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got Person to update with ID: " +
- knownItemResourceId +
- " in PersonAuthority: " + knownResourceId );
- }
- input = new PoxPayloadIn(res.getEntity());
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got Person to update with ID: "
+ + knownItemResourceId
+ + " in PersonAuthority: " + knownResourceId);
+ }
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
PersonsCommon person = (PersonsCommon) extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(person);
-
+
if (logger.isDebugEnabled() == true) {
- logger.debug("About to update the following person...");
- logger.debug(objectAsXmlString(person, PersonsCommon.class));
+ logger.debug("About to update the following person...");
+ logger.debug(objectAsXmlString(person, PersonsCommon.class));
}
// Update the contents of this resource.
person.setCsid(null);
person.setForeName("updated-" + person.getForeName());
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("to be updated Person");
logger.debug(objectAsXmlString(person,
- PersonsCommon.class));
- }
-
+ PersonsCommon.class));
+ }
+
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
commonPart.setLabel(client.getItemCommonPartName());
res = client.updateItem(knownResourceId, knownItemResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
PersonsCommon updatedPerson =
(PersonsCommon) extractPart(input,
- client.getItemCommonPartName(), PersonsCommon.class);
+ client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(updatedPerson);
-
+
if (logger.isDebugEnabled() == true) {
- logger.debug("Updated to following person to:");
- logger.debug(objectAsXmlString(updatedPerson, PersonsCommon.class));
- }
+ logger.debug("Updated to following person to:");
+ logger.debug(objectAsXmlString(updatedPerson, PersonsCommon.class));
+ }
// Verify that the updated resource received the correct data.
Assert.assertEquals(updatedPerson.getForeName(),
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"updateItem"})
public void updateContact(String testName) throws Exception {
-
+
if (logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
}
ClientResponse<String> res =
client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
try {
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got Contact to update with ID: " +
- knownContactResourceId +
- " in item: " + knownItemResourceId +
- " in parent: " + knownResourceId );
- }
- input = new PoxPayloadIn(res.getEntity());
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got Contact to update with ID: "
+ + knownContactResourceId
+ + " in item: " + knownItemResourceId
+ + " in parent: " + knownResourceId);
+ }
+ input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
-
+
ContactsCommon contact = (ContactsCommon) extractPart(input,
new ContactClient().getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(contact);
+ // Verify the contents of this resource
+ AddressGroupList addressGroupList = contact.getAddressGroupList();
+ Assert.assertNotNull(addressGroupList);
+ List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
+ Assert.assertNotNull(addressGroups);
+ Assert.assertTrue(addressGroups.size() > 0);
+ String addressPlace1 = addressGroups.get(0).getAddressPlace1();
+ Assert.assertNotNull(addressPlace1);
+
// Update the contents of this resource.
- contact.setAddressPlace("updated-" + contact.getAddressPlace());
- if(logger.isDebugEnabled()){
+ addressGroups.get(0).setAddressPlace1("updated-" + addressPlace1);
+ contact.setAddressGroupList(addressGroupList);
+ if (logger.isDebugEnabled()) {
logger.debug("to be updated Contact");
logger.debug(objectAsXmlString(contact,
- ContactsCommon.class));
+ ContactsCommon.class));
}
// Submit the updated resource to the service and store the response.
commonPart.setLabel(client.getCommonPartName());
res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());;
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = new PoxPayloadIn(res.getEntity());;
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
ContactsCommon updatedContact =
(ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
+ new ContactClient().getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(updatedContact);
// Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedContact.getAddressPlace(),
- contact.getAddressPlace(),
- "Data in updated Contact did not match submitted data.");
+ Assert.assertEquals(updatedContact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
+ contact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
+ "Data in updated object did not match submitted data.");
}
// Failure outcomes
*/
@Override
public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
-/* //FIXME: REM - Can we kill all this dead code please?
+ /* //FIXME: REM - Can we kill all this dead code please?
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
+ groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody(testName, logger);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupUpdateWithEmptyEntityBody(testName, logger);
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = "";
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
+ groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupUpdateWithMalformedXml();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = MALFORMED_XML_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
+ groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateWithWrongXmlSchema: url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-*/
+ // Perform setup.
+ setupUpdateWithWrongXmlSchema();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = WRONG_XML_SCHEMA_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithWrongXmlSchema: url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+ */
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
-@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// The only relevant ID may be the one used in update(), below.
PersonAuthorityClient client = new PersonAuthorityClient();
String displayName = "displayName-NON_EXISTENT_ID";
- PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
- displayName, "NON_EXISTENT_SHORT_ID", client.getCommonPartName());
+ PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
+ displayName, "NON_EXISTENT_SHORT_ID", client.getCommonPartName());
ClientResponse<String> res =
client.update(NON_EXISTENT_ID, multipart);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
public void updateNonExistentItem(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Note: The ID used in this 'create' call may be arbitrary.
// The only relevant ID may be the one used in update(), below.
PersonAuthorityClient client = new PersonAuthorityClient();
- Map<String, String> nonexMap = new HashMap<String,String>();
+ Map<String, String> nonexMap = new HashMap<String, String>();
nonexMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, "nonEX");
nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
nonexMap.put(PersonJAXBSchema.GENDER, "male");
Map<String, List<String>> nonexRepeatablesMap = new HashMap<String, List<String>>();
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
- PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
- nonexMap, nonexRepeatablesMap, client.getItemCommonPartName() );
+ PoxPayloadOut multipart =
+ PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
+ PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
+ nonexMap, nonexRepeatablesMap, client.getItemCommonPartName());
ClientResponse<String> res =
client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
} finally {
- res.releaseConnection();
+ res.releaseConnection();
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
public void updateNonExistentContact(String testName) throws Exception {
// Currently a no-op test
}
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
// Success outcomes
-
// Note: delete sub-resources in ascending hierarchical order,
// before deleting their parents.
-
/**
* Delete contact.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnGroups = {"update"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnGroups = {"update"})
public void deleteContact(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Perform setup.
setupDelete();
- if(logger.isDebugEnabled()){
- logger.debug("parentcsid =" + knownResourceId +
- " itemcsid = " + knownItemResourceId +
- " csid = " + knownContactResourceId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("parentcsid =" + knownResourceId
+ + " itemcsid = " + knownItemResourceId
+ + " csid = " + knownContactResourceId);
}
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res =
- client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
+ client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Delete item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteContact"})
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * Delete item.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteContact"})
public void deleteItem(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Perform setup.
setupDelete();
- if(logger.isDebugEnabled()){
- logger.debug("parentcsid =" + knownResourceId +
- " itemcsid = " + knownItemResourceId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("parentcsid =" + knownResourceId
+ + " itemcsid = " + knownItemResourceId);
}
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteItem"})
public void delete(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Perform setup.
setupDelete();
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("parentcsid =" + knownResourceId);
}
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res = client.delete(knownResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"delete"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteItem"})
public void deleteNonExistentItem(String testName) {
if (logger.isDebugEnabled()) {
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
*
* @param testName the test name
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteContact"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteContact"})
public void deleteNonExistentContact(String testName) {
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res =
- client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
+ client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testSubmitRequest: url=" + url +
- " status=" + statusCode);
+ if (logger.isDebugEnabled()) {
+ logger.debug("testSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testItemSubmitRequest: url=" + url +
- " status=" + statusCode);
+ if (logger.isDebugEnabled()) {
+ logger.debug("testItemSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
String url = getContactResourceURL(knownResourceId,
- knownItemResourceId, knownContactResourceId);
+ knownItemResourceId, knownContactResourceId);
int statusCode = submitRequest(method, url);
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testItemSubmitRequest: url=" + url +
- " status=" + statusCode);
+ if (logger.isDebugEnabled()) {
+ logger.debug("testItemSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
}
-
// ---------------------------------------------------------------
// Cleanup of resources created during testing
// ---------------------------------------------------------------
-
/**
* Deletes all resources created by tests, after all tests have been run.
*
* at any point during testing, even if some of those resources
* may be expected to be deleted by certain tests.
*/
-
- @AfterClass(alwaysRun=true)
+ @AfterClass(alwaysRun = true)
@Override
public void cleanUp() {
String noTest = System.getProperty("noTestCleanup");
- if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+ if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
logger.debug("Skipping Cleanup phase ...");
}
return;
- }
+ }
if (logger.isDebugEnabled()) {
logger.debug("Cleaning up temporary resources created for testing ...");
}
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
ClientResponse<Response> res =
- client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
+ client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
res.releaseConnection();
}
// Clean up item resources.
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
ClientResponse<Response> res =
- client.deleteItem(parentResourceId, itemResourceId);
+ client.deleteItem(parentResourceId, itemResourceId);
res.releaseConnection();
}
// Clean up parent resources.
public String getContactServicePathComponent() {
return ContactClient.SERVICE_PATH_COMPONENT;
}
-
+
/**
* Returns the root URL for the item service.
*
return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
}
-
/**
* Returns the root URL for the contact service.
*
* @return The root URL for the contact service.
*/
protected String getContactServiceRootURL(String parentResourceIdentifier,
- String itemResourceIdentifier) {
- return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/" +
- getContactServicePathComponent();
+ String itemResourceIdentifier) {
+ return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/"
+ + getContactServicePathComponent();
}
/**
* @return The URL of a specific resource managed by a service.
*/
protected String getContactResourceURL(String parentResourceIdentifier,
- String itemResourceIdentifier, String contactResourceIdentifier) {
+ String itemResourceIdentifier, String contactResourceIdentifier) {
return getContactServiceRootURL(parentResourceIdentifier,
- itemResourceIdentifier) + "/" + contactResourceIdentifier;
+ itemResourceIdentifier) + "/" + contactResourceIdentifier;
}
}