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;
/**
* 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() {
* @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 {
// 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);
}
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;
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);
}
/**
// 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.
*/
@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());
//
// 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();
// 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
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));
}
}
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();
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();
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();
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 {
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);
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 {
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;
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;
+ }
}
* 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);
}
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;
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;
// 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";
* @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 {
// 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);
}
* @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();
}
+"\" 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);
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;
// 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";
/** The known resource id. */
private String knownLocationTypeRefName = null;
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
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.
*
* @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);
// 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);
}
//
// Authority item specific overrides
//
-
- @Override
- protected String createItemInAuthority(AuthorityClient client, String authorityId) {
- return createItemInAuthority(client, authorityId, null /*refname*/);
- }
@Override
protected LocationsCommon updateItemInstance(LocationsCommon locationsCommon) {
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;
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()
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.
*
* @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>();
// 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);
}
// Authority item specific overrides
//
- @Override
- protected String createItemInAuthority(AuthorityClient client, String authorityId) {
- return createItemInAuthority(client, authorityId, null /*refname*/);
- }
-
@Override
protected MaterialsCommon updateItemInstance(MaterialsCommon materialsCommon) {
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;
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;
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;
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);
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.
*
* @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);
}
- @Override
- protected String createItemInAuthority(AuthorityClient client, String authorityId) {
- return createItemInAuthority(client, authorityId, null /*refname*/);
- }
-
@Override
protected OrganizationsCommon updateItemInstance(OrganizationsCommon organizationsCommon) {
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;
@Override
public String getParentCommonSchemaName() {
// TODO Auto-generated method stub
- return OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
- }
+ return OrgAuthorityClient.SERVICE_COMMON_PART_NAME;
+ }
}
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;
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;
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;
/** 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() {
public String getItemServicePathComponent() {
return AuthorityClient.ITEMS;
}
+
/** The test forename. */
final String TEST_FORE_NAME = "John";
/** The test middle name. */
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;
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.
* @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()) {
dependsOnMethods = {"createItem"})
public void createContact(String testName) {
setupCreate();
- String newID = createContactInItem(knownResourceId, knownItemResourceId);
+ createContactInItem(knownResourceId, knownItemResourceId);
}
/**
// 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 {
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,
// 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.
// 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 {
// 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 {
// 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 {
// 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 {
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();
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;
}
// 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.
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()
*/
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.
*
* @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);
// 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);
}
// 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 {
// Authority item specific overrides
//
- @Override
- protected String createItemInAuthority(AuthorityClient client, String authorityId) {
- return createItemInAuthority(client, authorityId, null /*refname*/);
- }
-
@Override
protected PlacesCommon updateItemInstance(PlacesCommon placesCommon) {
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;
*/
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
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;
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.
*
* @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()) {
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);
// 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);
}
String identifier) {
String shortId = identifier;
String displayName = "displayName-" + shortId;
- String baseRefName = TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
PoxPayloadOut multipart = TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
displayName, shortId, commonPartName);
return multipart;
//
// 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;
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;
*/
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()
*/
}
@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,
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));
}
}
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;
// 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 = "";
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()
*/
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.
*
* @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);
// 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);
}
// 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 {
// Authority item specific overrides
//
- @Override
- protected String createItemInAuthority(AuthorityClient client, String authorityId) {
- return createItemInAuthority(client, authorityId, null /*refname*/);
- }
-
@Override
protected WorksCommon updateItemInstance(WorksCommon worksCommon) {