<entryNumber>CompleteIntake001</entryNumber>
<normalLocation>urn:cspace:core.collectionspace.org:locationauthorities:name(location):item:name(MOMA1321979112557)'MOMA'</normalLocation>
<insurancePolicyNumber>BH-90210</insurancePolicyNumber>
- <depositorsRequirements>Must wear suit and tie</depositorsRequirements>
<entryReason>commission</entryReason>
<insuranceReferenceNumber>1234-5678-90</insuranceReferenceNumber>
<returnDate>2010-07-14T04:00:00Z</returnDate>
</conditionCheckersOrAssessors>
<entryDate>2010-07-16T04:00:00Z</entryDate>
<insuranceRenewalDate>2010-07-05T04:00:00Z</insuranceRenewalDate>
- <currentOwner>urn:cspace:org.collectionspace.demo:personauthority:name(person):person:name(seanbean)'Sean+Bean'</currentOwner>
+ <currentOwners>
+ <currentOwner>urn:cspace:org.collectionspace.demo:personauthority:name(person):person:name(seanbean)'Sean+Bean'</currentOwner>
+ </currentOwners>
<locationDate>2009-07-15T04:00:00Z</locationDate>
- <depositor>urn:cspace:org.collectionspace.demo:personauthority:name(person):person:name(tommyjones)'Tommy+Jones'</depositor>
+ <depositorGroupList>
+ <depositorGroup>
+ <depositor>urn:cspace:org.collectionspace.demo:personauthority:name(person):person:name(tommyjones)'Tommy+Jones'</depositor>
+ <depositorsRequirements>Must wear suit and tie</depositorsRequirements>
+ </depositorGroup>
+ </depositorGroupList>
</ns2:intakes_common>
</document>
import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.intake.ConditionCheckerOrAssessorList;
+import org.collectionspace.services.intake.CurrentOwnerList;
+import org.collectionspace.services.intake.DepositorGroup;
+import org.collectionspace.services.intake.DepositorGroupList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.intake.InsurerList;
import org.collectionspace.services.jaxb.AbstractCommonList;
private String knownResourceId = null;
private List<String> intakeIdsCreated = new ArrayList<String>();
private List<String> personIdsCreated = new ArrayList<String>();
- private String personAuthCSID = null;
+ private String personAuthCSID = null;
private String currentOwnerRefName = null;
private String depositorRefName = null;
private String conditionCheckerOrAssessorRefName = null;
protected String getServiceName() {
throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
// Submit the request to the service and store the response.
String identifier = createIdentifier();
-
+
// Create all the person refs and entities
createPersonRefs();
-
+
// Submit the request to the service and store the response.
IntakeClient intakeClient = new IntakeClient();
PoxPayloadOut multipart = createIntakeInstance(
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
}
-
+
// Store the IDs from every resource created by tests,
// so they can be deleted after tests have been run.
intakeIdsCreated.add(newId);
}
-
+
protected void createPersonRefs() throws Exception {
//
// First, create a new person authority
} finally {
res.close();
}
-
+
String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
String csid = createPerson("Olivier", "Owner", "olivierOwner", authRefName);
currentOwnerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
personIdsCreated.add(csid);
-
+
csid = createPerson("Debbie", "Depositor", "debbieDepositor", authRefName);
depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
personIdsCreated.add(csid);
-
+
csid = createPerson("Andrew", "Assessor", "andrewAssessor", authRefName);
conditionCheckerOrAssessorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
personIdsCreated.add(csid);
-
+
csid = createPerson("Ingrid", "Insurer", "ingridInsurer", authRefName);
insurerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
personIdsCreated.add(csid);
-
+
csid = createPerson("Vince", "Valuer", "vinceValuer", authRefName);
valuerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
personIdsCreated.add(csid);
}
-
+
protected String createPerson(String firstName, String surName, String shortId, String authRefName ) throws Exception {
String result = null;
-
+
PersonClient personAuthClient = new PersonClient();
Map<String, String> personInfo = new HashMap<String,String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
term.setTermDisplayName(termName);
term.setTermName(termName);
personTerms.add(term);
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
+ PoxPayloadOut multipart =
+ PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
authRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
-
+
Response res = personAuthClient.createItem(personAuthCSID, multipart);
try {
int statusCode = res.getStatus();
} finally {
res.close();
}
-
+
return result;
}
IntakesCommon intake = (IntakesCommon) extractPart(input, intakeClient.getCommonPartName(), IntakesCommon.class);
Assert.assertNotNull(intake);
// Check a couple of fields
- Assert.assertEquals(intake.getCurrentOwner(), currentOwnerRefName);
+ Assert.assertEquals(intake.getCurrentOwners().getCurrentOwner().get(0), currentOwnerRefName);
Assert.assertEquals(intake.getConditionCheckersOrAssessors().getConditionCheckerOrAssessor().get(0), conditionCheckerOrAssessorRefName);
Assert.assertEquals(intake.getInsurers().getInsurer().get(0), insurerRefName);
} finally {
res.close();
}
}
-
+
// Get the auth refs and check them
res = intakeClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
res.close();
}
}
-
+
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
if (logger.isDebugEnabled()) {
* For this reason, it attempts to remove all resources created
* at any point during testing, even if some of those resources
* may be expected to be deleted by certain tests.
- * @throws Exception
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
public void cleanUp() throws Exception {
}
private PoxPayloadOut createIntakeInstance(String entryNumber,
- String entryDate,
- String currentOwner,
- String depositor,
- String conditionCheckerAssessor,
- String insurer,
- String Valuer ) throws Exception {
+ String entryDate,
+ String currentOwner,
+ String depositor,
+ String conditionCheckerAssessor,
+ String insurer,
+ String Valuer ) throws Exception {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
- intake.setCurrentOwner(currentOwner);
- intake.setDepositor(depositor);
+
+ CurrentOwnerList currentOwnerList = new CurrentOwnerList();
+ List<String> currentOwners = currentOwnerList.getCurrentOwner();
+
+ currentOwners.add(currentOwner);
+ intake.setCurrentOwners(currentOwnerList);
+
+ DepositorGroupList depositorGroupList = new DepositorGroupList();
+ List<DepositorGroup> depositorGroups = depositorGroupList.getDepositorGroup();
+ DepositorGroup depositorGroup = new DepositorGroup();
+
+ depositorGroup.setDepositor(depositor);
+ depositorGroups.add(depositorGroup);
+
+ intake.setDepositorGroupList(depositorGroupList);
intake.setValuer(Valuer);
ConditionCheckerOrAssessorList checkerOrAssessorList = new ConditionCheckerOrAssessorList();
import org.collectionspace.services.intake.FieldCollectionEventNameList;
import org.collectionspace.services.intake.CurrentLocationGroup;
import org.collectionspace.services.intake.CurrentLocationGroupList;
+import org.collectionspace.services.intake.DepositorGroup;
+import org.collectionspace.services.intake.DepositorGroupList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.testng.Assert;
protected String getServiceName() {
return IntakeClient.SERVICE_NAME;
}
-
+
// ---------------------------------------------------------------
// CRUD tests : READ tests
// ---------------------------------------------------------------
"UTF-8 data retrieved '" + fromRead.getEntryNote()
+ "' does not match expected data '" + getUTF8DataFragment());
}
-
+
@Override
public void delete(String testName) throws Exception {
// Do nothing because this test is not ready to delete the "knownResourceId".
// test is run, the localDelete() test/method will get run. The localDelete() test/method in turn
// calls the inherited delete() test/method.
}
-
+
@Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests", "verifyReadOnlyCoreFields"})
public void localDelete(String testName) throws Exception {
// Because of issues with TestNG not allowing @Test annotations on on override methods,
logger.debug(testName + ": read status = " + res.getStatus());
}
Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
+
input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
res.close();
}
-
+
PayloadInputPart payloadInputPart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
Element coreAsElement = null;
if (payloadInputPart != null) {
Element createdBy = coreAsElement.element(COLLECTIONSPACE_CORE_CREATED_BY);
String originalCreatedBy = createdBy.getText();
createdBy.setText("foo");
-
+
if (logger.isDebugEnabled()) {
logger.debug("Core part to be updated:");
logger.debug(coreAsElement.asXML());
// Create an output payload to send to the service, and add the common part
PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart corePart = output.addPart(COLLECTIONSPACE_CORE_SCHEMA, coreAsElement);
-
+
// Submit the request to the service and store the response.
res = client.update(knownResourceId, output);
try {
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
-
+
input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
res.close();
}
-
+
PayloadInputPart updatedCorePart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
Element updatedCoreAsElement = null;
if (updatedCorePart != null) {
updatedCoreAsElement = updatedCorePart.getElementBody();
}
Assert.assertNotNull(updatedCoreAsElement);
-
+
tenantId = updatedCoreAsElement.element(COLLECTIONSPACE_CORE_TENANTID);
String updatedTenantId = tenantId.getText();
Assert.assertEquals(updatedTenantId, originalTenantId,
// ---------------------------------------------------------------
// Utility tests : tests of code used in tests above
// ---------------------------------------------------------------
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
*
* @param identifier the identifier
* @return the multipart output
- * @throws Exception
+ * @throws Exception
*/
@Override
protected PoxPayloadOut createInstance(String identifier) throws Exception {
* @param entryDate the entry date
* @param depositor the depositor
* @return the multipart output
- * @throws Exception
+ * @throws Exception
*/
private PoxPayloadOut createIntakeInstance(String entryNumber,
String entryDate,
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
- intake.setDepositor(depositor);
+
+ DepositorGroupList depositorGroupList = new DepositorGroupList();
+ List<DepositorGroup> depositorGroups = depositorGroupList.getDepositorGroup();
+ DepositorGroup depositorGroup = new DepositorGroup();
+
+ depositorGroup.setDepositor(depositor);
+ depositorGroups.add(depositorGroup);
+
+ intake.setDepositorGroupList(depositorGroupList);
EntryMethodList entryMethodsList = new EntryMethodList();
List<String> entryMethods = entryMethodsList.getEntryMethod();
@Override
protected IntakesCommon updateInstance(IntakesCommon intakesCommon) {
IntakesCommon result = new IntakesCommon();
-
+
result.setEntryNumber("updated-" + intakesCommon.getEntryNumber());
result.setEntryNote(intakesCommon.getEntryNote());
CurrentLocationGroupList currentLocationGroupList = intakesCommon.getCurrentLocationGroupList();
Assert.assertNotNull(currentLocationGroupList);
-
+
List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
- Assert.assertNotNull(currentLocationGroups);
+ Assert.assertNotNull(currentLocationGroups);
Assert.assertTrue(currentLocationGroups.size() > 0);
-
+
CurrentLocationGroup currentLocationGroup = currentLocationGroups.get(0);
Assert.assertNotNull(currentLocationGroup);
-
+
String currentLocationNote = currentLocationGroup.getCurrentLocationNote();
Assert.assertNotNull(currentLocationNote);
-
+
String updatedCurrentLocationNote = "updated-" + currentLocationNote;
currentLocationGroups.get(0).setCurrentLocationNote(updatedCurrentLocationNote);
result.setCurrentLocationGroupList(currentLocationGroupList);
-
+
return result;
}
Assert.assertEquals(updated.getEntryNumber(),
original.getEntryNumber(),
"Data in updated object did not match submitted data.");
-
+
CurrentLocationGroupList currentLocationGroupList = updated.getCurrentLocationGroupList();
Assert.assertNotNull(currentLocationGroupList);
List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
Assert.assertNotNull(currentLocationGroups);
Assert.assertTrue(currentLocationGroups.size() > 0);
Assert.assertNotNull(currentLocationGroups.get(0));
-
+
String updatedCurrentLocationNote = original.getCurrentLocationGroupList()
.getCurrentLocationGroup().get(0).getCurrentLocationNote();
Assert.assertEquals(updatedCurrentLocationNote,
currentLocationGroups.get(0).getCurrentLocationNote(),
"Data in updated object did not match submitted data.");
-
+
Assert.assertEquals(updated.getEntryNote(), original.getEntryNote(),
"Data in updated object did not match submitted data.");
//
}
Assert.assertTrue(updated.getEntryNote().contains(getUTF8DataFragment()),
"UTF-8 data retrieved '" + updated.getEntryNote()
- + "' does not contain expected data '" + getUTF8DataFragment());
+ + "' does not contain expected data '" + getUTF8DataFragment());
}
/*
@Override
@Test(dataProvider = "testName",
dependsOnMethods = {
- "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
public void CRUDTests(String testName) {
- // Needed for TestNG dependency chain.
+ // Needed for TestNG dependency chain.
}
}
import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
import org.collectionspace.services.intake.ConditionCheckerOrAssessorList;
+import org.collectionspace.services.intake.CurrentOwnerList;
+import org.collectionspace.services.intake.DepositorGroup;
+import org.collectionspace.services.intake.DepositorGroupList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.intake.InsurerList;
import org.collectionspace.services.jaxb.AbstractCommonList;
private String knownIntakeId = null;
private List<String> intakeIdsCreated = new ArrayList<String>();
private List<String> orgIdsCreated = new ArrayList<String>();
- private String orgAuthCSID = null;
- //private String orgAuthRefName = null;
- private String currentOwnerOrgCSID = null;
+ private String orgAuthCSID = null;
+ //private String orgAuthRefName = null;
+ private String currentOwnerOrgCSID = null;
private String currentOwnerRefName = null;
private String depositorRefName = null;
private String conditionCheckerAssessorRefName = null;
protected String getServiceName() {
throw new UnsupportedOperationException(); //FIXME: REM - See http://issues.collectionspace.org/browse/CSPACE-3498
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
// Submit the request to the service and store the response.
String identifier = createIdentifier();
-
+
// Create all the organization refs and entities
createOrgRefs();
Response res = intakeClient.create(intakePayload);
try {
int statusCode = res.getStatus();
-
+
// Check the status code of the response: does it match
// the expected response(s)?
//
Assert.assertNotNull(newIntakeId, "Could not create a new Intake record.");
// Store the ID returned from the first resource created
- // for additional tests below.
+ // for additional tests below.
if (knownIntakeId == null) {
knownIntakeId = newIntakeId;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownIntakeId=" + knownIntakeId);
}
}
-
+
// Store the IDs from every resource created by tests,
// so they can be deleted after tests have been run.
intakeIdsCreated.add(newIntakeId);
}
}
-
+
/**
* Creates the organization refs.
- * @throws Exception
+ * @throws Exception
*/
protected void createOrgRefs() throws Exception{
OrganizationClient orgAuthClient = new OrganizationClient();
- //orgAuthRefName =
+ //orgAuthRefName =
// OrgAuthorityClientUtils.createOrgAuthRefName(ORGANIZATION_AUTHORITY_NAME, null);
PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
ORGANIZATION_AUTHORITY_NAME, ORGANIZATION_AUTHORITY_NAME, orgAuthClient.getCommonPartName());
} finally {
res.close();
}
-
+
currentOwnerOrgCSID = createOrganization("olivierOwnerCompany", "Olivier Owner Company", "Olivier Owner Company");
orgIdsCreated.add(currentOwnerOrgCSID);
currentOwnerRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, currentOwnerOrgCSID, orgAuthClient);
-
+
String newOrgCSID =
createOrganization("debbieDepositorAssocs", "Debbie Depositor & Associates", "Debbie Depositor & Associates");
- depositorRefName =
+ depositorRefName =
OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, newOrgCSID, orgAuthClient);
orgIdsCreated.add(newOrgCSID);
-
+
newOrgCSID = createOrganization("andrewCheckerAssessorLtd", "Andrew Checker-Assessor Ltd.", "Andrew Checker-Assessor Ltd.");
- conditionCheckerAssessorRefName =
+ conditionCheckerAssessorRefName =
OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, newOrgCSID, orgAuthClient);
orgIdsCreated.add(newOrgCSID);
-
+
newOrgCSID = createOrganization("ingridInsurerBureau", "Ingrid Insurer Bureau", "Ingrid Insurer Bureau");
- insurerRefName =
+ insurerRefName =
OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, newOrgCSID, orgAuthClient);
orgIdsCreated.add(newOrgCSID);
-
+
newOrgCSID = createOrganization("vinceValuerLLC", "Vince Valuer LLC", "Vince Valuer LLC");
- valuerRefName =
+ valuerRefName =
OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, newOrgCSID, orgAuthClient);
orgIdsCreated.add(newOrgCSID);
}
protected String createOrganization(String shortId, String shortName, String longName) throws Exception {
String result = null;
-
+
OrganizationClient orgAuthClient = new OrganizationClient();
Map<String, String> orgInfo = new HashMap<String,String>();
orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
-
+
List<OrgTermGroup> orgTerms = new ArrayList<OrgTermGroup>();
OrgTermGroup term = new OrgTermGroup();
term.setTermDisplayName(shortName);
Response res = orgAuthClient.createItem(orgAuthCSID, multipart);
try {
int statusCode = res.getStatus();
-
+
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
} finally {
res.close();
}
-
+
return result;
}
public void readAndCheckAuthRefDocs(String testName) throws Exception {
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
-
+
// Get the auth ref docs and check them
OrganizationClient orgAuthClient = new OrganizationClient();
Response refDocListResp = orgAuthClient.getReferencingObjects(orgAuthCSID, currentOwnerOrgCSID);
* For this reason, it attempts to remove all resources created
* at any point during testing, even if some of those resources
* may be expected to be deleted by certain tests.
- * @throws Exception
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
public void cleanUp() throws Exception {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
- intake.setCurrentOwner(currentOwner);
- intake.setDepositor(depositor);
+
+ CurrentOwnerList currentOwnerList = new CurrentOwnerList();
+ List<String> currentOwners = currentOwnerList.getCurrentOwner();
+
+ currentOwners.add(currentOwner);
+ intake.setCurrentOwners(currentOwnerList);
+
+ DepositorGroupList depositorGroupList = new DepositorGroupList();
+ List<DepositorGroup> depositorGroups = depositorGroupList.getDepositorGroup();
+ DepositorGroup depositorGroup = new DepositorGroup();
+
+ depositorGroup.setDepositor(depositor);
+ depositorGroups.add(depositorGroup);
+
+ intake.setDepositorGroupList(depositorGroupList);
intake.setValuer(Valuer);
ConditionCheckerOrAssessorList checkerOrAssessorList = new ConditionCheckerOrAssessorList();
import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
import org.collectionspace.services.intake.ConditionCheckerOrAssessorList;
+import org.collectionspace.services.intake.CurrentOwnerList;
+import org.collectionspace.services.intake.DepositorGroup;
+import org.collectionspace.services.intake.DepositorGroupList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.intake.InsurerList;
import org.collectionspace.services.jaxb.AbstractCommonList;
GregorianCalendarDateTimeUtils.currentDateUTC();
@Override
- public String getServiceName() {
- throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3498
+ public String getServiceName() {
+ throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3498
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
/**
* Creates the person refs.
- * @throws Exception
+ * @throws Exception
*/
protected void createPersonRefs() throws Exception {
PersonClient personAuthClient = new PersonClient();
protected String createPerson(String firstName, String surName, String shortId, String authRefName) throws Exception {
String result = null;
-
+
PersonClient personAuthClient = new PersonClient();
Map<String, String> personInfo = new HashMap<String, String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
Response res = personAuthClient.createItem(personAuthCSID, multipart);
try {
int statusCode = res.getStatus();
-
+
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
} finally {
res.close();
}
-
+
return result;
}
res.close();
}
}
-
+
List<AuthorityRefDocList.AuthorityRefDocItem> items =
list.getAuthorityRefDocItem();
Assert.assertTrue(items != null);
res.close();
}
}
-
+
items = list.getAuthorityRefDocItem();
Assert.assertTrue(items != null);
Assert.assertTrue(items.size() > 0);
Assert.assertTrue(items.get(0) != null);
-
+
// Optionally output additional data about list members for debugging.
iterateThroughList = true;
fFoundIntake = false;
res.close();
}
}
-
+
List<AuthorityRefDocList.AuthorityRefDocItem> items =
list.getAuthorityRefDocItem();
Assert.assertTrue(items != null);
* For this reason, it attempts to remove all resources created
* at any point during testing, even if some of those resources
* may be expected to be deleted by certain tests.
- * @throws Exception
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
- intake.setCurrentOwner(currentOwner);
- intake.setDepositor(depositor);
+
+ CurrentOwnerList currentOwnerList = new CurrentOwnerList();
+ List<String> currentOwners = currentOwnerList.getCurrentOwner();
+
+ currentOwners.add(currentOwner);
+ intake.setCurrentOwners(currentOwnerList);
+
+ DepositorGroupList depositorGroupList = new DepositorGroupList();
+ List<DepositorGroup> depositorGroups = depositorGroupList.getDepositorGroup();
+ DepositorGroup depositorGroup = new DepositorGroup();
+
+ depositorGroup.setDepositor(depositor);
+ depositorGroups.add(depositorGroup);
+
+ intake.setDepositorGroupList(depositorGroupList);
intake.setValuer(Valuer);
ConditionCheckerOrAssessorList checkerOrAssessorList = new ConditionCheckerOrAssessorList();
<!--
Intake schema (XSD)
-
+
Entity : Intake
Part : Common
Used for: JAXB binding between XML and Java objects
$LastChangedDate$
-->
-<xs:schema
+<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="1.0" elementFormDefault="unqualified"
Avoid XmlRootElement nightmare:
See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
-->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Intake+Schema -->
-
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Intake+Schema -->
+
<!-- intake -->
<xs:element name="intakes_common">
<xs:complexType>
<xs:sequence>
<xs:element name="csid" type="xs:string" />
-
+
<!-- Object Entry Information Group -->
- <xs:element name="currentOwner" type="xs:string"/>
- <xs:element name="depositor" type="xs:string"/>
- <xs:element name="depositorsRequirements" type="xs:string"/>
+ <xs:element name="currentOwners" type="currentOwnerList"/>
+ <xs:element name="depositorGroupList" type="depositorGroupList"/>
<xs:element name="entryDate" type="xs:string"/>
<xs:element name="entryMethods" type="entryMethodList"/>
<xs:element name="entryNote" type="xs:string"/>
</xs:complexType>
</xs:element>
+ <xs:complexType name="currentOwnerList">
+ <xs:sequence>
+ <xs:element name="currentOwner" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="depositorGroupList">
+ <xs:sequence>
+ <xs:element name="depositorGroup" type="depositorGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="depositorGroup">
+ <xs:sequence>
+ <xs:element name="depositor" type="xs:string"/>
+ <xs:element name="depositorsRequirements" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
<xs:complexType name="entryMethodList">
<xs:sequence>
<xs:element name="entryMethod" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="conditionCheckerOrAssessor" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
-
-</xs:schema>
+</xs:schema>
-/**
+/**
* 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:
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.organization.StructuredDateGroup;
-import org.collectionspace.services.organization.ContactNameList;
+import org.collectionspace.services.organization.ContactGroup;
+import org.collectionspace.services.organization.ContactGroupList;
import org.collectionspace.services.organization.FunctionList;
import org.collectionspace.services.organization.GroupList;
import org.collectionspace.services.organization.HistoryNoteList;
* OrgAuthorityClientUtils.
*/
public class OrgAuthorityClientUtils {
-
+
/** The Constant logger. */
private static final Logger logger =
LoggerFactory.getLogger(OrgAuthorityClientUtils.class);
* @param csid the id of the OrgAuthority
* @param client if null, creates a new client
* @return
- * @throws Exception
+ * @throws Exception
*/
public static String getAuthorityRefName(String csid, OrganizationClient client) throws Exception{
if (client==null) {
client = new OrganizationClient();
}
-
+
Response res = client.read(csid);
try {
int statusCode = res.getStatus();
//FIXME: remove the following try catch once Aron fixes signatures
try {
PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
- OrgauthoritiesCommon orgAuthority =
+ OrgauthoritiesCommon orgAuthority =
(OrgauthoritiesCommon) CollectionSpaceClientUtils.extractPart(input,
client.getCommonPartName(), OrgauthoritiesCommon.class);
if(orgAuthority==null) {
* @param csid the ID of the Organization
* @param client if null, creates a new client
* @return
- * @throws Exception
+ * @throws Exception
*/
public static String getOrgRefName(String inAuthority, String csid, OrganizationClient client) throws Exception{
if (client == null) {
client = new OrganizationClient();
}
-
+
Response res = client.readItem(inAuthority, csid);
try {
int statusCode = res.getStatus();
//FIXME: remove the following try catch once Aron fixes signatures
try {
PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
- OrganizationsCommon org =
+ OrganizationsCommon org =
(OrganizationsCommon) CollectionSpaceClientUtils.extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
if(org==null) {
* Creates the org authority instance.
*
* @param displayName the display name
- * @param shortIdentifier the short Id
+ * @param shortIdentifier the short Id
* @param headerLabel the header label
* @return the multipart output
*/
+"\" in orgAuthority: \"" + orgAuthorityRefName +"\"");
}
PoxPayloadOut multipart =
- createOrganizationInstance(orgAuthorityRefName,
+ createOrganizationInstance(orgAuthorityRefName,
orgInfo, terms, orgRepeatablesInfo, client.getItemCommonPartName());
Response res = client.createItem(inAuthority, multipart);
String result;
- try {
+ try {
int statusCode = res.getStatus();
-
+
if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
throw new RuntimeException("Could not create Item: \""+orgInfo.get(OrganizationJAXBSchema.SHORT_IDENTIFIER)
+"\" in orgAuthority: \"" + orgAuthorityRefName
throw new RuntimeException("Unexpected Status when creating Item: \""+ orgInfo.get(OrganizationJAXBSchema.SHORT_IDENTIFIER)
+"\" in orgAuthority: \"" + orgAuthorityRefName +"\", Status:"+ statusCode);
}
-
+
result = extractId(res);
} finally {
res.close();
}
-
+
return result;
}
-
+
public static List<OrgTermGroup> getTermGroupInstance(String shortIdentifier, String displayName) {
if (Tools.isBlank(shortIdentifier)) {
shortIdentifier = getGeneratedIdentifier();
if (Tools.isBlank(shortIdentifier)) {
displayName = shortIdentifier;
}
-
+
List<OrgTermGroup> terms = new ArrayList<OrgTermGroup>();
OrgTermGroup term = new OrgTermGroup();
term.setTermDisplayName(displayName);
terms.add(term);
return terms;
}
-
+
/*
* Create a very simple Organization term -just a short ID and display name.
*/
public static PoxPayloadOut createOrganizationInstance(String shortIdentifier, String displayName,
String headerLabel) {
List<OrgTermGroup> terms = getTermGroupInstance(shortIdentifier, displayName);
-
+
Map<String, String> orgInfo = new HashMap<String, String>();
orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
-
+
final Map<String, List<String>> EMPTY_ORG_REPEATABLES_INFO = new HashMap<String, List<String>>();
return createOrganizationInstance(null, orgInfo, terms, EMPTY_ORG_REPEATABLES_INFO, headerLabel);
- }
+ }
/**
* Creates the organization instance.
* @param headerLabel the header label
* @return the multipart output
*/
- public static PoxPayloadOut createOrganizationInstance(
- String orgAuthRefName,
- Map<String, String> orgInfo,
+ public static PoxPayloadOut createOrganizationInstance(
+ String orgAuthRefName,
+ Map<String, String> orgInfo,
List<OrgTermGroup> terms,
Map<String, List<String>> orgRepeatablesInfo,
String headerLabel) {
-
+
OrganizationsCommon organization = new OrganizationsCommon();
String shortId = orgInfo.get(OrganizationJAXBSchema.SHORT_IDENTIFIER);
if (shortId == null || shortId.isEmpty()) {
throw new IllegalArgumentException("shortIdentifier cannot be null or empty");
- }
+ }
organization.setShortIdentifier(shortId);
String value = null;
List<String> values = null;
-
+
// Set values in the Term Information Group
OrgTermGroupList termList = new OrgTermGroupList();
if (terms == null || terms.isEmpty()) {
terms = getTermGroupInstance(getGeneratedIdentifier());
}
- termList.getOrgTermGroup().addAll(terms);
+ termList.getOrgTermGroup().addAll(terms);
organization.setOrgTermGroupList(termList);
-
+
if ((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.CONTACT_NAMES))!=null) {
- ContactNameList contactsList = new ContactNameList();
- List<String> contactNames = contactsList.getContactName();
- contactNames.addAll(values);
- organization.setContactNames(contactsList);
+ ContactGroupList contactGroupList = new ContactGroupList();
+ List<ContactGroup> contactGroups = contactGroupList.getContactGroup();
+
+ for (String contactName : values) {
+ ContactGroup contactGroup = new ContactGroup();
+ contactGroup.setContactName(contactName);
+
+ contactGroups.add(contactGroup);
+ }
+
+ organization.setContactGroupList(contactGroupList);
}
if ((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_DATE))!=null) {
StructuredDateGroup foundingDate = new StructuredDateGroup();
}
return id;
}
-
+
/**
* Creates the org auth ref name.
*
terms.add(term);
return terms;
}
-
+
private static String getGeneratedIdentifier() {
- return "id" + new Date().getTime();
+ return "id" + new Date().getTime();
}
-
+
}
// Instance variables specific to this test.
final String PERSON_AUTHORITY_NAME = "TestPersonAuthForOrgTest";
final String ORG_AUTHORITY_NAME = "TestOrgAuth";
-
+
@Override
public String getServicePathComponent() {
return OrganizationClient.SERVICE_PATH_COMPONENT;
}
protected String knownItemResourceId = null;
-
+
private String knownResourceRefName = null;
-
+
/** The person ids created. */
private List<String> personIdsCreated = new ArrayList<String>();
-
+
// CSID for the instance of the test Person authority
// created during testing.
private String personAuthCSID = null;
-
+
/** The organization contact person refNames. */
private String organizationContactPersonRefName1 = null;
private String organizationContactPersonRefName2 = null;
// The refName of an Organization item that represents
// the sub-body organization of a second Organization item.
private String subBodyRefName = null;
-
+
/** The number of authorityreferences expected. */
private final int NUM_AUTH_REFS_EXPECTED = 2; // Place authRef not legal, should not be returned.
protected CollectionSpaceClient getClientInstance() {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
-
+
@Override
protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
-
+
// Store the IDs from every resource created by tests,
// so they can be deleted after tests have been run.
String newId = extractId(res);
allResourceIdsCreated.add(newId);
} finally {
res.close();
- }
+ }
// Create all the person refs and entities
createPersonRefs();
testOrgContactNames.add(organizationContactPersonRefName1);
testOrgContactNames.add(organizationContactPersonRefName2);
testOrgRepeatablesMap.put(OrganizationJAXBSchema.CONTACT_NAMES, testOrgContactNames);
-
+
List<OrgTermGroup> terms = OrgAuthorityClientUtils.getTermGroupInstance("Org name");
// Finishing creating the new Organization item, then
// so they can be deleted after tests have been run.
allResourceItemIdsCreated.put(knownItemResourceId, knownResourceId);
}
-
+
/**
* Creates the person refs.
- * @throws Exception
+ * @throws Exception
*/
protected void createPersonRefs() throws Exception {
PersonClient personAuthClient = new PersonClient();
// refName by which it can be identified.
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-
+
Response res = personAuthClient.create(multipart);
try {
int statusCode = res.getStatus();
}
//String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
-
+
// Create temporary Person resources, and their corresponding refNames
// by which they can be identified.
String csid = createPerson(personAuthCSID, "Charlie", "Orgcontact", "charlieOrgcontact" + System.currentTimeMillis(), null ); // authRefName);
personIdsCreated.add(csid);
organizationContactPersonRefName2 = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
}
-
+
/**
* Creates the person.
*
* @param shortId
* @param authRefName
* @return the string
- * @throws Exception
+ * @throws Exception
*/
protected String createPerson(String personAuthCSID, String firstName, String surName, String shortId, String authRefName ) throws Exception {
PersonClient personAuthClient = new PersonClient();
term.setForeName(firstName);
term.setSurName(surName);
personTerms.add(term);
- PoxPayloadOut multipart =
+ PoxPayloadOut multipart =
PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
null, personInfo, personTerms, personAuthClient.getItemCommonPartName());
-
+
String result = null;
Response res = personAuthClient.createItem(personAuthCSID, multipart);
try {
int statusCode = res.getStatus();
-
+
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
} finally {
res.close();
}
-
+
return result;
}
res.close();
}
}
-
+
// Check one or more of the authority fields in the Organization item
- Assert.assertEquals(organization.getContactNames().getContactName().get(0),
+ Assert.assertEquals(organization.getContactGroupList().getContactGroup().get(0).getContactName(),
organizationContactPersonRefName1);
- Assert.assertEquals(organization.getContactNames().getContactName().get(1),
+ Assert.assertEquals(organization.getContactGroupList().getContactGroup().get(1).getContactName(),
organizationContactPersonRefName2);
res2.close();
}
}
-
+
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
if(logger.isDebugEnabled()){
* For this reason, it attempts to remove all resources created
* at any point during testing, even if some of those resources
* may be expected to be deleted by certain tests.
- * @throws Exception
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
public void cleanUp() throws Exception {
}
return;
}
-
+
if (logger.isDebugEnabled()) {
logger.debug("Cleaning up temporary resources created for testing ...");
}
-
+
String parentResourceId;
String itemResourceId;
OrganizationClient client = new OrganizationClient();
// below are ignored and not reported.
client.deleteItem(parentResourceId, itemResourceId).close();
}
-
+
//
// Delete the person authority items we created for the authRefs. Note
// that we needed to delete the objects/records referencing these authority items first since
// Note: Any non-success responses are ignored and not reported.
personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
-
+
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
if (personAuthCSID != null) {
personAuthClient.delete(personAuthCSID).close();
- }
-
+ }
+
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.organization.OrgauthoritiesCommon;
import org.collectionspace.services.organization.OrganizationsCommon;
+import org.collectionspace.services.organization.ContactGroup;
import org.collectionspace.services.organization.OrgTermGroup;
import org.collectionspace.services.organization.OrgTermGroupList;
import org.slf4j.Logger;
super();
TEST_SHORTID = "TestOrg";
}
-
+
@Override
public String getServicePathComponent() {
return OrganizationClient.SERVICE_PATH_COMPONENT;
protected String getServiceName() {
return OrganizationClient.SERVICE_NAME;
}
-
+
private final String TEST_ORG_NAME = "Test Org";
private final String TEST_ORG_MAIN_BODY_NAME = "The real official test organization";
private final String TEST_ORG_FOUNDING_PLACE = "Anytown, USA";
private final String TEST_ORG_FOUNDING_DATE = "May 26, 1907";
-
+
/** The known item resource short ID. */
private String knownItemResourceShortIdentifer = null;
-
+
/** The known contact resource id. */
private String knownContactResourceId = null;
-
+
/** The all contact resource ids created. */
private Map<String, String> allContactResourceIdsCreated = new HashMap<String, String>();
/**
- *
+ *
*/
protected void setKnownItemResource(String id, String shortIdentifer) {
knownItemResourceId = id;
@Override
protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) throws Exception {
String headerLabel = new OrganizationClient().getItemCommonPartName();
-
+
String shortId = TEST_SHORTID + identifier;
Map<String, String> testOrgMap = new HashMap<String, String>();
testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, TEST_ORG_FOUNDING_DATE);
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, TEST_ORG_FOUNDING_PLACE);
-
+
List<OrgTermGroup> terms = new ArrayList<OrgTermGroup>();
OrgTermGroup term = new OrgTermGroup();
term.setTermDisplayName(TEST_ORG_NAME);
protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
return createItemInAuthority(client, authorityId, shortId, null /*refname*/);
}
-
+
/**
* Creates the item in authority.
*
if (logger.isDebugEnabled()) {
logger.debug(testName + ":...");
}
-
+
Map<String, String> testOrgMap = new HashMap<String, String>();
testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, TEST_ORG_FOUNDING_DATE);
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, TEST_ORG_FOUNDING_PLACE);
-
+
List<OrgTermGroup> terms = new ArrayList<OrgTermGroup>();
OrgTermGroup term = new OrgTermGroup();
term.setTermDisplayName(TEST_ORG_NAME);
term.setTermName(TEST_ORG_NAME);
term.setMainBodyName(TEST_ORG_MAIN_BODY_NAME);
terms.add(term);
-
+
Map<String, List<String>> testOrgRepeatablesMap = new HashMap<String, List<String>>();
List<String> testOrgContactNames = new ArrayList<String>();
testOrgContactNames.add("joe@example.org");
* Creates the contact.
*
* @param testName the test name
- * @throws Exception
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"create"},
dependsOnMethods = {"createItem"})
* @param parentcsid the parentcsid
* @param itemcsid the itemcsid
* @return the string
- * @throws Exception
+ * @throws Exception
*/
private String createContactInItem(String parentcsid, String itemcsid) throws Exception {
Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
try {
- assertStatusCode(res, testName);
+ assertStatusCode(res, testName);
//FIXME: remove the following try catch once Aron fixes signatures
try {
PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
/**
* Read item in Named Auth.
- *
+ *
* TODO Enable this if we really need this - it is a funky case, where we would have
* the shortId of the item, but the CSID of the parent authority!? Unlikely.
*
readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
}
*/
-
+
/**
* Read named item.
*
public void readNamedItem(String testName) throws Exception {
readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
}
-
+
/**
* Read item in Named Auth.
*
// 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));
+ List<ContactGroup> contactGroups = organization.getContactGroupList().getContactGroup();
+ Assert.assertTrue(contactGroups.size() > 0);
+ Assert.assertNotNull(contactGroups.get(0).getContactName());
} finally {
if (res != null) {
res.close();
}
}
}
-
+
@Override
protected void verifyReadItemInstance(OrganizationsCommon item) throws Exception {
- List<String> contactNames = item.getContactNames().getContactName();
- Assert.assertTrue(contactNames.size() > 0);
- Assert.assertNotNull(contactNames.get(0));
+ List<ContactGroup> contactGroups = item.getContactGroupList().getContactGroup();
+ Assert.assertTrue(contactGroups.size() > 0);
+ Assert.assertNotNull(contactGroups.get(0).getContactName());
}
-
+
/**
* Verify illegal item display name.
*
Response res = client.readItem(knownResourceId, knownItemResourceId);
OrganizationsCommon organization = null;
try {
- assertStatusCode(res, testName);
+ assertStatusCode(res, testName);
// Check whether organization has expected displayName.
PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
organization = (OrganizationsCommon) extractPart(input,
res.close();
}
}
-
+
//
// Make an invalid UPDATE request, without a display name
//
Assert.assertTrue(terms.size() > 0);
terms.get(0).setTermDisplayName(null);
terms.get(0).setTermName(null);
-
+
setupUpdateWithInvalidBody(); // we expect a failure
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(OrganizationClient.SERVICE_ITEM_PAYLOAD_NAME);
Response res =client.readContact(knownResourceId, knownItemResourceId,
knownContactResourceId);
try {
- assertStatusCode(res, testName);
+ assertStatusCode(res, testName);
// Check whether we've received a contact.
PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
ContactsCommon contact = (ContactsCommon) extractPart(input,
* Read contact non existent.
*
* @param testName the test name
- * @throws Exception
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"readItem"},
dependsOnMethods = {"readContact"})
/**
* Read item list.
- * @throws Exception
+ * @throws Exception
*/
@Override
// @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
/**
* Read item list by authority name.
- * @throws Exception
+ * @throws Exception
*/
@Override
// @Test(dataProvider = "testName",
*
* @param vcsid the vcsid
* @param name the name
- * @throws Exception
+ * @throws Exception
*/
private void readItemList(String vcsid, String name) throws Exception {
} else {
Assert.fail("readItemList passed null csid and name!");
}
-
+
AbstractCommonList list = null;
try {
- assertStatusCode(res, testName);
+ assertStatusCode(res, testName);
list = res.readEntity(AbstractCommonList.class);
} finally {
if (res != null) {
res.close();
}
}
-
+
List<AbstractCommonList.ListItem> items = list.getListItem();
int nItemsReturned = items.size();
// There will be 'nItemsToCreateInList'
/**
* Read contact list.
- * @throws Exception
+ * @throws Exception
*/
@Test(groups = {"readList"},
dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItemList"})
*
* @param parentcsid the parentcsid
* @param itemcsid the itemcsid
- * @throws Exception
+ * @throws Exception
*/
private void readContactList(String parentcsid, String itemcsid) throws Exception {
final String testName = "readContactList";
Response res = client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
ContactsCommon contact = null;
try {
- assertStatusCode(res, testName);
+ assertStatusCode(res, testName);
if (logger.isDebugEnabled()) {
logger.debug("got Contact to update with ID: "
+ knownContactResourceId
(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(),
public void delete(String testName) throws Exception {
// Do nothing. See localDelete(). This ensure proper test order.
}
-
- @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
+
+ @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
public void localDelete(String testName) throws Exception {
super.delete(testName);
}
// Do nothing. We need to wait until after the test "localDelete" gets run. When it does,
// its dependencies will get run first and then we can call the base class' delete method.
}
-
+
@Test(dataProvider = "testName", groups = {"delete"},
dependsOnMethods = {"verifyIllegalItemDisplayName", "testContactSubmitRequest", "deleteContact"})
public void localDeleteItem(String testName) throws Exception {
super.deleteItem(testName);
- }
-
+ }
+
/**
* Delete non existent contact.
*
* @param testName the test name
- * @throws Exception
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"delete"},
dependsOnMethods = {"deleteContact"})
* For this reason, it attempts to remove all resources created
* at any point during testing, even if some of those resources
* may be expected to be deleted by certain tests.
- * @throws Exception
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
@Override
@Override
public void authorityTests(String testName) {
// TODO Auto-generated method stub
-
+
}
@Override
protected OrganizationsCommon updateItemInstance(OrganizationsCommon organizationsCommon) {
-
+
OrgTermGroupList termList = organizationsCommon.getOrgTermGroupList();
Assert.assertNotNull(termList);
List<OrgTermGroup> terms = termList.getOrgTermGroup();
protected void compareUpdatedItemInstances(OrganizationsCommon original,
OrganizationsCommon updated,
boolean compareRevNumbers) throws Exception {
-
+
OrgTermGroupList originalTermList = original.getOrgTermGroupList();
Assert.assertNotNull(originalTermList);
List<OrgTermGroup> originalTerms = originalTermList.getOrgTermGroup();
Assert.assertNotNull(originalTerms);
Assert.assertTrue(originalTerms.size() > 0);
-
+
OrgTermGroupList updatedTermList = updated.getOrgTermGroupList();
Assert.assertNotNull(updatedTermList);
List<OrgTermGroup> updatedTerms = updatedTermList.getOrgTermGroup();
Assert.assertNotNull(updatedTerms);
Assert.assertTrue(updatedTerms.size() > 0);
-
+
Assert.assertEquals(updatedTerms.get(0).getTermDisplayName(),
originalTerms.get(0).getTermDisplayName(),
"Value in updated record did not match submitted data.");
-
+
if (compareRevNumbers == true) {
Assert.assertEquals(original.getRev(), updated.getRev(), "Revision numbers should match.");
}
displayName, shortId, commonPartName);
return result;
}
-
+
protected PoxPayloadOut createNonExistenceItemInstance(String commonPartName,
String identifier) {
Map<String, String> nonexOrgMap = new HashMap<String, String>();
@Override
protected OrgauthoritiesCommon updateInstance(OrgauthoritiesCommon orgauthoritiesCommon) {
OrgauthoritiesCommon result = new OrgauthoritiesCommon();
-
+
result.setDisplayName("updated-" + orgauthoritiesCommon.getDisplayName());
result.setVocabType("updated-" + orgauthoritiesCommon.getVocabType());
-
+
return result;
}
Used for: JAXB binding between XML and Java objects
-->
-<xs:schema
+<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="1.0" elementFormDefault="unqualified"
<!-- Common identifier -->
<xs:element name="csid" type="xs:string" />
<xs:element name="rev" type="xs:integer" /> <!-- Revision number -->
-
+
<!-- Organization Information Group -->
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
-
+
<!-- Term Information repeatable group -->
<xs:element name="orgTermGroupList" type="orgTermGroupList"/>
-
+
<xs:element name="foundingDateGroup" type="structuredDateGroup"/>
<xs:element name="dissolutionDateGroup" type="structuredDateGroup"/>
<xs:element name="foundingPlace" type="xs:string"/>
-
+
<xs:element name="groups" type="groupList"/>
<xs:element name="functions" type="functionList"/>
- <xs:element name="contactNames" type="contactNameList"/>
+ <xs:element name="contactGroupList" type="contactGroupList"/>
<xs:element name="historyNotes" type="historyNoteList"/>
</xs:sequence>
</xs:complexType>
</xs:element>
-
- <xs:complexType name="contactNameList">
+
+ <xs:element name="contactGroupList" type="contactGroupList"/>
+
+ <xs:complexType name="contactGroupList">
<xs:sequence>
- <xs:element name="contactName" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="contactGroup" type="contactGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="contactGroup">
+ <xs:sequence>
+ <xs:element name="contactName" type="xs:string"/>
+ <xs:element name="contactRole" type="xs:string"/>
+ <xs:element name="contactStatus" type="xs:string"/>
+ <xs:element name="contactDateGroup" type="structuredDateGroup"/>
+ <xs:element name="contactEndDateGroup" type="structuredDateGroup"/>
</xs:sequence>
</xs:complexType>
<xs:element name="historyNote" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
-
+
<xs:complexType name="orgTermGroupList">
<xs:sequence>
<xs:element name="orgTermGroup" type="orgTermGroup" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="scalarValuesComputed" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
-
-</xs:schema>
+</xs:schema>
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.BaseServiceTest;
import org.collectionspace.services.dimension.DimensionsCommon;
+import org.collectionspace.services.intake.DepositorGroup;
+import org.collectionspace.services.intake.DepositorGroupList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.testng.Assert;
/*
* (non-Javadoc)
- *
+ *
* @see
* org.collectionspace.services.client.test.BaseServiceTest#getClientInstance
* ()
* @param depositor
* the depositor
* @return the multipart output
- * @throws Exception
+ * @throws Exception
*/
private PoxPayloadOut createIntakeInstance(String entryNumber, String entryDate, String depositor) throws Exception {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
- intake.setDepositor(depositor);
+
+ DepositorGroupList depositorGroupList = new DepositorGroupList();
+ List<DepositorGroup> depositorGroups = depositorGroupList.getDepositorGroup();
+ DepositorGroup depositorGroup = new DepositorGroup();
+
+ depositorGroup.setDepositor(depositor);
+ depositorGroups.add(depositorGroup);
+
+ intake.setDepositorGroupList(depositorGroupList);
PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);