import org.collectionspace.services.person.GroupList;\r
import org.collectionspace.services.person.NationalityList;\r
import org.collectionspace.services.person.OccupationList;\r
+import org.collectionspace.services.person.PersonTermGroup;\r
+import org.collectionspace.services.person.PersonTermGroupList;\r
import org.collectionspace.services.person.PersonsCommon;\r
import org.collectionspace.services.person.PersonauthoritiesCommon;\r
import org.collectionspace.services.person.SchoolOrStyleList;\r
public static PoxPayloadOut createPersonInstance(String inAuthority,\r
String personAuthRefName,\r
Map<String, String> personInfo,\r
+ List<PersonTermGroup> terms,\r
String headerLabel){\r
final Map<String, List<String>> EMPTY_PERSON_REPEATABLES_INFO =\r
new HashMap<String, List<String>>();\r
- return createPersonInstance(inAuthority, null /*personAuthRefName*/, personInfo,\r
- EMPTY_PERSON_REPEATABLES_INFO, headerLabel);\r
+ return createPersonInstance(inAuthority, null /*personAuthRefName*/,\r
+ personInfo, terms, EMPTY_PERSON_REPEATABLES_INFO, headerLabel);\r
}\r
\r
/**\r
* @param inAuthority the owning authority\r
* @param personAuthRefName the owning Authority ref name\r
* @param personInfo the person info\r
+ * @param terms a list of Person terms\r
* @param personRepeatablesInfo names and values of repeatable scalar fields in the Person record\r
* @param headerLabel the header label\r
* @return the multipart output\r
*/\r
public static PoxPayloadOut createPersonInstance(String inAuthority, \r
String personAuthRefName, Map<String, String> personInfo,\r
+ List<PersonTermGroup> terms,\r
Map<String, List<String>> personRepeatablesInfo, String headerLabel){\r
PersonsCommon person = new PersonsCommon();\r
person.setInAuthority(inAuthority);\r
throw new IllegalArgumentException("shortIdentifier cannot be null or empty");\r
} \r
person.setShortIdentifier(shortId);\r
- \r
- //\r
- // If the 'DISPLAY_NAME_COMPUTED' property is null or empty then\r
- // we'll assume that the service consumer wants us to compute the\r
- // display name. Otherwise, we'll parse the value with the Boolean class.\r
- //\r
- String booleanStr = personInfo.get(PersonJAXBSchema.DISPLAY_NAME_COMPUTED);\r
- boolean displayNameComputed = true;\r
- if (booleanStr != null && booleanStr.length() > 0) {\r
- displayNameComputed = Boolean.parseBoolean(booleanStr);\r
- }\r
- person.setDisplayNameComputed(displayNameComputed);\r
-\r
- String displayName = personInfo.get(PersonJAXBSchema.DISPLAY_NAME);\r
- person.setDisplayName(displayName);\r
- if (displayNameComputed == false && displayName == null) {\r
- throw new IllegalArgumentException("displayName cannot be null when displayComputed is 'false'");\r
- } \r
-\r
- booleanStr = personInfo.get(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);\r
- boolean shortDisplayNameComputed = true;\r
- if (booleanStr != null && booleanStr.length() > 0) {\r
- shortDisplayNameComputed = Boolean.parseBoolean(booleanStr);\r
- }\r
- person.setShortDisplayNameComputed(shortDisplayNameComputed);\r
-\r
- String shortDisplayName = personInfo.get(PersonJAXBSchema.SHORT_DISPLAY_NAME);\r
- person.setShortDisplayName(shortDisplayName);\r
- if (shortDisplayNameComputed == false && shortDisplayName == null) {\r
- throw new IllegalArgumentException("shortDisplayName cannot be null when shortDisplayComputed is 'false'");\r
- } \r
-\r
- //String refName = createPersonRefName(personAuthRefName, shortId, displayName);\r
- //person.setRefName(refName);\r
\r
String value;\r
List<String> values = null;\r
- 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. \r
- person.setForeName(value);\r
- if((value = (String)personInfo.get(PersonJAXBSchema.MIDDLE_NAME))!=null)\r
- person.setMiddleName(value);\r
- if((value = (String)personInfo.get(PersonJAXBSchema.SUR_NAME))!=null)\r
- person.setSurName(value);\r
- if((value = (String)personInfo.get(PersonJAXBSchema.INITIALS))!=null)\r
- person.setInitials(value);\r
- if((value = (String)personInfo.get(PersonJAXBSchema.SALUTATIONS))!=null)\r
- person.setSalutation(value);\r
- if((value = (String)personInfo.get(PersonJAXBSchema.TITLE))!=null)\r
- person.setTitle(value);\r
- if((value = (String)personInfo.get(PersonJAXBSchema.NAME_ADDITIONS))!=null)\r
- person.setNameAdditions(value);\r
+\r
if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null)\r
person.setBirthDate(value);\r
if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null)\r
if((value = (String)personInfo.get(PersonJAXBSchema.NAME_NOTE))!=null)\r
person.setNameNote(value);\r
\r
+ // Set values in the Term Information Group\r
+ PersonTermGroupList termList = person.getPersonTermGroupList();\r
+ List<PersonTermGroup> existingTerms = termList.getPersonTermGroup();\r
+ existingTerms = terms;\r
+ \r
if (personRepeatablesInfo != null) {\r
if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.GROUPS))!=null) {\r
GroupList groupsList = new GroupList();\r
List<String> schoolsOrStyles = schoolOrStyleList.getSchoolOrStyle();\r
schoolsOrStyles.addAll(values);\r
person.setSchoolsOrStyles(schoolOrStyleList);\r
- }\r
+ } \r
}\r
\r
\r
*/\r
public static String createItemInAuthority(String vcsid, \r
String personAuthorityRefName, Map<String,String> personMap,\r
- Map<String, List<String>> personRepeatablesMap, PersonAuthorityClient client ) {\r
+ List<PersonTermGroup> terms, Map<String, List<String>> personRepeatablesMap,\r
+ PersonAuthorityClient client ) {\r
// Expected status code: 201 Created\r
int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();\r
// Type of service request being tested\r
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
- \r
- String displayName = personMap.get(PersonJAXBSchema.DISPLAY_NAME);\r
- String displayNameComputedStr = personMap.get(PersonJAXBSchema.DISPLAY_NAME_COMPUTED);\r
- boolean displayNameComputed = (displayNameComputedStr==null) || displayNameComputedStr.equalsIgnoreCase("true");\r
- if( displayName == null ) {\r
- if(!displayNameComputed) {\r
- throw new RuntimeException(\r
- "CreateItem: Must supply a displayName if displayNameComputed is set to false.");\r
- }\r
- displayName = \r
- prepareDefaultDisplayName(\r
- personMap.get(PersonJAXBSchema.FORE_NAME),\r
- personMap.get(PersonJAXBSchema.MIDDLE_NAME),\r
- personMap.get(PersonJAXBSchema.SUR_NAME),\r
- personMap.get(PersonJAXBSchema.BIRTH_DATE),\r
- personMap.get(PersonJAXBSchema.DEATH_DATE));\r
- personMap.put(PersonJAXBSchema.DISPLAY_NAME, displayName);\r
- }\r
- String shortDisplayName = personMap.get(PersonJAXBSchema.SHORT_DISPLAY_NAME);\r
- String shortDisplayNameComputedStr = personMap.get(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);\r
- boolean shortDisplayNameComputed = (shortDisplayNameComputedStr==null) || shortDisplayNameComputedStr.equalsIgnoreCase("true");\r
- if( shortDisplayName == null ) {\r
- if(!shortDisplayNameComputed) {\r
- throw new RuntimeException(\r
- "CreateItem: Must supply a shortDisplayName if shortDisplayNameComputed is set to false.");\r
- }\r
- shortDisplayName = \r
- prepareDefaultDisplayName(\r
- personMap.get(PersonJAXBSchema.FORE_NAME), null,\r
- personMap.get(PersonJAXBSchema.SUR_NAME),null,null);\r
- personMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, shortDisplayName);\r
- }\r
+ \r
+ String displayName = "";\r
+ if (terms !=null && terms.size() > 0) {\r
+ displayName = terms.get(0).getDisplayName();\r
+ }\r
\r
if(logger.isDebugEnabled()){\r
- logger.debug("Import: Create Item: \"" + displayName\r
- +"\" in personAuthorityulary: \"" + vcsid +"\"");\r
+ logger.debug("Creating item with display name: \"" + displayName\r
+ +"\" in personAuthority: \"" + vcsid +"\"");\r
}\r
PoxPayloadOut multipart = \r
createPersonInstance(vcsid, null /*personAuthorityRefName*/,\r
- personMap, personRepeatablesMap, client.getItemCommonPartName());\r
+ personMap, terms, personRepeatablesMap, client.getItemCommonPartName());\r
\r
String result = null;\r
ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
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;
PersonAuthorityClient client = new PersonAuthorityClient();
Map<String, String> partialTermPersonMap = new HashMap<String,String>();
//
- // 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<PersonTermGroup> partialTerms = new ArrayList<PersonTermGroup>();
+ 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<String, List<String>> partialTermRepeatablesMap = new HashMap<String, List<String>>();
ArrayList<String> styles = new ArrayList<String>();
partialTermRepeatablesMap.put(PersonJAXBSchema.SCHOOLS_OR_STYLES, styles);
createItem(testName, authorityCsid, null /*authRefName*/, client,
- partialTermPersonMap, partialTermRepeatablesMap);
+ partialTermPersonMap, partialTerms, partialTermRepeatablesMap);
//
- // Adjust the property map for the QUOTE item
+ // Adjust values for the QUOTE item
//
partialTermPersonMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, TEST_SHORT_ID_QUOTE );
- partialTermPersonMap.put(PersonJAXBSchema.DISPLAY_NAME, TEST_PARTIAL_TERM_DISPLAY_NAME_QUOTE);
- partialTermPersonMap.put(PersonJAXBSchema.SUR_NAME, TEST_PARTIAL_TERM_SUR_NAME_QUOTE);
partialTermPersonMap.put(PersonJAXBSchema.BIO_NOTE, TEST_KWD_BIO_NOTE_DBL_QUOTES);
+
+ partialTerms.get(0).setDisplayName(TEST_PARTIAL_TERM_DISPLAY_NAME_QUOTE);
+ partialTerms.get(0).setSurName(TEST_PARTIAL_TERM_SUR_NAME_QUOTE);
createItem(testName, authorityCsid, null /*authRefName*/, client,
- partialTermPersonMap, partialTermRepeatablesMap);
+ partialTermPersonMap, partialTerms, partialTermRepeatablesMap);
}
private void createItem(
String authRefName,
PersonAuthorityClient client,
Map<String, String> partialTermPersonMap,
+ List<PersonTermGroup> partialTerms,
Map<String, List<String>> partialTermRepeatablesMap) throws Exception {
PoxPayloadOut multipart =
PersonAuthorityClientUtils.createPersonInstance(authorityCsid, null, //authRefName,
- partialTermPersonMap, partialTermRepeatablesMap, client.getItemCommonPartName() );
+ partialTermPersonMap, partialTerms, partialTermRepeatablesMap, client.getItemCommonPartName() );
String newID = null;
ClientResponse<Response> res = client.createItem(authorityCsid, multipart);
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;
@Override
protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
String headerLabel = new PersonAuthorityClient().getItemCommonPartName();
+
HashMap<String, String> personInfo = new HashMap<String, String>();
String shortId = "johnWayneTempActor";
- personInfo.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
- personInfo.put(PersonJAXBSchema.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<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
+ PersonTermGroup term = new PersonTermGroup();
+ term.setDisplayName("John Wayne Temp");
+ term.setTerm("JohnWayneTemp");
+ terms.add(term);
+
+ return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, terms, headerLabel);
}
/**
// Fill the property map
//
String shortId = "johnWayneActor";
- johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
- johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME, "John Wayne");
- johnWayneMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
- johnWayneMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "JohnWayne");
johnWayneMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
-
- johnWayneMap.put(PersonJAXBSchema.FORE_NAME, TEST_FORE_NAME);
- johnWayneMap.put(PersonJAXBSchema.SUR_NAME, TEST_SUR_NAME);
johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, TEST_BIRTH_DATE);
johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
+ "He was also known for his conservative political views and his support in "
+ "the 1950s for anti-communist positions.");
+ List<PersonTermGroup> johnWayneTerms = new ArrayList<PersonTermGroup>();
+ 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<String, List<String>> johnWayneRepeatablesMap = new HashMap<String, List<String>>();
List<String> johnWayneGroups = new ArrayList<String>();
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);
}
* @return the string
*/
private String createItemInAuthority(String vcsid, String authRefName, String shortId,
- Map itemFieldProperties, Map itemRepeatableFieldProperties) {
+ Map itemFieldProperties, List<PersonTermGroup> terms, Map itemRepeatableFieldProperties) {
final String testName = "createItemInAuthority";
if (logger.isDebugEnabled()) {
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadOut multipart =
PersonAuthorityClientUtils.createPersonInstance(vcsid, null /*authRefName*/, itemFieldProperties,
- itemRepeatableFieldProperties, client.getItemCommonPartName());
+ terms, itemRepeatableFieldProperties, client.getItemCommonPartName());
setupCreate();
ClientResponse<Response> res = client.createItem(vcsid, multipart);
String newID = null;
// Create the payload to be included in the body of the request
String shortId = "7-Eleven";
Map<String, String> fieldProperties = new HashMap<String, String>();
- fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
- fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME, shortId);
- fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
- fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, shortId);
fieldProperties.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
+
+ List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
+ 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
}
}
}
-
- /**
- * Verify item display name.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", groups = {"update"},
- dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
- public void verifyItemDisplayName(String testName) throws Exception {
- // Perform setup.
- setupUpdate();
-
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
- PoxPayloadIn input = null;
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- try {
- 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.
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", groups = {"update"},
- dependsOnMethods = {"verifyItemDisplayName"})
+ @Test(dataProvider = "testName", groups = {"update"})
public void verifyIllegalItemDisplayName(String testName) throws Exception {
// Perform setup for read.
setupRead();
}
}
//
- // Make an invalid UPDATE request -i.e., if we don't want the display name computed, then
- // we need to supply one.
+ // Make an invalid UPDATE request, without a display name
//
PersonsCommon person = (PersonsCommon) extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(person);
- // Try to Update with computed false and no displayName
- person.setDisplayNameComputed(false);
- person.setDisplayName(null);
+ // Try to Update with no displayName
+ List<PersonTermGroup> johnWayneTerms = new ArrayList<PersonTermGroup>();
+ 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<PersonTermGroup> 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);
// Update the contents of this resource.
person.setCsid(null);
- person.setForeName("updated-" + person.getForeName());
+ PersonTermGroupList termList = person.getPersonTermGroupList();
+ Assert.assertNotNull(termList);
+ List<PersonTermGroup> 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,
}
// Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedPerson.getForeName(),
- person.getForeName(),
+ PersonTermGroupList updatedTermList = person.getPersonTermGroupList();
+ Assert.assertNotNull(updatedTermList);
+ List<PersonTermGroup> 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.");
}
protected PoxPayloadOut createNonExistenceItemInstance(String commonPartName, String identifier) {
Map<String, String> nonexMap = new HashMap<String, String>();
nonexMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, "nonEX");
- nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
- nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
nonexMap.put(PersonJAXBSchema.GENDER, "male");
+
+ List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
+ PersonTermGroup term = new PersonTermGroup();
+ term.setForeName("John");
+ term.setSurName("Wayne");
+ terms.add(term);
+
Map<String, List<String>> nonexRepeatablesMap = new HashMap<String, List<String>>();
PoxPayloadOut result =
PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
null, //PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
- nonexMap, nonexRepeatablesMap, commonPartName);
+ nonexMap, terms, nonexRepeatablesMap, commonPartName);
return result;
}