From 335764e5c7b6bee165e8b3d1fc55b23d3250e742 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Mon, 30 Apr 2012 18:19:21 -0700 Subject: [PATCH] CSPACE-5119,CSPACE-5135: Modified Person service client tests to reflect addition of Term Information Group to Person item schema. --- .../client/PersonAuthorityClientUtils.java | 111 ++------- .../test/PersonAuthoritySearchTest.java | 29 ++- .../test/PersonAuthorityServicePerfTest.java | 15 +- .../test/PersonAuthorityServiceTest.java | 233 ++++++------------ 4 files changed, 123 insertions(+), 265 deletions(-) diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java index 267c8ac99..a0f5668b2 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java @@ -41,6 +41,8 @@ import org.collectionspace.services.client.test.ServiceRequestType; import org.collectionspace.services.person.GroupList; import org.collectionspace.services.person.NationalityList; import org.collectionspace.services.person.OccupationList; +import org.collectionspace.services.person.PersonTermGroup; +import org.collectionspace.services.person.PersonTermGroupList; import org.collectionspace.services.person.PersonsCommon; import org.collectionspace.services.person.PersonauthoritiesCommon; import org.collectionspace.services.person.SchoolOrStyleList; @@ -167,11 +169,12 @@ public class PersonAuthorityClientUtils { public static PoxPayloadOut createPersonInstance(String inAuthority, String personAuthRefName, Map personInfo, + List terms, String headerLabel){ final Map> EMPTY_PERSON_REPEATABLES_INFO = new HashMap>(); - return createPersonInstance(inAuthority, null /*personAuthRefName*/, personInfo, - EMPTY_PERSON_REPEATABLES_INFO, headerLabel); + return createPersonInstance(inAuthority, null /*personAuthRefName*/, + personInfo, terms, EMPTY_PERSON_REPEATABLES_INFO, headerLabel); } /** @@ -180,12 +183,14 @@ public class PersonAuthorityClientUtils { * @param inAuthority the owning authority * @param personAuthRefName the owning Authority ref name * @param personInfo the person info + * @param terms a list of Person terms * @param personRepeatablesInfo names and values of repeatable scalar fields in the Person record * @param headerLabel the header label * @return the multipart output */ public static PoxPayloadOut createPersonInstance(String inAuthority, String personAuthRefName, Map personInfo, + List terms, Map> personRepeatablesInfo, String headerLabel){ PersonsCommon person = new PersonsCommon(); person.setInAuthority(inAuthority); @@ -194,57 +199,10 @@ public class PersonAuthorityClientUtils { throw new IllegalArgumentException("shortIdentifier cannot be null or empty"); } person.setShortIdentifier(shortId); - - // - // If the 'DISPLAY_NAME_COMPUTED' property is null or empty then - // we'll assume that the service consumer wants us to compute the - // display name. Otherwise, we'll parse the value with the Boolean class. - // - String booleanStr = personInfo.get(PersonJAXBSchema.DISPLAY_NAME_COMPUTED); - boolean displayNameComputed = true; - if (booleanStr != null && booleanStr.length() > 0) { - displayNameComputed = Boolean.parseBoolean(booleanStr); - } - person.setDisplayNameComputed(displayNameComputed); - - String displayName = personInfo.get(PersonJAXBSchema.DISPLAY_NAME); - person.setDisplayName(displayName); - if (displayNameComputed == false && displayName == null) { - throw new IllegalArgumentException("displayName cannot be null when displayComputed is 'false'"); - } - - booleanStr = personInfo.get(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED); - boolean shortDisplayNameComputed = true; - if (booleanStr != null && booleanStr.length() > 0) { - shortDisplayNameComputed = Boolean.parseBoolean(booleanStr); - } - person.setShortDisplayNameComputed(shortDisplayNameComputed); - - String shortDisplayName = personInfo.get(PersonJAXBSchema.SHORT_DISPLAY_NAME); - person.setShortDisplayName(shortDisplayName); - if (shortDisplayNameComputed == false && shortDisplayName == null) { - throw new IllegalArgumentException("shortDisplayName cannot be null when shortDisplayComputed is 'false'"); - } - - //String refName = createPersonRefName(personAuthRefName, shortId, displayName); - //person.setRefName(refName); String value; List values = null; - if((value = (String)personInfo.get(PersonJAXBSchema.FORE_NAME))!=null) //FIXME: REM - I don't think we need to check for null -null is a valid value and won't cause any problems. - person.setForeName(value); - if((value = (String)personInfo.get(PersonJAXBSchema.MIDDLE_NAME))!=null) - person.setMiddleName(value); - if((value = (String)personInfo.get(PersonJAXBSchema.SUR_NAME))!=null) - person.setSurName(value); - if((value = (String)personInfo.get(PersonJAXBSchema.INITIALS))!=null) - person.setInitials(value); - if((value = (String)personInfo.get(PersonJAXBSchema.SALUTATIONS))!=null) - person.setSalutation(value); - if((value = (String)personInfo.get(PersonJAXBSchema.TITLE))!=null) - person.setTitle(value); - if((value = (String)personInfo.get(PersonJAXBSchema.NAME_ADDITIONS))!=null) - person.setNameAdditions(value); + if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null) person.setBirthDate(value); if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null) @@ -260,6 +218,11 @@ public class PersonAuthorityClientUtils { if((value = (String)personInfo.get(PersonJAXBSchema.NAME_NOTE))!=null) person.setNameNote(value); + // Set values in the Term Information Group + PersonTermGroupList termList = person.getPersonTermGroupList(); + List existingTerms = termList.getPersonTermGroup(); + existingTerms = terms; + if (personRepeatablesInfo != null) { if((values = (List)personRepeatablesInfo.get(PersonJAXBSchema.GROUPS))!=null) { GroupList groupsList = new GroupList(); @@ -285,7 +248,7 @@ public class PersonAuthorityClientUtils { List schoolsOrStyles = schoolOrStyleList.getSchoolOrStyle(); schoolsOrStyles.addAll(values); person.setSchoolsOrStyles(schoolOrStyleList); - } + } } @@ -312,51 +275,25 @@ public class PersonAuthorityClientUtils { */ public static String createItemInAuthority(String vcsid, String personAuthorityRefName, Map personMap, - Map> personRepeatablesMap, PersonAuthorityClient client ) { + List terms, Map> personRepeatablesMap, + PersonAuthorityClient client ) { // Expected status code: 201 Created int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); // Type of service request being tested ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE; - - String displayName = personMap.get(PersonJAXBSchema.DISPLAY_NAME); - String displayNameComputedStr = personMap.get(PersonJAXBSchema.DISPLAY_NAME_COMPUTED); - boolean displayNameComputed = (displayNameComputedStr==null) || displayNameComputedStr.equalsIgnoreCase("true"); - if( displayName == null ) { - if(!displayNameComputed) { - throw new RuntimeException( - "CreateItem: Must supply a displayName if displayNameComputed is set to false."); - } - displayName = - prepareDefaultDisplayName( - personMap.get(PersonJAXBSchema.FORE_NAME), - personMap.get(PersonJAXBSchema.MIDDLE_NAME), - personMap.get(PersonJAXBSchema.SUR_NAME), - personMap.get(PersonJAXBSchema.BIRTH_DATE), - personMap.get(PersonJAXBSchema.DEATH_DATE)); - personMap.put(PersonJAXBSchema.DISPLAY_NAME, displayName); - } - String shortDisplayName = personMap.get(PersonJAXBSchema.SHORT_DISPLAY_NAME); - String shortDisplayNameComputedStr = personMap.get(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED); - boolean shortDisplayNameComputed = (shortDisplayNameComputedStr==null) || shortDisplayNameComputedStr.equalsIgnoreCase("true"); - if( shortDisplayName == null ) { - if(!shortDisplayNameComputed) { - throw new RuntimeException( - "CreateItem: Must supply a shortDisplayName if shortDisplayNameComputed is set to false."); - } - shortDisplayName = - prepareDefaultDisplayName( - personMap.get(PersonJAXBSchema.FORE_NAME), null, - personMap.get(PersonJAXBSchema.SUR_NAME),null,null); - personMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, shortDisplayName); - } + + String displayName = ""; + if (terms !=null && terms.size() > 0) { + displayName = terms.get(0).getDisplayName(); + } if(logger.isDebugEnabled()){ - logger.debug("Import: Create Item: \"" + displayName - +"\" in personAuthorityulary: \"" + vcsid +"\""); + logger.debug("Creating item with display name: \"" + displayName + +"\" in personAuthority: \"" + vcsid +"\""); } PoxPayloadOut multipart = createPersonInstance(vcsid, null /*personAuthorityRefName*/, - personMap, personRepeatablesMap, client.getItemCommonPartName()); + personMap, terms, personRepeatablesMap, client.getItemCommonPartName()); String result = null; ClientResponse res = client.createItem(vcsid, multipart); diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java index 226cf33ac..675d303ea 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java @@ -36,6 +36,7 @@ import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.person.PersonTermGroup; import org.jboss.resteasy.client.ClientResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -602,16 +603,20 @@ public class PersonAuthoritySearchTest extends BaseServiceTest partialTermPersonMap = new HashMap(); // - // Fill the property map for the UNICODE item + // Fill values for the UNICODE item // partialTermPersonMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, TEST_SHORT_ID_UNICODE ); - partialTermPersonMap.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false"); - partialTermPersonMap.put(PersonJAXBSchema.DISPLAY_NAME, TEST_PARTIAL_TERM_DISPLAY_NAME_UNICODE); - partialTermPersonMap.put(PersonJAXBSchema.FORE_NAME, TEST_PARTIAL_TERM_FORE_NAME); - partialTermPersonMap.put(PersonJAXBSchema.SUR_NAME, TEST_PARTIAL_TERM_SUR_NAME_UNICODE); partialTermPersonMap.put(PersonJAXBSchema.BIRTH_PLACE, TEST_KWD_BIRTH_PLACE); partialTermPersonMap.put(PersonJAXBSchema.GENDER, "male"); partialTermPersonMap.put(PersonJAXBSchema.BIO_NOTE, TEST_KWD_BIO_NOTE_NO_QUOTES); + + List partialTerms = new ArrayList(); + PersonTermGroup term = new PersonTermGroup(); + term.setDisplayName(TEST_PARTIAL_TERM_DISPLAY_NAME_UNICODE); + term.setTerm(TEST_PARTIAL_TERM_DISPLAY_NAME_UNICODE); + term.setForeName(TEST_PARTIAL_TERM_FORE_NAME); + term.setSurName(TEST_PARTIAL_TERM_SUR_NAME_UNICODE); + partialTerms.add(term); Map> partialTermRepeatablesMap = new HashMap>(); ArrayList styles = new ArrayList(); @@ -619,17 +624,18 @@ public class PersonAuthoritySearchTest extends BaseServiceTest partialTermPersonMap, + List partialTerms, Map> partialTermRepeatablesMap) throws Exception { PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(authorityCsid, null, //authRefName, - partialTermPersonMap, partialTermRepeatablesMap, client.getItemCommonPartName() ); + partialTermPersonMap, partialTerms, partialTermRepeatablesMap, client.getItemCommonPartName() ); String newID = null; ClientResponse res = client.createItem(authorityCsid, multipart); diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java index 0e6ed2452..d475409d9 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java @@ -34,6 +34,7 @@ import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.person.PersonTermGroup; import org.jboss.resteasy.client.ClientResponse; import org.slf4j.Logger; @@ -203,13 +204,19 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest terms = new ArrayList(); + PersonTermGroup term = new PersonTermGroup(); + term.setDisplayName(firstName + " " + lastName); + term.setTerm(firstName + " " + lastName); + term.setForeName(firstName); + term.setSurName(lastName); + terms.add(term); + Map> personRepeatablesMap = new HashMap>(); PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(authId, null, //authRefName, - personMap, personRepeatablesMap, client.getItemCommonPartName() ); + personMap, terms, personRepeatablesMap, client.getItemCommonPartName() ); String newID = null; ClientResponse res = client.createItem(authId, multipart); diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java index 61dcc1f28..32cb21cc7 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java @@ -46,6 +46,8 @@ 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.PersonTermGroup; +import org.collectionspace.services.person.PersonTermGroupList; import org.collectionspace.services.person.PersonsCommon; import org.jboss.resteasy.client.ClientResponse; @@ -183,15 +185,18 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest personInfo = new HashMap(); String shortId = "johnWayneTempActor"; - personInfo.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false"); - personInfo.put(PersonJAXBSchema.DISPLAY_NAME, "John Wayne Temp"); - personInfo.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false"); - personInfo.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "JohnWayneTemp"); personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId); - - return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, headerLabel); + + List terms = new ArrayList(); + PersonTermGroup term = new PersonTermGroup(); + term.setDisplayName("John Wayne Temp"); + term.setTerm("JohnWayneTemp"); + terms.add(term); + + return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, terms, headerLabel); } /** @@ -214,14 +219,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest johnWayneTerms = new ArrayList(); + PersonTermGroup term = new PersonTermGroup(); + term.setDisplayName("John Wayne DisplayName"); + term.setTerm("John Wayne"); + term.setForeName(TEST_FORE_NAME); + term.setSurName(TEST_SUR_NAME); + johnWayneTerms.add(term); + Map> johnWayneRepeatablesMap = new HashMap>(); List johnWayneGroups = new ArrayList(); johnWayneGroups.add("Irish"); johnWayneGroups.add("Scottish"); johnWayneRepeatablesMap.put(PersonJAXBSchema.GROUPS, johnWayneGroups); - return createItemInAuthority(vcsid, null /*authRefName*/, shortId, johnWayneMap, johnWayneRepeatablesMap); + return createItemInAuthority(vcsid, null /*authRefName*/, shortId, johnWayneMap, johnWayneTerms, johnWayneRepeatablesMap); } @@ -253,7 +259,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest terms, Map itemRepeatableFieldProperties) { final String testName = "createItemInAuthority"; if (logger.isDebugEnabled()) { @@ -264,7 +270,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest res = client.createItem(vcsid, multipart); String newID = null; @@ -409,15 +415,18 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest fieldProperties = new HashMap(); - 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_DISPLAY_NAME, shortId); fieldProperties.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId); + + List terms = new ArrayList(); + PersonTermGroup term = new PersonTermGroup(); + term.setDisplayName(shortId); + term.setTerm(shortId); + terms.add(term); + final Map NULL_REPEATABLE_FIELD_PROPERTIES = null; PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(knownResourceId, - null /*knownResourceRefName*/, fieldProperties, + null /*knownResourceRefName*/, fieldProperties, terms, NULL_REPEATABLE_FIELD_PROPERTIES, client.getItemCommonPartName()); // Send the request and receive a response @@ -617,135 +626,10 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest res = client.readItem(knownResourceId, knownItemResourceId); - try { - assertStatusCode(res, testName); - // Check whether person has expected displayName. - input = new PoxPayloadIn(res.getEntity()); - } finally { - if (res != null) { - res.releaseConnection(); - } - } - - PersonsCommon person = (PersonsCommon) extractPart(input, - client.getItemCommonPartName(), PersonsCommon.class); - Assert.assertNotNull(person); - // Check whether person has expected displayName. - // Make sure displayName matches computed form - String displayName = person.getDisplayName(); - String expectedDisplayName = - PersonAuthorityClientUtils.prepareDefaultDisplayName( - TEST_FORE_NAME, null, TEST_SUR_NAME, - TEST_BIRTH_DATE, TEST_DEATH_DATE); - Assert.assertFalse(displayName.equals(expectedDisplayName)); - - // Make sure short displayName matches computed form - String shortDisplayName = person.getShortDisplayName(); - 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); - - // Submit the updated resource to the service and store the response. - PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person); - res = client.updateItem(knownResourceId, knownItemResourceId, output); - try { - assertStatusCode(res, testName); - // Retrieve the updated resource and verify that its contents exist. - input = new PoxPayloadIn(res.getEntity()); - } finally { - if (res != null) { - res.releaseConnection(); - } - } - - PersonsCommon updatedPerson = - (PersonsCommon) extractPart(input, - 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."); - // Verify that the updated resource computes the right displayName. - Assert.assertEquals(updatedPerson.getDisplayName(), expectedDisplayName, - "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."); - - // Now Update the displayName, not computed and verify the computed name is overriden. - person.setDisplayNameComputed(false); - expectedDisplayName = "TestName"; - person.setDisplayName(expectedDisplayName); - person.setShortDisplayNameComputed(false); - person.setShortDisplayName(expectedDisplayName); - - // Submit the updated resource to the service and store the response. - output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - commonPart = output.addPart(client.getItemCommonPartName(), person); - res = client.updateItem(knownResourceId, knownItemResourceId, output); - try { - assertStatusCode(res, testName); - // Retrieve the updated resource and verify that its contents exist. - input = new PoxPayloadIn(res.getEntity()); - } finally { - if (res != null) { - res.releaseConnection(); - } - } - - updatedPerson = - (PersonsCommon) extractPart(input, - client.getItemCommonPartName(), PersonsCommon.class); - Assert.assertNotNull(updatedPerson); - - // Verify that the updated resource received the correct data. - Assert.assertEquals(updatedPerson.isDisplayNameComputed(), false, - "Updated displayNameComputed in Person did not match submitted data."); - // Verify that the updated resource computes the right displayName. - Assert.assertEquals(updatedPerson.getDisplayName(), - 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, - "Updated ShortDisplayName (not computed) in Person not stored."); - } + + // FIXME: This test depends on server-side validation logic to require + // a non-null (and potentially, non-empty) displayname for each term, + // and will fail if that validation is not present. /** * Verify illegal item display name. @@ -753,8 +637,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest johnWayneTerms = new ArrayList(); + PersonTermGroup term = new PersonTermGroup(); + term.setDisplayName("John Wayne DisplayName"); + term.setTerm("John Wayne"); + term.setForeName(TEST_FORE_NAME); + term.setSurName(TEST_SUR_NAME); + johnWayneTerms.add(term); + + PersonTermGroupList termList = person.getPersonTermGroupList(); + Assert.assertNotNull(termList); + List terms = termList.getPersonTermGroup(); + Assert.assertNotNull(terms); + terms.get(0).setDisplayName(null); // Submit the updated resource to the service and store the response. PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); @@ -1105,7 +998,12 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest terms = termList.getPersonTermGroup(); + Assert.assertNotNull(terms); + String foreName = terms.get(0).getForeName(); + terms.get(0).setForeName("updated-" + foreName); if (logger.isDebugEnabled()) { logger.debug("to be updated Person"); logger.debug(objectAsXmlString(person, @@ -1138,8 +1036,12 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest updatedTerms = termList.getPersonTermGroup(); + Assert.assertNotNull(updatedTerms); + String updatedForeName = updatedTerms.get(0).getForeName(); + Assert.assertEquals(updatedForeName, foreName, "Data in updated Person did not match submitted data."); } @@ -1518,14 +1420,19 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest nonexMap = new HashMap(); nonexMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, "nonEX"); - nonexMap.put(PersonJAXBSchema.FORE_NAME, "John"); - nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne"); nonexMap.put(PersonJAXBSchema.GENDER, "male"); + + List terms = new ArrayList(); + PersonTermGroup term = new PersonTermGroup(); + term.setForeName("John"); + term.setSurName("Wayne"); + terms.add(term); + Map> nonexRepeatablesMap = new HashMap>(); PoxPayloadOut result = PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID, null, //PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null), - nonexMap, nonexRepeatablesMap, commonPartName); + nonexMap, terms, nonexRepeatablesMap, commonPartName); return result; } -- 2.47.3