]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5135,CSPACE-5155,CSPACE-5156: All but one Organization test passes after term...
authorAron Roberts <aron@socrates.berkeley.edu>
Fri, 4 May 2012 23:48:04 +0000 (16:48 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Fri, 4 May 2012 23:48:04 +0000 (16:48 -0700)
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java

index 7d0bbedf957469ed3a4bada7f384a41dc0f705e6..008be55b6b899b70ed65cf7ba5a4ba415dc5ff55 100644 (file)
             <service:col>inauthority</service:col>
           </service:field>
           <service:field>
-            <service:table>organizations_common</service:table>
-            <service:col>displayname</service:col>
+            <service:table>orgtermgroup</service:table>
+            <service:col>termdisplayname</service:col>
           </service:field>
           <service:field>
             <service:table>organizations_common</service:table>
index ebeeb796ed3b5f1edc3b21ccb00782e7e5267955..79f5f5f0bc7b18916a4d50725317c427e5e74f97 100644 (file)
@@ -36,7 +36,7 @@ public class OrgAuthorityClient extends AuthorityWithContactsClientImpl<Organiza
        public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;       
        public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
        public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
-    public static final String TERM_INFO_GROUP_XPATH_BASE = "organizationTermGroup";
+    public static final String TERM_INFO_GROUP_XPATH_BASE = "orgTermGroupList";
        //
        // Subitem constants
        //
index 651a97fbe51859d073a883a3bbabe6eed3bbaa35..38a8e6cf7c5e86a2c3960d7bd3408d5ee7d8f7c9 100644 (file)
@@ -1,14 +1,4 @@
 /**    \r
- * OrgAuthorityClientUtils.java\r
- *\r
- * {Purpose of This Class}\r
- *\r
- * {Other Notes Relating to This Class (Optional)}\r
- *\r
- * $LastChangedBy: $\r
- * $LastChangedRevision$\r
- * $LastChangedDate$\r
- *\r
  * This document is a part of the source code and related artifacts\r
  * for CollectionSpace, an open source collections management system\r
  * for museums and related institutions:\r
@@ -16,7 +6,7 @@
  * http://www.collectionspace.org\r
  * http://wiki.collectionspace.org\r
  *\r
- * Copyright © 2009 {Contributing Institution}\r
+ * Copyright © 2009 University of California, Berkeley\r
  *\r
  * Licensed under the Educational Community License (ECL), Version 2.0.\r
  * You may not use this file except in compliance with this License.\r
@@ -36,7 +26,6 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;\r
 \r
 import org.collectionspace.services.OrganizationJAXBSchema;\r
-import org.collectionspace.services.client.test.BaseServiceTest;\r
 import org.collectionspace.services.client.test.ServiceRequestType;\r
 import org.collectionspace.services.organization.ContactNameList;\r
 import org.collectionspace.services.organization.FunctionList;\r
@@ -46,15 +35,12 @@ import org.collectionspace.services.organization.OrganizationsCommon;
 import org.collectionspace.services.organization.OrgauthoritiesCommon;\r
 import org.collectionspace.services.organization.OrgTermGroup;\r
 import org.collectionspace.services.organization.OrgTermGroupList;\r
-import org.collectionspace.services.person.PersonauthoritiesCommon;\r
-import org.collectionspace.services.person.PersonsCommon;\r
 import org.jboss.resteasy.client.ClientResponse;\r
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
 /**\r
- * The Class OrgAuthorityClientUtils.\r
+ * OrgAuthorityClientUtils.\r
  */\r
 public class OrgAuthorityClientUtils {\r
     \r
@@ -168,13 +154,17 @@ public class OrgAuthorityClientUtils {
      * @return the string\r
      */\r
     public static String createItemInAuthority( String inAuthority,\r
-               String orgAuthorityRefName, List<OrgTermGroup> terms, Map<String, String> orgInfo,\r
+               String orgAuthorityRefName, Map<String, String> orgInfo, List<OrgTermGroup> terms,\r
                 Map<String, List<String>> orgRepeatablesInfo, OrgAuthorityClient 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
-        String displayName = createDisplayName(orgInfo);\r
+\r
+        String displayName = "";\r
+        if (terms !=null && terms.size() > 0) {\r
+            displayName = terms.get(0).getTermDisplayName();\r
+        }\r
 \r
        if(logger.isDebugEnabled()){\r
                logger.debug("Import: Create Item: \""+displayName\r
@@ -247,9 +237,11 @@ public class OrgAuthorityClientUtils {
                String value = null;\r
         List<String> values = null;\r
         \r
+        // Set values in the Term Information Group\r
+        OrgTermGroupList termList = new OrgTermGroupList();\r
+        termList.getOrgTermGroup().addAll(terms);\r
+        organization.setOrgTermGroupList(termList);\r
         \r
-               // Handle terms here\r
-\r
         if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.CONTACT_NAMES))!=null) {\r
                 ContactNameList contactsList = new ContactNameList();\r
                 List<String> contactNames = contactsList.getContactName();\r
@@ -394,20 +386,13 @@ public class OrgAuthorityClientUtils {
                return newStr.toString();\r
     }\r
 \r
-    public static String createDisplayName(Map<String, String> orgInfo) {\r
-        String displayName = orgInfo.get(OrganizationJAXBSchema.DISPLAY_NAME);\r
-       String displayNameComputedStr = orgInfo.get(OrganizationJAXBSchema.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 = prepareDefaultDisplayName(\r
-                orgInfo.get(OrganizationJAXBSchema.SHORT_NAME ),\r
-                orgInfo.get(OrganizationJAXBSchema.FOUNDING_PLACE ));\r
-       }\r
-        return displayName;\r
+    public static List<OrgTermGroup> getTermGroupInstance(String identifier) {\r
+        List<OrgTermGroup> terms = new ArrayList<OrgTermGroup>();\r
+        OrgTermGroup term = new OrgTermGroup();\r
+        term.setTermDisplayName(identifier);\r
+        term.setTermName(identifier);\r
+        terms.add(term);\r
+        return terms;\r
     }\r
     \r
 }\r
index 2125087e28da28ec2dd8ca30c9caf149b1e098bd..7e5f25e5802cf06a9c3731deb95be4e73aabb932 100644 (file)
@@ -40,9 +40,8 @@ import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.organization.MainBodyGroup;
-import org.collectionspace.services.organization.MainBodyGroupList;
 import org.collectionspace.services.organization.OrganizationsCommon;
+import org.collectionspace.services.organization.OrgTermGroup;
 import org.collectionspace.services.person.PersonTermGroup;
 
 import org.jboss.resteasy.client.ClientResponse;
@@ -194,22 +193,14 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest<AbstractCommonList
         testOrgContactNames.add(organizationContactPersonRefName1);
         testOrgContactNames.add(organizationContactPersonRefName2);
         testOrgRepeatablesMap.put(OrganizationJAXBSchema.CONTACT_NAMES, testOrgContactNames);
-        List<String> testOrgSubBodies = new ArrayList<String>();
-        testOrgSubBodies.add(subBodyRefName);
-        testOrgRepeatablesMap.put(OrganizationJAXBSchema.SUB_BODIES, testOrgSubBodies);
-
-        MainBodyGroupList mainBodyList = new MainBodyGroupList();
-        List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
-        MainBodyGroup mainBodyGroup = new MainBodyGroup();
-        mainBodyGroup.setShortName("Test Organization-" + shortId);
-        mainBodyGroup.setLongName("Test Organization Name");
-        mainBodyGroups.add(mainBodyGroup);
+        
+        List<OrgTermGroup> terms = OrgAuthorityClientUtils.getTermGroupInstance("Org name");
 
         // Finishing creating the new Organization item, then
         // submit the request to the service and store the response.
         knownItemResourceId = OrgAuthorityClientUtils.createItemInAuthority(
                        knownResourceId, knownResourceRefName, testOrgMap,
-                        testOrgRepeatablesMap, mainBodyList, orgAuthClient);
+                        terms, testOrgRepeatablesMap, orgAuthClient);
 
         // Store the IDs from every item created by tests,
         // so they can be deleted after tests have been run.
@@ -241,13 +232,13 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest<AbstractCommonList
         
         // Create temporary Person resources, and their corresponding refNames
         // by which they can be identified.
-               String csid = createPerson("Charlie", "Orgcontact", "charlieOrgcontact", null ); // authRefName);
+               String csid = createPerson(personAuthCSID, "Charlie", "Orgcontact", "charlieOrgcontact", null ); // authRefName);
         personIdsCreated.add(csid);
         organizationContactPersonRefName1 = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
 
         // Create temporary Person resources, and their corresponding refNames
         // by which they can be identified.
-               csid = createPerson("Chelsie", "Contact", "chelsieContact", null ); // authRefName);
+               csid = createPerson(personAuthCSID, "Chelsie", "Contact", "chelsieContact", null ); // authRefName);
         personIdsCreated.add(csid);
         organizationContactPersonRefName2 = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
     }
@@ -261,21 +252,21 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest<AbstractCommonList
      * @param authRefName
      * @return the string
      */
-    protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+    protected String createPerson(String personAuthCSID, String firstName, String surName, String shortId, String authRefName ) {
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         Map<String, String> personInfo = new HashMap<String,String>();
-        personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
-        personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
         personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
         List<PersonTermGroup> personTerms = new ArrayList<PersonTermGroup>();
         PersonTermGroup term = new PersonTermGroup();
         String termName = firstName + " " + surName;
         term.setTermDisplayName(termName);
         term.setTermName(termName);
+        term.setForeName(firstName);
+        term.setSurName(surName);
         personTerms.add(term);
        PoxPayloadOut multipart = 
            PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
-                       authRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
+                       null, personInfo, personTerms, personAuthClient.getItemCommonPartName());
         
        String result = null;
        ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
index fde3af062214f923b4a76e510ae039a2743e27a1..aa6b2916288673a7a82a8a355f37a9f4a8327660 100644 (file)
@@ -44,10 +44,10 @@ import org.collectionspace.services.contact.ContactsCommon;
 import org.collectionspace.services.client.OrgAuthorityClient;
 import org.collectionspace.services.client.OrgAuthorityClientUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.organization.MainBodyGroup;
-import org.collectionspace.services.organization.MainBodyGroupList;
 import org.collectionspace.services.organization.OrgauthoritiesCommon;
 import org.collectionspace.services.organization.OrganizationsCommon;
+import org.collectionspace.services.organization.OrgTermGroup;
+import org.collectionspace.services.organization.OrgTermGroupList;
 
 import org.jboss.resteasy.client.ClientResponse;
 
@@ -81,11 +81,12 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
     protected String getServiceName() {
         return OrgAuthorityClient.SERVICE_NAME;
     }
-    /** The test organization shortname. */
-    private final String TEST_ORG_SHORTNAME = "Test Org";
-    
-    /** The test organization founding place. */
+    private final String TEST_SHORT_ID = "TestOrg";
+    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";
+    // FIXME: Change this to a structured date once this field changes in the schema.
+    private final String TEST_ORG_FOUNDING_DATE = "May 26, 1907";
     
     private String knownItemResourceShortIdentifer = null;
     
@@ -121,15 +122,21 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
     @Override
     protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
         String headerLabel = new OrgAuthorityClient().getItemCommonPartName();
-        String shortId = "testOrg";
+        
+        String shortId = TEST_SHORT_ID;
         Map<String, String> testOrgMap = new HashMap<String, String>();
         testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
-        testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, TEST_ORG_SHORTNAME);
-        testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization");
-        testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "May 26, 1907");
+        testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, TEST_ORG_FOUNDING_DATE);
         testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, TEST_ORG_FOUNDING_PLACE);
