]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6937-A: Additional authority tests recfactoring.
authorremillet <remillet@yahoo.com>
Wed, 27 Apr 2016 03:37:18 +0000 (20:37 -0700)
committerremillet <remillet@yahoo.com>
Wed, 27 Apr 2016 03:37:18 +0000 (20:37 -0700)
15 files changed:
services/citation/client/src/test/java/org/collectionspace/services/client/test/CitationAuthorityServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java
services/concept/client/src/test/java/org/collectionspace/services/client/test/ConceptAuthorityServiceTest.java
services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClientUtils.java
services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java
services/material/client/src/test/java/org/collectionspace/services/client/test/MaterialAuthorityServiceTest.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.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
services/place/client/src/test/java/org/collectionspace/services/client/test/PlaceAuthorityServiceTest.java
services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java
services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java
services/work/client/src/test/java/org/collectionspace/services/client/test/WorkAuthorityServiceTest.java

index a20a9c81905e1bdbb00c49aaf6f77709898e9467..d9b7c60e30b11c87f74fcd1589388cf0da389f77 100644 (file)
@@ -37,10 +37,9 @@ import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.CitationAuthorityClient;
 import org.collectionspace.services.client.CitationAuthorityClientUtils;
 import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
+
 import org.dom4j.DocumentException;
-import org.jboss.resteasy.client.ClientResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -59,16 +58,19 @@ public class CitationAuthorityServiceTest extends AbstractAuthorityServiceTest<C
     /**
      * The logger.
      */
-    private final String CLASS_NAME = CitationAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(CitationAuthorityServiceTest.class);
-    private final static String CURRENT_DATE_UTC =
-            GregorianCalendarDateTimeUtils.currentDateUTC();
+    
     // Instance variables specific to this test.
     final String TEST_NAME = "Citation 1";
-    final String TEST_SHORTID = "citation1";
     final String TEST_SCOPE_NOTE = "A representative citation";
-    // TODO Make status type be a controlled vocab term.
     final String TEST_STATUS = "Approved";
