From: Ray Lee Date: Sun, 15 Mar 2020 23:34:06 +0000 (-0700) Subject: NOJIRA: Fix tests. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=b0fd8e03ef5dec2eff5723b99569641bca73827c;p=tmp%2Fjakarta-migration.git NOJIRA: Fix tests. --- diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/intake1.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/intake1.xml index 38892b544..593dea486 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/intake1.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/authrefs/intake1.xml @@ -5,7 +5,6 @@ CompleteIntake001 urn:cspace:core.collectionspace.org:locationauthorities:name(location):item:name(MOMA1321979112557)'MOMA' BH-90210 - Must wear suit and tie commission 1234-5678-90 2010-07-14T04:00:00Z @@ -38,8 +37,15 @@ 2010-07-16T04:00:00Z 2010-07-05T04:00:00Z - urn:cspace:org.collectionspace.demo:personauthority:name(person):person:name(seanbean)'Sean+Bean' + + urn:cspace:org.collectionspace.demo:personauthority:name(person):person:name(seanbean)'Sean+Bean' + 2009-07-15T04:00:00Z - urn:cspace:org.collectionspace.demo:personauthority:name(person):person:name(tommyjones)'Tommy+Jones' + + + urn:cspace:org.collectionspace.demo:personauthority:name(person):person:name(tommyjones)'Tommy+Jones' + Must wear suit and tie + + diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java index 24b96e4cc..46cbe5f2b 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java @@ -40,6 +40,9 @@ import org.collectionspace.services.client.PoxPayloadOut; 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; @@ -68,7 +71,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { private String knownResourceId = null; private List intakeIdsCreated = new ArrayList(); private List personIdsCreated = new ArrayList(); - private String personAuthCSID = null; + private String personAuthCSID = null; private String currentOwnerRefName = null; private String depositorRefName = null; private String conditionCheckerOrAssessorRefName = null; @@ -80,7 +83,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { 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() */ @@ -93,7 +96,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { 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) */ @@ -112,10 +115,10 @@ public class IntakeAuthRefsTest extends BaseServiceTest { // 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( @@ -156,12 +159,12 @@ public class IntakeAuthRefsTest extends BaseServiceTest { 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 @@ -179,32 +182,32 @@ public class IntakeAuthRefsTest extends BaseServiceTest { } 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 personInfo = new HashMap(); personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); @@ -216,10 +219,10 @@ public class IntakeAuthRefsTest extends BaseServiceTest { 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(); @@ -230,7 +233,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { } finally { res.close(); } - + return result; } @@ -249,7 +252,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { 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 { @@ -257,7 +260,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { res.close(); } } - + // Get the auth refs and check them res = intakeClient.getAuthorityRefs(knownResourceId); AuthorityRefList list = null; @@ -269,7 +272,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { res.close(); } } - + List items = list.getAuthorityRefItem(); int numAuthRefsFound = items.size(); if (logger.isDebugEnabled()) { @@ -308,7 +311,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { * 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 { @@ -345,17 +348,30 @@ public class IntakeAuthRefsTest extends BaseServiceTest { } 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 currentOwners = currentOwnerList.getCurrentOwner(); + + currentOwners.add(currentOwner); + intake.setCurrentOwners(currentOwnerList); + + DepositorGroupList depositorGroupList = new DepositorGroupList(); + List depositorGroups = depositorGroupList.getDepositorGroup(); + DepositorGroup depositorGroup = new DepositorGroup(); + + depositorGroup.setDepositor(depositor); + depositorGroups.add(depositorGroup); + + intake.setDepositorGroupList(depositorGroupList); intake.setValuer(Valuer); ConditionCheckerOrAssessorList checkerOrAssessorList = new ConditionCheckerOrAssessorList(); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index 38a421ad3..b4256a9d3 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -39,6 +39,8 @@ import org.collectionspace.services.intake.EntryMethodList; 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; @@ -76,7 +78,7 @@ public class IntakeServiceTest extends AbstractPoxServiceTestImpl depositorGroups = depositorGroupList.getDepositorGroup(); + DepositorGroup depositorGroup = new DepositorGroup(); + + depositorGroup.setDepositor(depositor); + depositorGroups.add(depositorGroup); + + intake.setDepositorGroupList(depositorGroupList); EntryMethodList entryMethodsList = new EntryMethodList(); List entryMethods = entryMethodsList.getEntryMethod(); @@ -332,27 +342,27 @@ public class IntakeServiceTest extends AbstractPoxServiceTestImpl 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; } @@ -362,20 +372,20 @@ public class IntakeServiceTest extends AbstractPoxServiceTestImpl 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."); // @@ -387,7 +397,7 @@ public class IntakeServiceTest extends AbstractPoxServiceTestImpl intakeIdsCreated = new ArrayList(); private List orgIdsCreated = new ArrayList(); - 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; @@ -83,7 +86,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest orgInfo = new HashMap(); orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId); - + List orgTerms = new ArrayList(); OrgTermGroup term = new OrgTermGroup(); term.setTermDisplayName(shortName); @@ -235,7 +238,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest currentOwners = currentOwnerList.getCurrentOwner(); + + currentOwners.add(currentOwner); + intake.setCurrentOwners(currentOwnerList); + + DepositorGroupList depositorGroupList = new DepositorGroupList(); + List depositorGroups = depositorGroupList.getDepositorGroup(); + DepositorGroup depositorGroup = new DepositorGroup(); + + depositorGroup.setDepositor(depositor); + depositorGroups.add(depositorGroup); + + intake.setDepositorGroupList(depositorGroupList); intake.setValuer(Valuer); ConditionCheckerOrAssessorList checkerOrAssessorList = new ConditionCheckerOrAssessorList(); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java index 50f5baa80..12c634aad 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java @@ -39,6 +39,9 @@ import org.collectionspace.services.client.PoxPayloadOut; 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; @@ -82,10 +85,10 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { 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() */ @@ -167,7 +170,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { /** * Creates the person refs. - * @throws Exception + * @throws Exception */ protected void createPersonRefs() throws Exception { PersonClient personAuthClient = new PersonClient(); @@ -225,7 +228,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { protected String createPerson(String firstName, String surName, String shortId, String authRefName) throws Exception { String result = null; - + PersonClient personAuthClient = new PersonClient(); Map personInfo = new HashMap(); personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); @@ -243,7 +246,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { Response res = personAuthClient.createItem(personAuthCSID, multipart); try { int statusCode = res.getStatus(); - + Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, STATUS_CREATED); @@ -251,7 +254,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { } finally { res.close(); } - + return result; } @@ -274,7 +277,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { res.close(); } } - + List items = list.getAuthorityRefDocItem(); Assert.assertTrue(items != null); @@ -313,12 +316,12 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { 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; @@ -365,7 +368,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { res.close(); } } - + List items = list.getAuthorityRefDocItem(); Assert.assertTrue(items != null); @@ -405,7 +408,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { * 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 { @@ -452,8 +455,21 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { IntakesCommon intake = new IntakesCommon(); intake.setEntryNumber(entryNumber); intake.setEntryDate(entryDate); - intake.setCurrentOwner(currentOwner); - intake.setDepositor(depositor); + + CurrentOwnerList currentOwnerList = new CurrentOwnerList(); + List currentOwners = currentOwnerList.getCurrentOwner(); + + currentOwners.add(currentOwner); + intake.setCurrentOwners(currentOwnerList); + + DepositorGroupList depositorGroupList = new DepositorGroupList(); + List depositorGroups = depositorGroupList.getDepositorGroup(); + DepositorGroup depositorGroup = new DepositorGroup(); + + depositorGroup.setDepositor(depositor); + depositorGroups.add(depositorGroup); + + intake.setDepositorGroupList(depositorGroupList); intake.setValuer(Valuer); ConditionCheckerOrAssessorList checkerOrAssessorList = new ConditionCheckerOrAssessorList(); diff --git a/services/intake/jaxb/src/main/resources/intakes-common.xsd b/services/intake/jaxb/src/main/resources/intakes-common.xsd index a088782e2..cde240b54 100644 --- a/services/intake/jaxb/src/main/resources/intakes-common.xsd +++ b/services/intake/jaxb/src/main/resources/intakes-common.xsd @@ -2,7 +2,7 @@ - - - + + - + - - - + + @@ -83,6 +82,25 @@ + + + + + + + + + + + + + + + + + + + @@ -150,6 +168,5 @@ - - + diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java index 69520c7b1..dbaddb916 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java @@ -1,4 +1,4 @@ -/** +/** * 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: @@ -31,7 +31,8 @@ import org.collectionspace.services.client.test.ServiceRequestType; 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; @@ -48,7 +49,7 @@ import org.slf4j.LoggerFactory; * OrgAuthorityClientUtils. */ public class OrgAuthorityClientUtils { - + /** The Constant logger. */ private static final Logger logger = LoggerFactory.getLogger(OrgAuthorityClientUtils.class); @@ -58,13 +59,13 @@ public class OrgAuthorityClientUtils { * @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(); @@ -74,7 +75,7 @@ public class OrgAuthorityClientUtils { //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) { @@ -94,13 +95,13 @@ public class OrgAuthorityClientUtils { * @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(); @@ -111,7 +112,7 @@ public class OrgAuthorityClientUtils { //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) { @@ -130,7 +131,7 @@ public class OrgAuthorityClientUtils { * 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 */ @@ -181,14 +182,14 @@ public class OrgAuthorityClientUtils { +"\" 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 @@ -198,15 +199,15 @@ public class OrgAuthorityClientUtils { 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 getTermGroupInstance(String shortIdentifier, String displayName) { if (Tools.isBlank(shortIdentifier)) { shortIdentifier = getGeneratedIdentifier(); @@ -214,7 +215,7 @@ public class OrgAuthorityClientUtils { if (Tools.isBlank(shortIdentifier)) { displayName = shortIdentifier; } - + List terms = new ArrayList(); OrgTermGroup term = new OrgTermGroup(); term.setTermDisplayName(displayName); @@ -222,21 +223,21 @@ public class OrgAuthorityClientUtils { 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 terms = getTermGroupInstance(shortIdentifier, displayName); - + Map orgInfo = new HashMap(); orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier); - + final Map> EMPTY_ORG_REPEATABLES_INFO = new HashMap>(); return createOrganizationInstance(null, orgInfo, terms, EMPTY_ORG_REPEATABLES_INFO, headerLabel); - } + } /** * Creates the organization instance. @@ -266,35 +267,42 @@ public class OrgAuthorityClientUtils { * @param headerLabel the header label * @return the multipart output */ - public static PoxPayloadOut createOrganizationInstance( - String orgAuthRefName, - Map orgInfo, + public static PoxPayloadOut createOrganizationInstance( + String orgAuthRefName, + Map orgInfo, List terms, Map> 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 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)orgRepeatablesInfo.get(OrganizationJAXBSchema.CONTACT_NAMES))!=null) { - ContactNameList contactsList = new ContactNameList(); - List contactNames = contactsList.getContactName(); - contactNames.addAll(values); - organization.setContactNames(contactsList); + ContactGroupList contactGroupList = new ContactGroupList(); + List 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(); @@ -375,7 +383,7 @@ public class OrgAuthorityClientUtils { } return id; } - + /** * Creates the org auth ref name. * @@ -451,9 +459,9 @@ public class OrgAuthorityClientUtils { terms.add(term); return terms; } - + private static String getGeneratedIdentifier() { - return "id" + new Date().getTime(); + return "id" + new Date().getTime(); } - + } diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java index 7d7904257..afa7c9cc4 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java @@ -65,7 +65,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest personIdsCreated = new ArrayList(); - + // 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; @@ -94,7 +94,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest terms = OrgAuthorityClientUtils.getTermGroupInstance("Org name"); // Finishing creating the new Organization item, then @@ -206,10 +206,10 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest items = list.getAuthorityRefItem(); int numAuthRefsFound = items.size(); if(logger.isDebugEnabled()){ @@ -377,7 +377,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest allContactResourceIdsCreated = new HashMap(); /** - * + * */ protected void setKnownItemResource(String id, String shortIdentifer) { knownItemResourceId = id; @@ -133,13 +134,13 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest testOrgMap = new HashMap(); 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 terms = new ArrayList(); OrgTermGroup term = new OrgTermGroup(); term.setTermDisplayName(TEST_ORG_NAME); @@ -154,7 +155,7 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest testOrgMap = new HashMap(); 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 terms = new ArrayList(); 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> testOrgRepeatablesMap = new HashMap>(); List testOrgContactNames = new ArrayList(); testOrgContactNames.add("joe@example.org"); @@ -211,7 +212,7 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest contactNames = organization.getContactNames().getContactName(); - Assert.assertTrue(contactNames.size() > 0); - Assert.assertNotNull(contactNames.get(0)); + List 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 contactNames = item.getContactNames().getContactName(); - Assert.assertTrue(contactNames.size() > 0); - Assert.assertNotNull(contactNames.get(0)); + List contactGroups = item.getContactGroupList().getContactGroup(); + Assert.assertTrue(contactGroups.size() > 0); + Assert.assertNotNull(contactGroups.get(0).getContactName()); } - + /** * Verify illegal item display name. * @@ -479,7 +480,7 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest 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); @@ -534,7 +535,7 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest items = list.getListItem(); int nItemsReturned = items.size(); // There will be 'nItemsToCreateInList' @@ -669,7 +670,7 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest terms = termList.getOrgTermGroup(); @@ -1088,23 +1089,23 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest originalTerms = originalTermList.getOrgTermGroup(); Assert.assertNotNull(originalTerms); Assert.assertTrue(originalTerms.size() > 0); - + OrgTermGroupList updatedTermList = updated.getOrgTermGroupList(); Assert.assertNotNull(updatedTermList); List 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."); } @@ -1131,7 +1132,7 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest nonexOrgMap = new HashMap(); @@ -1146,10 +1147,10 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest - - + - + - + - + - + - - + + + + - + + + + + + + + + + + @@ -73,7 +85,7 @@ - + @@ -131,6 +143,5 @@ - - + diff --git a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java index e9c6b4c1f..abc1148bf 100644 --- a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java +++ b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java @@ -66,6 +66,8 @@ import org.collectionspace.services.client.RoleClient; 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; @@ -226,7 +228,7 @@ public class AuthorizationServiceTest extends BaseServiceTest 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);