-
-        return OrgAuthorityClientUtils.createOrganizationInstance(identifier, testOrgMap, headerLabel);
+        
+        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);
+
+        return OrgAuthorityClientUtils.createOrganizationInstance(identifier, testOrgMap, terms, headerLabel);
     }
 
     /**
@@ -148,29 +155,28 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
 
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
-        String shortId = "testOrg";
+        
+        String shortId = TEST_SHORT_ID;
         Map<String, String> testOrgMap = new HashMap<String, String>();
         testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
-        testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, TEST_ORG_SHORTNAME);
-        testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization");
-        testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "May 26, 1907");
+        testOrgMap.put(OrganizationJAXBSchema.FOUNDING_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");
         testOrgContactNames.add("sally@example.org");
         testOrgRepeatablesMap.put(OrganizationJAXBSchema.CONTACT_NAMES, testOrgContactNames);
 
-        MainBodyGroupList mainBodyList = new MainBodyGroupList();
-        List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
-        MainBodyGroup mainBodyGroup = new MainBodyGroup();
-        mainBodyGroup.setShortName(TEST_ORG_SHORTNAME);
-        mainBodyGroup.setLongName("The real official test organization");
-        mainBodyGroups.add(mainBodyGroup);
-
         String newID = OrgAuthorityClientUtils.createItemInAuthority(
-                vcsid, authRefName, testOrgMap, testOrgRepeatablesMap, mainBodyList, client);
+                vcsid, authRefName, testOrgMap, terms, testOrgRepeatablesMap, client);
 
         // Store the ID returned from the first item resource created
         // for additional tests below.
@@ -442,139 +448,14 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
         Assert.assertTrue(contactNames.size() > 0);
         Assert.assertNotNull(contactNames.get(0));
     }
-
-    /**
-     * Verify item display name.
-     *
-     * @param testName the test name
-     * @throws Exception the exception
-     */
-    @Test(dataProvider = "testName",
-               dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
-    public void verifyItemDisplayName(String testName) throws Exception {
-        // Perform setup.
-        setupRead();
-        //
-        // First, read our known resource.
-        //
-        OrgAuthorityClient client = new OrgAuthorityClient();
-        PoxPayloadIn input = null;
-        ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
-        try {
-            assertStatusCode(res, testName);
-            // Check whether organization has expected displayName.
-            input = new PoxPayloadIn(res.getEntity());
-            Assert.assertNotNull(input);
-        } finally {
-               if (res != null) {
-                res.releaseConnection();
-            }
-        }
-
-        // Check whether organization has expected displayName.
-        OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
-                client.getItemCommonPartName(), OrganizationsCommon.class);
-        Assert.assertNotNull(organization);
-        String displayName = organization.getDisplayName();
-        // Make sure displayName matches computed form
-        String expectedDisplayName =
-                OrgAuthorityClientUtils.prepareDefaultDisplayName(
-                TEST_ORG_SHORTNAME, TEST_ORG_FOUNDING_PLACE);
-        Assert.assertNotNull(displayName, expectedDisplayName);
-
-        // Update the shortName and verify the computed name is updated.
-        organization.setCsid(null);
-        organization.setDisplayNameComputed(true);
-
-        MainBodyGroupList mainBodyList = organization.getMainBodyGroupList();
-        List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
-        MainBodyGroup mainBodyGroup = new MainBodyGroup();
-        String updatedShortName = "updated-" + TEST_ORG_SHORTNAME;
-        mainBodyGroup.setShortName(updatedShortName);
-        mainBodyGroups.clear(); //clear all the elements and do a sparse update
-        mainBodyGroups.add(mainBodyGroup);
-        organization.setMainBodyGroupList(mainBodyList);
-
-        expectedDisplayName =
-                OrgAuthorityClientUtils.prepareDefaultDisplayName(
-                updatedShortName, TEST_ORG_FOUNDING_PLACE);
-        //
-        // Next, submit the updated resource to the service and store the response.
-        //
-        setupUpdate();
-        PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
-        PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), organization);
-        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();
-            }
-        }
-        //
-        // Now verify the update was correct.
-        //
-        OrganizationsCommon updatedOrganization =
-                (OrganizationsCommon) extractPart(input,
-                client.getItemCommonPartName(), OrganizationsCommon.class);
-        Assert.assertNotNull(updatedOrganization);
-
-        // Verify that the updated resource received the correct data.
-        mainBodyList = organization.getMainBodyGroupList();
-        Assert.assertNotNull(mainBodyList);
-        Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
-        Assert.assertEquals(updatedOrganization.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
-                updatedShortName, "Updated ShortName in Organization did not match submitted data.");
-
-        // Verify that the updated resource computes the right displayName.
-        Assert.assertEquals(updatedOrganization.getDisplayName(), expectedDisplayName,
-                "Updated ShortName in Organization not reflected in computed DisplayName.");
-        //
-        // Now Update the displayName, not computed and verify the computed name is overriden.
-        //
-        organization.setDisplayNameComputed(false);
-        expectedDisplayName = "TestName";
-        organization.setDisplayName(expectedDisplayName);
-
-        // Submit the updated resource to the service and store the response.
-        output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
-        commonPart = output.addPart(client.getItemCommonPartName(), organization);
-        res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        input = null;
-        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();
-            }
-        }
-        updatedOrganization =
-                (OrganizationsCommon) extractPart(input,
-                client.getItemCommonPartName(), OrganizationsCommon.class);
-        Assert.assertNotNull(updatedOrganization);
-
-        // Verify that the updated resource received the correct data.
-        Assert.assertEquals(updatedOrganization.isDisplayNameComputed(), false,
-                "Updated displayNameComputed in Organization did not match submitted data.");
-        // Verify that the updated resource computes the right displayName.
-        Assert.assertEquals(updatedOrganization.getDisplayName(),
-                expectedDisplayName,
-                "Updated DisplayName (not computed) in Organization not stored.");
-    }
-
+    
     /**
      * Verify illegal item display name.
      *
      * @param testName the test name
      * @throws Exception the exception
      */