+    
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    CitationAuthorityServiceTest() {
+       TEST_SHORTID = "citation1";
+    }
 
     @Override
     public String getServicePathComponent() {
@@ -105,14 +107,14 @@ public class CitationAuthorityServiceTest extends AbstractAuthorityServiceTest<C
      * @return the string
      */
     @Override
-    protected String createItemInAuthority(AuthorityClient client, String authorityId) {
+    protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
 
         final String testName = "createItemInAuthority(" + authorityId + ")";
         if (logger.isDebugEnabled()) {
             logger.debug(testName);
         }
 
-        String commonPartXML = createCommonPartXMLForItem(TEST_SHORTID, TEST_NAME);
+        String commonPartXML = createCommonPartXMLForItem(shortId, TEST_NAME);
 
         String newID;
         try {
@@ -127,7 +129,7 @@ public class CitationAuthorityServiceTest extends AbstractAuthorityServiceTest<C
         // Store the ID returned from the first item resource created
         // for additional tests below.
         if (knownItemResourceId == null) {
-            setKnownItemResource(newID, TEST_SHORTID);
+            setKnownItemResource(newID, shortId);
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownItemResourceId=" + newID);
             }
index 62e4d2e346015f92cb69cd150c44abb98796f779..0e6cb273caac4e0d00230118d0c8c702b24dabb3 100644 (file)
@@ -48,18 +48,58 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
     protected String knownItemResourceId = null;
     protected String knownItemResourceShortIdentifer = null;    
     protected int nItemsToCreateInList = 5;
-               
-       public abstract void authorityTests(String testName);
-    protected abstract String createItemInAuthority(AuthorityClient client, String authorityId);
+    protected String TEST_SHORTID = "johnWayneActor";
+
+    /*
+     * Abstract methods that subclasses must override/implement
+     */
+    
+    /**
+     * 
+     * @param testName
+     */
+    public abstract void authorityTests(String testName);
+       
+       /**
+        * 
+        * @param client
+        * @param vcsid
+        * @return
+        */
+       abstract protected String createItemInAuthority(AuthorityClient client, String vcsid, String shortId);
+       
+    
+    /**
+     * 
+     * @param authorityItem
+     * @return
+     */
     protected abstract AUTHORITY_ITEM_TYPE updateItemInstance(final AUTHORITY_ITEM_TYPE authorityItem);    
+    
+    /**
+     * 
+     * @param original
+     * @param updated
+     * @throws Exception
+     */
     protected abstract void compareUpdatedItemInstances(AUTHORITY_ITEM_TYPE original, AUTHORITY_ITEM_TYPE updated) throws Exception;
     
+    /**
+     * 
+     * @param id
+     * @param shortIdentifer
+     */
     protected void setKnownItemResource(String id, String shortIdentifer ) {
        knownItemResourceId = id;
        knownItemResourceShortIdentifer = shortIdentifer;
     }
 
+    /**
+     * 
+     * @param id
+     * @param shortIdentifer
+     * @param refName
+     */
     protected void setKnownResource(String id, String shortIdentifer,
             String refName) {
         knownResourceId = id;
@@ -67,13 +107,22 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         knownResourceRefName = refName;
     }
 
+    /**
+     * 
+     * @return
+     */
        protected String getSASAuthorityIdentifier() {
                // TODO Auto-generated method stub
                return this.getKnowResourceIdentifier() + this.SAS_IDENTIFIER;
        }
     
+       /**
+        * 
+        * @param shortId
+        * @return
+        */
        protected String getUrnIdentifier(String shortId) {
-               return String.format("urn:cspace:name:(%s)", shortId);
+               return String.format("urn:cspace:name(%s)", shortId);
        }
        
     /**
@@ -230,7 +279,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         // Perform setup.
         setupCreate();
 
-        String newID = createItemInAuthority((AuthorityClient) getClientInstance(), knownResourceId);
+        String newID = createItemInAuthority((AuthorityClient) getClientInstance(), knownResourceId, getTestAuthorityItemShortId());
 
         // Store the ID returned from the first item resource created
         // for additional tests below.
@@ -247,13 +296,11 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
      */
     @Test(dataProvider = "testName", dependsOnMethods = {"createSASItem", "CRUDTests"})
     public void syncWithSAS(String testName) {
-        setupSync();
-       AuthorityClient client = (AuthorityClient) this.getClientInstance();
-
         //
         // First create an empty instance of the authority, so we can sync items with it.  We're
        // using the short ID of the SAS authority.  The short ID of the local and the SAS will (must) be the same.
         //
+       AuthorityClient client = (AuthorityClient) this.getClientInstance();
        String localAuthorityId = null;
         try {
                        localAuthorityId = createResource(client, testName, getSASAuthorityIdentifier());
@@ -264,6 +311,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
        //
        // Now we can try to sync the SAS authority with the local one we just created.
        //
+        setupSync();
        Response response = client.syncByName(getSASAuthorityIdentifier()); // Notice we're using the Short ID (short ID is the same on the local and SAS)
         try {
                int statusCode = response.getStatus();
@@ -307,7 +355,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         // Perform setup.
         setupCreate();
 
-        String shortId = "SassyActor" + System.currentTimeMillis() + random.nextInt();; // short ID needs to be unique
+        String shortId = "SassyActor" + System.currentTimeMillis() + Math.abs(random.nextInt()); // short ID needs to be unique
         String newID = createItemInAuthority(getSASClientInstance(), knownSASAuthorityResourceId, shortId);
 
                // Store the ID returned from the first item resource created
@@ -331,7 +379,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
     public void createItemList(String testName) throws Exception {
        knownAuthorityWithItems = createResource(testName, READITEMS_SHORT_IDENTIFIER);
         for (int j = 0; j < nItemsToCreateInList; j++) {
-               createItemInAuthority((AuthorityClient) getClientInstance(), knownAuthorityWithItems);
+               createItemInAuthority((AuthorityClient) getClientInstance(), knownAuthorityWithItems, this.getTestAuthorityItemShortId(true));
         }
     }
 
@@ -379,8 +427,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
        public AUTHORITY_ITEM_TYPE extractItemCommonPartValue(Response res) throws Exception {
                AUTHORITY_ITEM_TYPE result = null;
                
-        AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
-                       this.getClientInstance();
+        AuthorityClient client = (AuthorityClient) getClientInstance();
                PayloadInputPart payloadInputPart = extractPart(res, client.getItemCommonPartName());
                if (payloadInputPart != null) {
                        result = (AUTHORITY_ITEM_TYPE) payloadInputPart.getBody();
@@ -398,8 +445,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         setupReadNonExistent();
 
         // Submit the request to the service and store the response.
-        AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
-                       this.getClientInstance();
+        AuthorityClient client = (AuthorityClient) getClientInstance();
         Response res = client.readItem(knownResourceId, NON_EXISTENT_ID);
         try {
                int statusCode = res.getStatus();
@@ -424,7 +470,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         setupRead();
 
         // Submit the request to the service and store the response.
-        AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
+        AuthorityClient client = (AuthorityClient) getClientInstance();
         Response res = client.readItem(knownResourceId, knownItemResourceId);
         try {
                int statusCode = res.getStatus();
@@ -456,8 +502,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         setupDelete();
 
         // Submit the request to the service and store the response.
-        AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
-                       this.getClientInstance();
+        AuthorityClient client = (AuthorityClient) getClientInstance();
         Response res = client.deleteItem(knownResourceId, knownItemResourceId);
         int statusCode;
         try {
@@ -481,7 +526,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         setupReadList();
 
         // Submit the request to the service and store the response.
-        AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
+        AuthorityClient client = (AuthorityClient) getClientInstance();
         Response res = null;
         if (vcsid != null) {
             res = client.readItemList(vcsid, null, null);
@@ -539,7 +584,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         setupDeleteNonExistent();
 
         // Submit the request to the service and store the response.
-        AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
+        AuthorityClient client = (AuthorityClient) getClientInstance();
         Response res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
         int statusCode;
         try {
@@ -565,7 +610,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
        public PoxPayloadOut createItemRequestTypeInstance(AUTHORITY_ITEM_TYPE itemTypeInstance) {
                PoxPayloadOut result = null;
                
-        AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
+        AuthorityClient client = (AuthorityClient) getClientInstance();
         PoxPayloadOut payloadOut = new PoxPayloadOut(this.getServicePathItemsComponent());
         PayloadOutputPart part = payloadOut.addPart(client.getItemCommonPartName(), itemTypeInstance);
         result = payloadOut;
@@ -755,5 +800,17 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         super.cleanUp(client);        
     }
     
-       abstract protected String createItemInAuthority(AuthorityClient client, String vcsid, String shortId);
+       protected String getTestAuthorityItemShortId() {
+               return getTestAuthorityItemShortId(false);
+       }
+
+       protected String getTestAuthorityItemShortId(boolean makeUnique) {
+               String result = TEST_SHORTID;
+               
+               if (makeUnique == true) {
+                       result = result + System.currentTimeMillis() + Math.abs(random.nextInt());
+               }
+               
+               return result;
+       }
 }
index 137713f71e118b8d9bf6bba70039cf9d53b8ca3e..0cab25e4540512c288797826b2a053dd199676e9 100644 (file)
@@ -447,7 +447,7 @@ public abstract class BaseServiceTest<CLT> {
      * Tests can override this method to customize their identifiers.
      */
     protected String createIdentifier() {
-        long identifier = System.currentTimeMillis() + random.nextInt();
+        long identifier = System.currentTimeMillis() + Math.abs(random.nextInt());
         return Long.toString(identifier);
     }
     
index 67b248259ce6fde3a842df7689ad7234f8d41c6c..7b7052307797e4e9b97bee4d2fd722598bc8354e 100644 (file)
@@ -34,14 +34,13 @@ import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.ConceptAuthorityClient;
 import org.collectionspace.services.client.ConceptAuthorityClientUtils;
 import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
 import org.collectionspace.services.concept.ConceptTermGroup;
 import org.collectionspace.services.concept.ConceptTermGroupList;
 import org.collectionspace.services.concept.ConceptauthoritiesCommon;
 import org.collectionspace.services.concept.ConceptsCommon;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.dom4j.DocumentException;
-import org.jboss.resteasy.client.ClientResponse;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -58,11 +57,15 @@ import org.testng.annotations.Test;
 public class ConceptAuthorityServiceTest extends AbstractAuthorityServiceTest<ConceptauthoritiesCommon, ConceptsCommon> {
 
        /** The logger. */
-    private final String CLASS_NAME = ConceptAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(ConceptAuthorityServiceTest.class);
-    private final static String CURRENT_DATE_UTC =
-        GregorianCalendarDateTimeUtils.currentDateUTC();
 
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    ConceptAuthorityServiceTest() {
+        TEST_SHORTID = "concept1";
+    }
+    
        @Override
        public String getServicePathComponent() {
                return ConceptAuthorityClient.SERVICE_PATH_COMPONENT;
@@ -80,7 +83,6 @@ public class ConceptAuthorityServiceTest extends AbstractAuthorityServiceTest<Co
     // Instance variables specific to this test.
     
     final String TEST_NAME = "Concept 1";
-    final String TEST_SHORTID = "concept1";
     final String TEST_SCOPE_NOTE = "Covers quite a bit";
     // TODO Make status type be a controlled vocab term.
     final String TEST_STATUS = "Approved";
@@ -108,14 +110,14 @@ public class ConceptAuthorityServiceTest extends AbstractAuthorityServiceTest<Co
      * @return the string
      */
        @Override
-       protected String createItemInAuthority(AuthorityClient client, String authorityId) {
+       protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
 
         final String testName = "createItemInAuthority("+authorityId+")";
         if(logger.isDebugEnabled()){
             logger.debug(testName);
         }
 
-        String commonPartXML = createCommonPartXMLForItem(TEST_SHORTID, TEST_NAME);
+        String commonPartXML = createCommonPartXMLForItem(shortId, TEST_NAME);
 
         String newID = null;
         try {
@@ -130,7 +132,7 @@ public class ConceptAuthorityServiceTest extends AbstractAuthorityServiceTest<Co
         // Store the ID returned from the first item resource created
         // for additional tests below.
         if (knownItemResourceId == null){
-               setKnownItemResource(newID, TEST_SHORTID);
+               setKnownItemResource(newID, shortId);
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownItemResourceId=" + newID);
             }
index 9b473f06b0f9134ee8bcb483cf5fa718fdbfdfeb..1af7856285b09c23338ed15225473bf408925f7a 100644 (file)
@@ -116,15 +116,13 @@ public class LocationAuthorityClientUtils {
      * @return the CSID of the new item
      */
     public static String createItemInAuthority(String vcsid, 
-               String locationAuthorityRefName, Map<String,String> locationMap,
-               List<LocTermGroup> terms, LocationAuthorityClient 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 locationAuthorityRefName,
+               Map<String,String> locationMap,
+               List<LocTermGroup> terms,
+               LocationAuthorityClient client ) {
         
         String displayName = "";
-        if ((terms !=null) && (! terms.isEmpty())) {
+        if (terms !=null && !terms.isEmpty()) {
             displayName = terms.get(0).getTermDisplayName();
         }
        
@@ -133,21 +131,22 @@ public class LocationAuthorityClientUtils {
                                +"\" in locationAuthority: \"" + vcsid +"\"");
        }
         
-       PoxPayloadOut multipart = 
-               createLocationInstance( locationAuthorityRefName,
+       PoxPayloadOut multipart = createLocationInstance( locationAuthorityRefName,
                        locationMap, terms, client.getItemCommonPartName() );
        String newID = null;
        Response res = client.createItem(vcsid, multipart);
         try {
+               int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
+               ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
                int statusCode = res.getStatus();
        
-               if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
+               if (!REQUEST_TYPE.isValidStatusCode(statusCode)) {
                        throw new RuntimeException("Could not create Item: \""
                                        +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)
                                        +"\" in locationAuthority: \"" + locationAuthorityRefName
                                        +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
                }
-               if(statusCode != EXPECTED_STATUS_CODE) {
+               if (statusCode != EXPECTED_STATUS_CODE) {
                        throw new RuntimeException("Unexpected Status when creating Item: \""
                                        +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)
                                        +"\" in locationAuthority: \"" + locationAuthorityRefName +"\", Status:"+ statusCode);
index db977fa906ac5cc302c891380758903781ec46dd..81a27275d42c497a889d7eff6f6bcfc90816119c 100644 (file)
@@ -60,11 +60,16 @@ import org.testng.annotations.Test;
 public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTest<LocationauthoritiesCommon, LocationsCommon> {
 
     /** The logger. */
-    private final String CLASS_NAME = LocationAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(LocationAuthorityServiceTest.class);
-    private final static String CURRENT_DATE_UTC =
-        GregorianCalendarDateTimeUtils.currentDateUTC();
+    private final static String CURRENT_DATE_UTC = GregorianCalendarDateTimeUtils.currentDateUTC();
 
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    LocationAuthorityServiceTest() {
+        TEST_SHORTID = "shelf1";
+    }
+    
        @Override
        public String getServicePathComponent() {
                return LocationAuthorityClient.SERVICE_PATH_COMPONENT;
@@ -82,7 +87,6 @@ public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTest<L
     // Instance variables specific to this test.
     
     final String TEST_NAME = "Shelf 1";
-    final String TEST_SHORTID = "shelf1";
     final String TEST_CONDITION_NOTE = "Basically clean";
     final String TEST_CONDITION_NOTE_DATE = CURRENT_DATE_UTC;
     final String TEST_SECURITY_NOTE = "Kind of safe";
@@ -95,7 +99,7 @@ public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTest<L
     
     /** The known resource id. */
     private String knownLocationTypeRefName = null;
-        
+
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
      */
@@ -109,6 +113,11 @@ public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTest<L
        return new LocationAuthorityClient(clientPropertiesFilename);
     }
     
+       @Override
+       protected String createItemInAuthority(AuthorityClient client, String vcsid, String shortId) {
+               return createItemInAuthority(client, vcsid, shortId, null/*refname*/);
+       }       
+    
     /**
      * Creates the item in authority.
      *
@@ -116,13 +125,13 @@ public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTest<L
      * @param authRefName the auth ref name
      * @return the string
      */
-    private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName) {
+    private String createItemInAuthority(AuthorityClient client, String vcsid, String shortId, String authRefName) {
         final String testName = "createItemInAuthority("+vcsid+","+authRefName+")";
 
         // Submit the request to the service and store the response.
         Map<String, String> shelf1Map = new HashMap<String,String>();
         // TODO Make loc type and status be controlled vocabs.
-        shelf1Map.put(LocationJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
+        shelf1Map.put(LocationJAXBSchema.SHORT_IDENTIFIER, shortId);
         shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE, TEST_CONDITION_NOTE);
         shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
         shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
@@ -144,7 +153,7 @@ public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTest<L
         // Store the ID returned from the first item resource created
         // for additional tests below.
         if (knownItemResourceId == null){
-               setKnownItemResource(newID, TEST_SHORTID);
+               setKnownItemResource(newID, shortId);
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownItemResourceId=" + newID);
             }
@@ -457,11 +466,6 @@ public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTest<L
        //
        // Authority item specific overrides
        //
-       
-       @Override
-       protected String createItemInAuthority(AuthorityClient client, String authorityId) {
-               return createItemInAuthority(client, authorityId, null /*refname*/);
-       }
 
        @Override
        protected LocationsCommon updateItemInstance(LocationsCommon locationsCommon) {
index b30fe5f1ec787432fc83287f8e41532e6aab86cf..e07f7b07663223464bcefdd79658b1135141bb7c 100644 (file)
@@ -58,9 +58,15 @@ import org.testng.annotations.Test;
 public class MaterialAuthorityServiceTest extends AbstractAuthorityServiceTest<MaterialauthoritiesCommon, MaterialsCommon> {
 
     /** The logger. */
-    private final String CLASS_NAME = MaterialAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(MaterialAuthorityServiceTest.class);
 
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    MaterialAuthorityServiceTest() {
+       TEST_SHORTID = "superglass";
+    }
+    
     @Override
     public String getServicePathComponent() {
         return MaterialAuthorityClient.SERVICE_PATH_COMPONENT;
@@ -75,22 +81,12 @@ public class MaterialAuthorityServiceTest extends AbstractAuthorityServiceTest<M
         return AuthorityClient.ITEMS;
     }   
     
-    // Instance variables specific to this test.
-    
-//    /** The SERVICE path component. */
-//    final String SERVICE_PATH_COMPONENT = "materialauthorities";
-//    
-//    /** The ITEM service path component. */
-//    final String ITEM_SERVICE_PATH_COMPONENT = "items";
-//    
-
     final String TEST_MATERIAL_TERM_DISPLAY_NAME = "SuperGlass 2";
     final String TEST_MATERIAL_TERM_NAME = "SuperGlass";
     final String TEST_MATERIAL_TERM_STATUS = "accepted";
     final String TEST_MATERIAL_TERM_SOURCE = "source";
     final String TEST_MATERIAL_TERM_SOURCE_DETAIL = "internal";
     final String TEST_MATERIAL_DESCRIPTION = "Really strong glass";
-    final String TEST_MATERIAL_SHORT_IDENTIFIER = "superglass";
     
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
@@ -105,6 +101,11 @@ public class MaterialAuthorityServiceTest extends AbstractAuthorityServiceTest<M
         return new MaterialAuthorityClient(clientPropertiesFilename);
     }
 
+    @Override
+    protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
+        return createItemInAuthority(client, authorityId, shortId, null /*refname*/);
+    }
+    
     /**
      * Creates the item in authority.
      *
@@ -112,13 +113,13 @@ public class MaterialAuthorityServiceTest extends AbstractAuthorityServiceTest<M
      * @param authRefName the auth ref name
      * @return the string
      */
-    private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName) {
+    private String createItemInAuthority(AuthorityClient client, String vcsid, String shortId, String authRefName) {
         final String testName = "createItemInAuthority("+vcsid+","+authRefName+")"; 
     
         // Submit the request to the service and store the response.
         Map<String, String> materialMap = new HashMap<String,String>();
         // TODO Make material type and status be controlled vocabs.
-        materialMap.put(MaterialJAXBSchema.SHORT_IDENTIFIER, TEST_MATERIAL_SHORT_IDENTIFIER);
+        materialMap.put(MaterialJAXBSchema.SHORT_IDENTIFIER, shortId);
         materialMap.put(MaterialJAXBSchema.MATERIAL_DESCRIPTION, TEST_MATERIAL_DESCRIPTION);
         
         List<MaterialTermGroup> terms = new ArrayList<MaterialTermGroup>();
@@ -136,7 +137,7 @@ public class MaterialAuthorityServiceTest extends AbstractAuthorityServiceTest<M
         // Store the ID returned from the first item resource created
         // for additional tests below.
         if (knownItemResourceId == null){
-            setKnownItemResource(newID, TEST_MATERIAL_SHORT_IDENTIFIER);
+            setKnownItemResource(newID, shortId);
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownItemResourceId=" + newID);
             }
@@ -452,11 +453,6 @@ public class MaterialAuthorityServiceTest extends AbstractAuthorityServiceTest<M
     // Authority item specific overrides
     //
     
-    @Override
-    protected String createItemInAuthority(AuthorityClient client, String authorityId) {
-        return createItemInAuthority(client, authorityId, null /*refname*/);
-    }
-
     @Override
     protected MaterialsCommon updateItemInstance(MaterialsCommon materialsCommon) {
                             
index 73b8bd5c2534ed3ab3a28bce9465b8f55d906d4e..be24d57080f8f170c20051b04e3e60b089853146 100644 (file)
@@ -49,7 +49,7 @@ 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;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -69,6 +69,14 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
     private final String CLASS_NAME = OrgAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
 
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    public OrgAuthorityServiceTest() {
+       super();
+        TEST_SHORTID = "TestOrg";
+    }
+    
     @Override
     public String getServicePathComponent() {
         return OrgAuthorityClient.SERVICE_PATH_COMPONENT;
@@ -78,22 +86,24 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
     protected String getServiceName() {
         return OrgAuthorityClient.SERVICE_NAME;
     }
-    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";
     
+    /** The known item resource short ID. */
     private String knownItemResourceShortIdentifer = null;
     
     /** The known contact resource id. */
     private String knownContactResourceId = null;
     
     /** The all contact resource ids created. */
-    private Map<String, String> allContactResourceIdsCreated =
-            new HashMap<String, String>();
+    private Map<String, String> allContactResourceIdsCreated = new HashMap<String, String>();
 
+    /**
+     * 
+     */
     protected void setKnownItemResource(String id, String shortIdentifer) {
         knownItemResourceId = id;
         knownItemResourceShortIdentifer = shortIdentifer;
@@ -125,7 +135,7 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
     protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
         String headerLabel = new OrgAuthorityClient().getItemCommonPartName();
         
-        String shortId = TEST_SHORT_ID + identifier;
+        String shortId = TEST_SHORTID + identifier;
         Map<String, String> testOrgMap = new HashMap<String, String>();
         testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
         testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, TEST_ORG_FOUNDING_DATE);
@@ -141,6 +151,11 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
         return OrgAuthorityClientUtils.createOrganizationInstance(identifier, testOrgMap, terms, headerLabel);
     }
 
+       @Override
+       protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
+               return createItemInAuthority(client, authorityId, shortId, null /*refname*/);
+       }
+    
     /**
      * Creates the item in authority.
      *
@@ -148,14 +163,13 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
      * @param authRefName the auth ref name
      * @return the string
      */
-    private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName) {
+    private String createItemInAuthority(AuthorityClient client, String vcsid, String shortId, String authRefName) {
 
         final String testName = "createItemInAuthority";
         if (logger.isDebugEnabled()) {
             logger.debug(testName + ":...");
         }
         
-        String shortId = TEST_SHORT_ID + System.currentTimeMillis();
         Map<String, String> testOrgMap = new HashMap<String, String>();
         testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
         testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, TEST_ORG_FOUNDING_DATE);
@@ -1046,11 +1060,6 @@ public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<Orgaut
                
        }
 
-       @Override
-       protected String createItemInAuthority(AuthorityClient client, String authorityId) {
-               return createItemInAuthority(client, authorityId, null /*refname*/);
-       }
-
        @Override
        protected OrganizationsCommon updateItemInstance(OrganizationsCommon organizationsCommon) {
                             
index b47a4d52112fcaad87a56648085edf7d931cf8f6..8d1f4b9ee30b7f15caffe76ac9ce1776b3b19158 100644 (file)
@@ -24,6 +24,7 @@
 package org.collectionspace.services.organization.nuxeo;
 
 import org.collectionspace.services.client.OrgAuthorityClient;
+import org.collectionspace.services.client.PersonAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.organization.OrganizationsCommon;
 
@@ -56,7 +57,7 @@ public class OrganizationDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
-       }
+               return OrgAuthorityClient.SERVICE_COMMON_PART_NAME;
+       }       
 }
 
index 6913506d19992f8d7c5ac9a3cf2fe3573ee713ed..a2b36d09431ab9dd6c13b6ceeba96c188374dcc7 100644 (file)
@@ -44,6 +44,7 @@ import org.collectionspace.services.person.PersonsCommon;
 import org.collectionspace.services.person.PersonauthoritiesCommon;
 import org.collectionspace.services.person.SchoolOrStyleList;
 import org.collectionspace.services.person.StructuredDateGroup;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index e3ce1442eb75911d46c865e8e2a2d4e1b9506294..e6f43feb1d99dc83aadfc752612103af95b13e0a 100644 (file)
@@ -32,7 +32,6 @@ import javax.ws.rs.core.Response;
 import org.collectionspace.services.client.AbstractCommonListUtils;
 import org.collectionspace.services.client.AuthorityClient;
 import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.ContactClient;
@@ -49,6 +48,7 @@ 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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -67,6 +67,19 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
     /** The logger. */
     private final String CLASS_NAME = PersonAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+    
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    public PersonAuthorityServiceTest() {
+       super();
+       TEST_SHORTID = "johnWayneActor";
+    }
+    
+    @Override
+       protected String getTestAuthorityItemShortId() {
+               return getTestAuthorityItemShortId(true); // The short ID of every person item we create should be unique
+       }
 
     @Override
     public String getServicePathComponent() {
@@ -81,6 +94,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
     public String getItemServicePathComponent() {
         return AuthorityClient.ITEMS;
     }
+    
     /** The test forename. */
     final String TEST_FORE_NAME = "John";
     /** The test middle name. */
@@ -93,14 +107,13 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
     final String TEST_DEATH_DATE = "June 11, 1979";
     //private String knownResourceRefName = null;
     private String knownItemResourceShortIdentifer = null;
-    // The resource ID of an item resource used for partial term matching tests.
-    private String knownItemPartialTermResourceId = null;
     /** The known contact resource id. */
     private String knownContactResourceId = null;
     /** The all contact resource ids created. */
     private Map<String, String> allContactResourceIdsCreated =
             new HashMap<String, String>();
 
+    
     protected void setKnownResource(String id, String shortIdentifer,
             String refName) {
         knownResourceId = id;
@@ -212,11 +225,6 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
         return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, terms, headerLabel);
     }
 
-    @Override
-    protected String createItemInAuthority(AuthorityClient client, String vcsid) {
-        String shortId = "johnWayneActor" + System.currentTimeMillis() + random.nextInt();; // short ID needs to be unique
-        return this.createItemInAuthority(client, vcsid, shortId);
-    }
     
     /**
      * Creates an item in an authority, using test data.
@@ -277,7 +285,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
      * @return the string
      */
     private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName, String shortId,
-            Map itemFieldProperties, List<PersonTermGroup> terms, Map itemRepeatableFieldProperties) {
+            Map<String, String> itemFieldProperties, List<PersonTermGroup> terms, Map<String, List<String>> itemRepeatableFieldProperties) {
 
         final String testName = "createItemInAuthority";
         if (logger.isDebugEnabled()) {
@@ -333,7 +341,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
                dependsOnMethods = {"createItem"})
     public void createContact(String testName) {
         setupCreate();
-        String newID = createContactInItem(knownResourceId, knownItemResourceId);
+        createContactInItem(knownResourceId, knownItemResourceId);
     }
 
     /**
@@ -406,7 +414,6 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
 
         // Submit the request to the service and store the response.
         Response res = client.create(multipart);
-        String newID = null;
         // Check the status code of the response: does it match
         // the expected response(s)?  We expect failure here.
         try {
@@ -443,7 +450,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
         term.setTermName(shortId);
         terms.add(term);
         
-        final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
+        final Map<String, List<String>> NULL_REPEATABLE_FIELD_PROPERTIES = null;
         PoxPayloadOut multipart =
                 PersonAuthorityClientUtils.createPersonInstance(knownResourceId,
                 null /*knownResourceRefName*/, fieldProperties, terms,
@@ -451,7 +458,6 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
 
         // Send the request and receive a response
         Response res = client.createItem(knownResourceId, multipart);
-        String newID = null;
         // Check the status code of the response: does it match
         // the expected response(s)?  We expect failure here, so there will be no
         // new ID to keep track of for later cleanup.
@@ -694,7 +700,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
 
         // 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);
+        output.addPart(client.getItemCommonPartName(), person);
         setupUpdateWithInvalidBody();
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
         try {
@@ -947,7 +953,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
 
         // Submit the updated resource to the service and store the response.
         PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_PAYLOAD_NAME);
-        PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), personAuthority);
+        output.addPart(client.getCommonPartName(), personAuthority);
         setupUpdate();
         res = client.update(knownResourceId, output);
         try {
@@ -1025,7 +1031,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
 
         // 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);
+        output.addPart(client.getItemCommonPartName(), person);
         setupUpdate();
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
         try {
@@ -1114,7 +1120,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
 
         // Submit the updated resource to the service and store the response.
         PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
-        PayloadOutputPart commonPart = output.addPart(contactsCommonLabel, contact);
+        output.addPart(contactsCommonLabel, contact);
         setupUpdate();
         res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
         try {
@@ -1283,7 +1289,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
         String contactResourceId;
         // Clean up contact resources.
         PersonAuthorityClient client = new PersonAuthorityClient();
-        parentResourceId = knownResourceId;
+        parentResourceId = this.getKnowResourceId();
         for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
             contactResourceId = entry.getKey();
             itemResourceId = entry.getValue();
index 63f093412c94f631221467cf6cfb4be288f1cd82..42d9d4efa292ae93ffe37e386b6dc3ce50145235 100644 (file)
@@ -60,9 +60,15 @@ import org.testng.annotations.Test;
 public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest<PlaceauthoritiesCommon, PlacesCommon> {
 
     /** The logger. */
-    private final String CLASS_NAME = PlaceAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(PlaceAuthorityServiceTest.class);
 
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    PlaceAuthorityServiceTest() {
+        TEST_SHORTID = "sanjose";
+    }
+    
        @Override
        public String getServicePathComponent() {
                return PlaceAuthorityClient.SERVICE_PATH_COMPONENT;
@@ -78,17 +84,9 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest<Plac
     }  
     
     // Instance variables specific to this test.
-    
-//    /** The SERVICE path component. */
-//    final String SERVICE_PATH_COMPONENT = "placeauthorities";
-//    
-//    /** The ITEM service path component. */
-//    final String ITEM_SERVICE_PATH_COMPONENT = "items";
-//    
-    
+        
     final String TEST_DNAME = "San Jose, CA";
     final String TEST_NAME = "San Jose";
-    final String TEST_SHORTID = "sanjose";
     // TODO Make place type be a controlled vocab term.
     final String TEST_PLACE_TYPE = "City";
     // TODO Make status type be a controlled vocab term.
@@ -98,12 +96,7 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest<Plac
     final String TEST_SOURCE_PAGE = "p.21";
     final String TEST_DISPLAY_DATE = "This year";
     final String TEST_EARLIEST_SINGLE_YEAR = "2012";
-    
-    /** The known resource id. */
-    private String knownResourceShortIdentifer = null;
-    private String knownResourceRefName = null;
-    private String knownPlaceTypeRefName = null;
-    
+        
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
      */
@@ -117,6 +110,12 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest<Plac
         return new PlaceAuthorityClient(clientPropertiesFilename);
        }
        
+       @Override
+       protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
+               return createItemInAuthority(client, authorityId, shortId, null /*refname*/);
+       }
+
+       
        /**
      * Creates the item in authority.
      *
@@ -124,13 +123,13 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest<Plac
      * @param authRefName the auth ref name
      * @return the string
      */
-    private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName) {
+    private String createItemInAuthority(AuthorityClient client, String vcsid, String shortId, String authRefName) {
         final String testName = "createItemInAuthority("+vcsid+","+authRefName+")"; 
     
         // Submit the request to the service and store the response.
         Map<String, String> sanjoseMap = new HashMap<String,String>();
         // TODO Make place type and status be controlled vocabs.
-        sanjoseMap.put(PlaceJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
+        sanjoseMap.put(PlaceJAXBSchema.SHORT_IDENTIFIER, shortId);
         sanjoseMap.put(PlaceJAXBSchema.PLACE_TYPE, TEST_PLACE_TYPE);
         sanjoseMap.put(PlaceJAXBSchema.NOTE, TEST_NOTE);
         
@@ -149,7 +148,7 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest<Plac
         // Store the ID returned from the first item resource created
         // for additional tests below.
         if (knownItemResourceId == null){
-               setKnownItemResource(newID, TEST_SHORTID);
+               setKnownItemResource(newID, shortId);
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownItemResourceId=" + newID);
             }
@@ -205,7 +204,6 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest<Plac
         
         // Submit the updated resource to the service and store the response.
         PoxPayloadOut output = new PoxPayloadOut(PlaceAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
-        PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), place);
         setupUpdateWithInvalidBody(); // we expected a failure here.
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
         try {
@@ -463,11 +461,6 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest<Plac
        // Authority item specific overrides
        //
        
-       @Override
-       protected String createItemInAuthority(AuthorityClient client, String authorityId) {
-               return createItemInAuthority(client, authorityId, null /*refname*/);
-       }
-
        @Override
        protected PlacesCommon updateItemInstance(PlacesCommon placesCommon) {
                             
index d93d808933459b799c4cd4ebfed5af1f3004df23..f08a1f2447512f290cbfb54004af7e16b4c999e2 100644 (file)
@@ -36,17 +36,19 @@ import org.collectionspace.services.client.TaxonomyAuthorityClient;
 import org.collectionspace.services.client.TaxonomyAuthorityClientUtils;
 import org.collectionspace.services.client.TaxonomyAuthorityProxy;
 import org.collectionspace.services.jaxb.AbstractCommonList;
+
+import org.collectionspace.services.taxonomy.CommonNameGroup;
 import org.collectionspace.services.taxonomy.CommonNameGroupList;
 import org.collectionspace.services.taxonomy.TaxonAuthorGroup;
 import org.collectionspace.services.taxonomy.TaxonAuthorGroupList;
 import org.collectionspace.services.taxonomy.TaxonCitationList;
-import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
 import org.collectionspace.services.taxonomy.TaxonCommon;
+import org.collectionspace.services.taxonomy.TaxonTermGroup;
+import org.collectionspace.services.taxonomy.TaxonTermGroupList;
+import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
 
 import javax.ws.rs.core.Response;
 
-import org.collectionspace.services.taxonomy.*;
-import org.jboss.resteasy.client.ClientResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -61,12 +63,18 @@ import org.testng.annotations.Test;
  */
 public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<TaxonomyauthorityCommon, TaxonCommon> {
 
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+       TaxonomyAuthorityServiceTest() {
+           TEST_SHORTID = "CentauruspleurexanthemusGreen1832";         
+       }
+       
     /**
      * The logger.
      */
     private final String CLASS_NAME = TaxonomyAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(TaxonomyAuthorityServiceTest.class);
-    private final String TEST_SHORTID = "CentauruspleurexanthemusGreen1832";
     private final String TEST_TERM_STATUS = "accepted";
     private final String TEST_TAXON_FULL_NAME = "Centaurus pleurexanthemus Green 1832";
     // TODO Re-implement the Taxon Rank field so as to provide an orderable
@@ -84,9 +92,6 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<T
     private final TaxonCitationList NULL_TAXON_CITATION_LIST = null;
     private final CommonNameGroupList NULL_COMMON_NAME_GROUP_LIST = null;
 
-    private String knownResourceShortIdentifer = null;
-    private String knownTaxonomyTypeRefName = null;
-
     @Override
     public String getServicePathComponent() {
         return TaxonomyAuthorityClient.SERVICE_PATH_COMPONENT;
@@ -115,6 +120,11 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<T
         return new TaxonomyAuthorityClient(clientPropertiesFilename);
        }
        
+    @Override
+    protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
+        return createItemInAuthority(client, authorityId, shortId, null /** refname */);
+    }
+
     /**
      * Creates the item in authority.
      *
@@ -122,7 +132,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<T
      * @param authRefName the auth ref name
      * @return the string
      */
-    private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName) {
+    private String createItemInAuthority(AuthorityClient client, String vcsid, String shortId, String authRefName) {
 
         final String testName = "createItemInAuthority(" + vcsid + "," + authRefName + ")";
         if (logger.isDebugEnabled()) {
@@ -133,7 +143,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<T
         Map<String, String> taxonMap = new HashMap<String, String>();
 
         // Fields present in all authority records.
-        taxonMap.put(TaxonJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
+        taxonMap.put(TaxonJAXBSchema.SHORT_IDENTIFIER, shortId);
         // TODO Make term status be controlled vocab.
         taxonMap.put(TaxonJAXBSchema.TERM_STATUS, TEST_TERM_STATUS);
 
@@ -174,7 +184,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<T
         // Store the ID returned from the first item resource created
         // for additional tests below.
         if (knownItemResourceId == null) {
-            setKnownItemResource(newID, TEST_SHORTID);
+            setKnownItemResource(newID, shortId);
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownItemResourceId=" + newID + " inAuthority=" + vcsid);
             }
@@ -438,7 +448,6 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<T
             String identifier) {
         String shortId = identifier;
         String displayName = "displayName-" + shortId;
-        String baseRefName = TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
         PoxPayloadOut multipart = TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
                 displayName, shortId, commonPartName);
         return multipart;
@@ -475,11 +484,6 @@ public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<T
     //
     // Authority item specific overrides
     //
-    @Override
-    protected String createItemInAuthority(AuthorityClient client, String authorityId) {
-        return createItemInAuthority(client, authorityId, null /** refname */);
-    }
-
     @Override
     protected TaxonCommon updateItemInstance(TaxonCommon taxonCommon) {
         TaxonCommon result = taxonCommon;
index 570aa6563ffdf73cb4c8436654f521eaf918ad2f..9cd44f9891542ac5aa066ee7a359d13a0733f167 100644 (file)
@@ -34,6 +34,7 @@ import org.collectionspace.services.client.VocabularyClient;
 import org.collectionspace.services.client.VocabularyClientUtils;
 import org.collectionspace.services.vocabulary.VocabulariesCommon;
 import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -50,14 +51,26 @@ import javax.ws.rs.core.Response;
  */
 public class VocabularyServiceTest extends AbstractAuthorityServiceTest<VocabulariesCommon, VocabularyitemsCommon> {
 
-    private final String CLASS_NAME = VocabularyServiceTest.class.getName();
-    private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+       // The class for logging
+    private final Logger logger = LoggerFactory.getLogger(VocabularyServiceTest.class);
+    
     // Instance variables specific to this test.
     final String SERVICE_PATH_COMPONENT = VocabularyClient.SERVICE_PATH_COMPONENT;//"vocabularies";
     final String SERVICE_PAYLOAD_NAME = VocabularyClient.SERVICE_PAYLOAD_NAME;
     final String SERVICE_ITEM_PAYLOAD_NAME = VocabularyClient.SERVICE_ITEM_PAYLOAD_NAME;
 
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    VocabularyServiceTest() {
+        TEST_SHORTID = "vocabTest";
+    }
 
+    @Override
+       protected String getTestAuthorityItemShortId() {
+               return getTestAuthorityItemShortId(true); // The short ID of every person item we create should be unique
+       }
+    
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
      */
@@ -72,11 +85,10 @@ public class VocabularyServiceTest extends AbstractAuthorityServiceTest<Vocabula
        }
     
     @Override
-    protected String createItemInAuthority(AuthorityClient client, String authorityId) {
+    protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
        String result = null;
        
         HashMap<String, String> itemInfo = new HashMap<String, String>();
-        String shortId = createIdentifier();
         itemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, shortId);
         itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-" + shortId);
         result = VocabularyClientUtils.createItemInVocabulary(authorityId,
@@ -109,7 +121,7 @@ public class VocabularyServiceTest extends AbstractAuthorityServiceTest<Vocabula
     public void createItemList(String testName) throws Exception {
        knownAuthorityWithItems = createResource(testName, READITEMS_SHORT_IDENTIFIER);
         for (int j = 0; j < nItemsToCreateInList; j++) {
-               createItemInAuthority((AuthorityClient) getClientInstance(), knownAuthorityWithItems);
+               createItemInAuthority((AuthorityClient) getClientInstance(), knownAuthorityWithItems, getTestAuthorityItemShortId(true));
         }
     }    
     
index 4aba2d7c311948562c7ec375c209ddf1b7dea9d3..d350031d31b34152b38046e5dfeb1943750a372a 100644 (file)
@@ -58,9 +58,15 @@ import org.testng.annotations.Test;
 public class WorkAuthorityServiceTest extends AbstractAuthorityServiceTest<WorkauthoritiesCommon, WorksCommon> {
 
     /** The logger. */
-    private final String CLASS_NAME = WorkAuthorityServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(WorkAuthorityServiceTest.class);
 
+    /**
+     * Default constructor.  Used to set the short ID for all tests authority items
+     */
+    WorkAuthorityServiceTest() {
+        TEST_SHORTID = "muppetstakemanhattan";
+    }
+    
     @Override
     public String getServicePathComponent() {
         return WorkAuthorityClient.SERVICE_PATH_COMPONENT;
@@ -77,13 +83,6 @@ public class WorkAuthorityServiceTest extends AbstractAuthorityServiceTest<Worka
     
     // Instance variables specific to this test.
     
-//    /** The SERVICE path component. */
-//    final String SERVICE_PATH_COMPONENT = "workauthorities";
-//    
-//    /** The ITEM service path component. */
-//    final String ITEM_SERVICE_PATH_COMPONENT = "items";
-//    
-
     final String TEST_WORK_TERM_DISPLAY_NAME = "Muppets Take Manhattan (1984)";
     final String TEST_WORK_TERM_NAME = "Muppets Take Manhattan";
     final String TEST_WORK_TERM_TYPE = "";
@@ -101,14 +100,8 @@ public class WorkAuthorityServiceTest extends AbstractAuthorityServiceTest<Worka
     final String TEST_WORK_CREATOR_GROUP_CREATOR_TYPE = "director";
     final String TEST_WORK_PUBLISHER_GROUP_PUBLISHER = "TriStar Pictures";
     final String TEST_WORK_PUBLISHER_GROUP_PUBLISHER_TYPE = "Distributor";
-    final String TEST_WORK_SHORT_IDENTIFIER = "muppetstakemanhattan";
     final String TEST_WORK_REFNAME = "refname";
-    
-    /** The known resource id. */
-    private String knownResourceShortIdentifer = null;
-    private String knownResourceRefName = null;
-    private String knownWorkTypeRefName = null;
-    
+        
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
      */
@@ -122,6 +115,11 @@ public class WorkAuthorityServiceTest extends AbstractAuthorityServiceTest<Worka
         return new WorkAuthorityClient(clientPropertiesFilename);
        }
 
+    @Override
+    protected String createItemInAuthority(AuthorityClient client, String authorityId, String shortId) {
+        return createItemInAuthority(client, authorityId, shortId, null /*refname*/);
+    }
+       
     /**
      * Creates the item in authority.
      *
@@ -129,13 +127,13 @@ public class WorkAuthorityServiceTest extends AbstractAuthorityServiceTest<Worka
      * @param authRefName the auth ref name
      * @return the string
      */
-    private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName) {
+    private String createItemInAuthority(AuthorityClient client, String vcsid, String shortId, String authRefName) {
         final String testName = "createItemInAuthority("+vcsid+","+authRefName+")"; 
     
         // Submit the request to the service and store the response.
         Map<String, String> workMap = new HashMap<String,String>();
         // TODO Make work type and status be controlled vocabs.
-        workMap.put(WorkJAXBSchema.SHORT_IDENTIFIER, TEST_WORK_SHORT_IDENTIFIER);
+        workMap.put(WorkJAXBSchema.SHORT_IDENTIFIER, shortId);
         workMap.put(WorkJAXBSchema.WORK_TYPE, TEST_WORK_TYPE);
         workMap.put(WorkJAXBSchema.WORK_HISTORY_NOTE, TEST_WORK_HISTORY_NOTE);
         
@@ -154,7 +152,7 @@ public class WorkAuthorityServiceTest extends AbstractAuthorityServiceTest<Worka
         // Store the ID returned from the first item resource created
         // for additional tests below.
         if (knownItemResourceId == null){
-            setKnownItemResource(newID, TEST_WORK_SHORT_IDENTIFIER);
+            setKnownItemResource(newID, shortId);
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownItemResourceId=" + newID);
             }
@@ -211,8 +209,7 @@ public class WorkAuthorityServiceTest extends AbstractAuthorityServiceTest<Worka
                // Submit the updated resource to the service and store the response.
                PoxPayloadOut output = new PoxPayloadOut(
                                WorkAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
-               PayloadOutputPart commonPart = output.addPart(
-                               client.getItemCommonPartName(), work);
+               output.addPart(client.getItemCommonPartName(), work);
                setupUpdateWithInvalidBody(); // we expected a failure here.
                res = client.updateItem(knownResourceId, knownItemResourceId, output);
                try {
@@ -470,11 +467,6 @@ public class WorkAuthorityServiceTest extends AbstractAuthorityServiceTest<Worka
     // Authority item specific overrides
     //
     
-    @Override
-    protected String createItemInAuthority(AuthorityClient client, String authorityId) {
-        return createItemInAuthority(client, authorityId, null /*refname*/);
-    }
-
     @Override
     protected WorksCommon updateItemInstance(WorksCommon worksCommon) {