-    @Test(dataProvider = "testName",
-               dependsOnMethods = {"verifyItemDisplayName"})
+    @Test(dataProvider = "testName")
     public void verifyIllegalItemDisplayName(String testName) throws Exception {
         // Perform setup for read.
         setupRead();
@@ -596,11 +477,17 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
                 res.releaseConnection();
             }
         }
+        
         //
-        // Try to Update with 'displayNameComputed' flag set to false and no displayName
+        // Make an invalid UPDATE request, without a display name
         //
-        organization.setDisplayNameComputed(false);
-        organization.setDisplayName(null);
+        OrgTermGroupList termList = organization.getOrgTermGroupList();
+        Assert.assertNotNull(termList);
+        List<OrgTermGroup> terms = termList.getOrgTermGroup();
+        Assert.assertNotNull(terms);
+        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.
@@ -1185,27 +1072,39 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
 
        @Override
        protected OrganizationsCommon updateItemInstance(OrganizationsCommon organizationsCommon) {
-               OrganizationsCommon result = organizationsCommon; //new OrganizationsCommon();
-               
-        MainBodyGroupList mainBodyList = organizationsCommon.getMainBodyGroupList();
-        Assert.assertNotNull(mainBodyList);
-        List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
-        Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
-        String updatedShortName = "updated-" + mainBodyGroups.get(0).getShortName();
-        mainBodyGroups.get(0).setShortName(updatedShortName);
-        
-        return result;
+            
+           OrganizationsCommon result = organizationsCommon;
+                
+            OrgTermGroupList termList = result.getOrgTermGroupList();
+            Assert.assertNotNull(termList);
+            List<OrgTermGroup> terms = termList.getOrgTermGroup();
+            Assert.assertNotNull(terms);
+            Assert.assertTrue(terms.size() > 0);
+            terms.get(0).setTermDisplayName("updated-" + terms.get(0).getTermDisplayName());
+            terms.get(0).setTermName("updated-" + terms.get(0).getTermName());
+       
+            return result;
        }
 
        @Override
        protected void compareUpdatedItemInstances(OrganizationsCommon original,
                        OrganizationsCommon updated) throws Exception {
-               MainBodyGroupList mainBodyList = original.getMainBodyGroupList();
-        Assert.assertNotNull(mainBodyList);
-        Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
-        Assert.assertEquals(updated.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
-                original.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
-                "Short name in updated Organization did not match submitted data.");
+            
+            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.");
        }
 
        @Override
@@ -1234,11 +1133,10 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
                String identifier) {
         Map<String, String> nonexOrgMap = new HashMap<String, String>();
         nonexOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, "nonExistent");
-        nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent");
         PoxPayloadOut result =
                 OrgAuthorityClientUtils.createOrganizationInstance(
                 knownResourceRefName,
-                nonexOrgMap, commonPartName);
+                nonexOrgMap, OrgAuthorityClientUtils.getTermGroupInstance(TEST_ORG_NAME), commonPartName);
         return result;
     }
 
@@ -1260,4 +1158,5 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
                        original.getDisplayName(),
                 "Display name in updated object did not match submitted data.");
        }
+
 }
index 28e48a7c7b4198403b8584105cd10b538b4f1c3a..80e070aa6f28daf01c30581855c7754e737855e4 100644 (file)
@@ -12,9 +12,7 @@ import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
 public interface OrganizationJAXBSchema extends AuthorityItemJAXBSchema {\r
 \r
     final static String ORGANIZATIONS_COMMON = "organizations_common";\r
-    final static String MAIN_BODY_GROUP_LIST = "mainBodyGroupList";\r
-    final static String LONG_NAME = "longName";\r
-    final static String SHORT_NAME = "shortName";\r
+    final static String TERM_NAME = "shortName";\r
     final static String NAME_ADDITIONS = "nameAdditions";\r
     final static String CONTACT_NAMES = "contactNames";\r
     final static String FOUNDING_DATE = "foundingDate";\r
@@ -22,7 +20,6 @@ public interface OrganizationJAXBSchema extends AuthorityItemJAXBSchema {
     final static String FOUNDING_PLACE = "foundingPlace";\r
     final static String GROUPS = "groups";\r
     final static String FUNCTIONS = "functions";\r
-    final static String SUB_BODIES = "subBodies";\r
     final static String HISTORY_NOTES = "historyNotes";\r
 }\r
 \r
index a1f5a1f53933d9ca32167a7d4b28c8f446f02a62..6507fbece2785c569ed70e505edc7f1c4f01913a 100644 (file)
  */\r
 package org.collectionspace.services.client;\r
 \r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
+import java.util.*;\r
 \r
 import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.MultivaluedMap;\r
@@ -173,6 +169,9 @@ public class PersonAuthorityClientUtils {
                String headerLabel){\r
         final Map<String, List<String>> EMPTY_PERSON_REPEATABLES_INFO =\r
                 new HashMap<String, List<String>>();\r
+        if (terms == null || terms.size() == 0) {\r
+            terms = getTermGroupInstance(getGeneratedIdentifier());\r
+        }\r
         return createPersonInstance(inAuthority, null /*personAuthRefName*/,\r
                 personInfo, terms, EMPTY_PERSON_REPEATABLES_INFO, headerLabel);\r
     }\r
@@ -446,6 +445,17 @@ public class PersonAuthorityClientUtils {
                return newStr.toString();\r
     }\r
     \r
-\r
+    public static List<PersonTermGroup> getTermGroupInstance(String identifier) {\r
+        List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();\r
+        PersonTermGroup term = new PersonTermGroup();\r
+        term.setTermDisplayName(identifier);\r
+        term.setTermName(identifier);\r
+        terms.add(term);\r
+        return terms;\r
+    }\r
+    \r
+    private static String getGeneratedIdentifier() {\r
+        return "id" + new Date().getTime(); \r
+   }\r
 \r
 }\r
index 5f234d5a8cce48f8ef5ff6e651dc729948f13046..61f815534e0c35bddc767aa8f3abb8c24819667d 100644 (file)
@@ -46,7 +46,6 @@ import org.collectionspace.services.client.PersonAuthorityClientUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.PersonJAXBSchema;
 import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.person.PersonauthoritiesCommon;
 import org.collectionspace.services.person.PersonTermGroup;
 import org.collectionspace.services.person.PersonTermGroupList;
@@ -627,7 +626,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
         }
     }
     
-    // FIXME: This test depends on server-side validation logic to require
+    // Note: 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.
 
@@ -673,6 +672,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
         Assert.assertNotNull(termList);
         List<PersonTermGroup> terms = termList.getPersonTermGroup();
         Assert.assertNotNull(terms);
+        Assert.assertTrue(terms.size() > 0);
         terms.get(0).setTermDisplayName(null);
         terms.get(0).setTermName(null);
 
@@ -1007,6 +1007,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
         Assert.assertNotNull(termList);
         List<PersonTermGroup> terms = termList.getPersonTermGroup();
         Assert.assertNotNull(terms);
+        Assert.assertTrue(terms.size() > 0);
         String foreName = terms.get(0).getForeName();
         String updatedForeName = "updated-" + foreName;
         terms.get(0).setForeName(updatedForeName);