From 48e2dca8ba73fb0d04aaee3f291e51ac57e043c5 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Sat, 7 May 2011 06:48:01 +0000 Subject: [PATCH] CSPACE-3865: More naming tweaks. Creation and reading of authority documents is working; items aren't receiving inAuthority values. --- .../client/TaxonomyAuthorityClient.java | 59 +- .../client/TaxonomyAuthorityClientUtils.java | 280 ++-- .../test/TaxonomyAuthorityServiceTest.java | 1339 ++++++++--------- .../services/TaxonomyJAXBSchema.java | 2 +- .../taxonomy/TaxonomyAuthorityResource.java | 1 + 5 files changed, 837 insertions(+), 844 deletions(-) diff --git a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java index 7200c3da3..1b3efa953 100644 --- a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java +++ b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java @@ -46,47 +46,52 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory; * The Class TaxonomyAuthorityClient. */ public class TaxonomyAuthorityClient extends AuthorityClientImpl { - public static final String SERVICE_NAME = "taxonomyauthorities"; - public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; - public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; - public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; - // - // Subitem constants - // - public static final String SERVICE_ITEM_NAME = "taxon"; - public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME; - // - // Payload Part/Schema part names - // - public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + - PART_LABEL_SEPARATOR + PART_COMMON_LABEL; - public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME + - PART_LABEL_SEPARATOR + PART_COMMON_LABEL; - - @Override - public String getServiceName() { - return SERVICE_NAME; - } + + public static final String SERVICE_NAME = "taxonomyauthorities"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PAYLOAD_NAME = "taxonomyauthority"; + // + // Subitem constants + // + public static final String SERVICE_ITEM_NAME = "taxon"; + public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME; + // + // Payload Part/Schema part names + // + public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + + PART_LABEL_SEPARATOR + PART_COMMON_LABEL; + public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME + + PART_LABEL_SEPARATOR + PART_COMMON_LABEL; + + @Override + public String getServiceName() { + return SERVICE_NAME; + } @Override public String getServicePathComponent() { return SERVICE_PATH_COMPONENT; } + @Override + public String getCommonPartName() { + return getCommonPartName(SERVICE_PAYLOAD_NAME); + } + @Override public String getItemCommonPartName() { return getCommonPartName(SERVICE_ITEM_NAME); } - @Override - public Class getProxyClass() { - return TaxonomyAuthorityProxy.class; - } - + @Override + public Class getProxyClass() { + return TaxonomyAuthorityProxy.class; + } + /* * Proxied service calls. */ - /** * @return list * @see org.collectionspace.services.client.TaxonomyAuthorityProxy#readList() diff --git a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClientUtils.java b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClientUtils.java index 833e067e8..aa4109273 100644 --- a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClientUtils.java +++ b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClientUtils.java @@ -22,8 +22,9 @@ import org.slf4j.LoggerFactory; import org.testng.Assert; public class TaxonomyAuthorityClientUtils { + private static final Logger logger = - LoggerFactory.getLogger(TaxonomyAuthorityClientUtils.class); + LoggerFactory.getLogger(TaxonomyAuthorityClientUtils.class); /** * Creates a new Taxonomy Authority @@ -33,7 +34,7 @@ public class TaxonomyAuthorityClientUtils { * @return The PoxPayloadOut payload for the create call */ public static PoxPayloadOut createTaxonomyAuthorityInstance( - String displayName, String shortIdentifier, String headerLabel ) { + String displayName, String shortIdentifier, String headerLabel) { TaxonomyauthorityCommon Taxonomyauthority = new TaxonomyauthorityCommon(); Taxonomyauthority.setDisplayName(displayName); Taxonomyauthority.setShortIdentifier(shortIdentifier); @@ -44,9 +45,9 @@ public class TaxonomyAuthorityClientUtils { PayloadOutputPart commonPart = multipart.addPart(Taxonomyauthority, MediaType.APPLICATION_XML_TYPE); commonPart.setLabel(headerLabel); - if(logger.isDebugEnabled()){ - logger.debug("to be created, Taxonomyauthority common ", - Taxonomyauthority, TaxonomyauthorityCommon.class); + if (logger.isDebugEnabled()) { + logger.debug("to be created, Taxonomyauthority common ", + Taxonomyauthority, TaxonomyauthorityCommon.class); } return multipart; @@ -54,148 +55,152 @@ public class TaxonomyAuthorityClientUtils { /** * @param taxonomyRefName The proper refName for this authority - * @param taxonomyInfo the properties for the new Taxonomy. Can pass in one condition + * @param taxonInfo the properties for the new Taxonomy. Can pass in one condition * note and date string. * @param headerLabel The common part label * @return The PoxPayloadOut payload for the create call */ - public static PoxPayloadOut createTaxonomyInstance( - String taxonomyAuthRefName, Map taxonomyInfo, - String headerLabel){ - TaxonCommon taxonomy = new TaxonCommon(); - String shortId = taxonomyInfo.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER); - String displayName = taxonomyInfo.get(TaxonomyJAXBSchema.DISPLAY_NAME); - taxonomy.setShortIdentifier(shortId); - String taxonomyRefName = createTaxonomyRefName(taxonomyAuthRefName, shortId, displayName); - taxonomy.setRefName(taxonomyRefName); - String value = null; - value = taxonomyInfo.get(TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED); - boolean displayNameComputed = (value==null) || value.equalsIgnoreCase("true"); - taxonomy.setDisplayNameComputed(displayNameComputed); - if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.NAME))!=null) - taxonomy.setTaxonFullName(value); - if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.RANK))!=null) - taxonomy.setTaxonRank(value); - if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.TERM_STATUS))!=null) - taxonomy.setTermStatus(value); + public static PoxPayloadOut createTaxonInstance( + String taxonomyAuthRefName, Map taxonInfo, + String headerLabel) { + TaxonCommon taxon = new TaxonCommon(); + String shortId = taxonInfo.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER); + String displayName = taxonInfo.get(TaxonomyJAXBSchema.DISPLAY_NAME); + taxon.setShortIdentifier(shortId); + String taxonomyRefName = createTaxonomyRefName(taxonomyAuthRefName, shortId, displayName); + taxon.setRefName(taxonomyRefName); + String value = null; + value = taxonInfo.get(TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED); + boolean displayNameComputed = (value == null) || value.equalsIgnoreCase("true"); + taxon.setDisplayNameComputed(displayNameComputed); + if ((value = (String) taxonInfo.get(TaxonomyJAXBSchema.NAME)) != null) { + taxon.setTaxonFullName(value); + } + if ((value = (String) taxonInfo.get(TaxonomyJAXBSchema.RANK)) != null) { + taxon.setTaxonRank(value); + } + if ((value = (String) taxonInfo.get(TaxonomyJAXBSchema.TERM_STATUS)) != null) { + taxon.setTermStatus(value); + } + // FIXME: Add additional fields in the Taxon record here. PoxPayloadOut multipart = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - PayloadOutputPart commonPart = multipart.addPart(taxonomy, - MediaType.APPLICATION_XML_TYPE); + PayloadOutputPart commonPart = multipart.addPart(taxon, + MediaType.APPLICATION_XML_TYPE); commonPart.setLabel(headerLabel); - if(logger.isDebugEnabled()){ - logger.debug("to be created, taxon common ", taxonomy, TaxonCommon.class); + if (logger.isDebugEnabled()) { + logger.debug("to be created, taxon common ", taxon, TaxonCommon.class); } return multipart; } - + /** - * @param vcsid CSID of the authority to create a new taxonomy in + * @param vcsid CSID of the authority to create a new taxon in * @param TaxonomyauthorityRefName The refName for the authority - * @param taxonomyMap the properties for the new Taxonomy + * @param taxonMap the properties for the new Taxonomy * @param client the service client * @return the CSID of the new item */ - public static String createItemInAuthority(String vcsid, - String TaxonomyauthorityRefName, Map taxonomyMap, - TaxonomyAuthorityClient client ) { - // Expected status code: 201 Created - int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); - // Type of service request being tested - ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE; - - String displayName = taxonomyMap.get(TaxonomyJAXBSchema.DISPLAY_NAME); - String displayNameComputedStr = taxonomyMap.get(TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED); - boolean displayNameComputed = (displayNameComputedStr==null) || displayNameComputedStr.equalsIgnoreCase("true"); - if( displayName == null ) { - if(!displayNameComputed) { - throw new RuntimeException( - "CreateItem: Must supply a displayName if displayNameComputed is set to false."); - } - displayName = - prepareDefaultDisplayName( - taxonomyMap.get(TaxonomyJAXBSchema.NAME)); - } - - if(logger.isDebugEnabled()){ - logger.debug("Import: Create Item: \""+displayName - +"\" in Taxonomyauthority: \"" + TaxonomyauthorityRefName +"\""); - } - PoxPayloadOut multipart = - createTaxonomyInstance( TaxonomyauthorityRefName, - taxonomyMap, client.getItemCommonPartName() ); - String newID = null; - ClientResponse res = client.createItem(vcsid, multipart); + public static String createItemInAuthority(String vcsid, + String TaxonomyauthorityRefName, Map taxonMap, + TaxonomyAuthorityClient client) { + // Expected status code: 201 Created + int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); + // Type of service request being tested + ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE; + + String displayName = taxonMap.get(TaxonomyJAXBSchema.DISPLAY_NAME); + String displayNameComputedStr = taxonMap.get(TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED); + boolean displayNameComputed = (displayNameComputedStr == null) || displayNameComputedStr.equalsIgnoreCase("true"); + if (displayName == null) { + if (!displayNameComputed) { + throw new RuntimeException( + "CreateItem: Must supply a displayName if displayNameComputed is set to false."); + } + displayName = + prepareDefaultDisplayName( + taxonMap.get(TaxonomyJAXBSchema.NAME)); + } + + if (logger.isDebugEnabled()) { + logger.debug("Import: Create Item: \"" + displayName + + "\" in Taxonomyauthority: \"" + TaxonomyauthorityRefName + "\""); + } + PoxPayloadOut multipart = + createTaxonInstance(TaxonomyauthorityRefName, + taxonMap, client.getItemCommonPartName()); + String newID = null; + ClientResponse res = client.createItem(vcsid, multipart); try { - int statusCode = res.getStatus(); - - if(!REQUEST_TYPE.isValidStatusCode(statusCode)) { - throw new RuntimeException("Could not create Item: \"" - +taxonomyMap.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER) - +"\" in Taxonomyauthority: \"" + TaxonomyauthorityRefName - +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - } - if(statusCode != EXPECTED_STATUS_CODE) { - throw new RuntimeException("Unexpected Status when creating Item: \"" - +taxonomyMap.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER) - +"\" in Taxonomyauthority: \"" + TaxonomyauthorityRefName +"\", Status:"+ statusCode); - } - newID = extractId(res); + int statusCode = res.getStatus(); + + if (!REQUEST_TYPE.isValidStatusCode(statusCode)) { + throw new RuntimeException("Could not create Item: \"" + + taxonMap.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER) + + "\" in Taxonomyauthority: \"" + TaxonomyauthorityRefName + + "\" " + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + } + if (statusCode != EXPECTED_STATUS_CODE) { + throw new RuntimeException("Unexpected Status when creating Item: \"" + + taxonMap.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER) + + "\" in Taxonomyauthority: \"" + TaxonomyauthorityRefName + "\", Status:" + statusCode); + } + newID = extractId(res); } finally { - res.releaseConnection(); + res.releaseConnection(); } - return newID; + return newID; } public static PoxPayloadOut createTaxonomyInstance( - String commonPartXML, String headerLabel) throws DocumentException { + String commonPartXML, String headerLabel) throws DocumentException { PoxPayloadOut multipart = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); PayloadOutputPart commonPart = multipart.addPart(commonPartXML, - MediaType.APPLICATION_XML_TYPE); + MediaType.APPLICATION_XML_TYPE); commonPart.setLabel(headerLabel); - if(logger.isDebugEnabled()){ - logger.debug("to be created, Taxon common ", commonPartXML); + if (logger.isDebugEnabled()) { + logger.debug("to be created, Taxon common ", commonPartXML); } return multipart; } - + public static String createItemInAuthority(String vcsid, - String commonPartXML, - TaxonomyAuthorityClient client ) throws DocumentException { - // Expected status code: 201 Created - int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); - // Type of service request being tested - ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE; - - PoxPayloadOut multipart = - createTaxonomyInstance(commonPartXML, client.getItemCommonPartName()); - String newID = null; - ClientResponse res = client.createItem(vcsid, multipart); + String commonPartXML, + TaxonomyAuthorityClient client) throws DocumentException { + // Expected status code: 201 Created + int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); + // Type of service request being tested + ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE; + + PoxPayloadOut multipart = + createTaxonomyInstance(commonPartXML, client.getItemCommonPartName()); + String newID = null; + ClientResponse res = client.createItem(vcsid, multipart); try { - int statusCode = res.getStatus(); - - if(!REQUEST_TYPE.isValidStatusCode(statusCode)) { - throw new RuntimeException("Could not create Item: \""+commonPartXML - +"\" in Taxonomyauthority: \"" + vcsid - +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - } - if(statusCode != EXPECTED_STATUS_CODE) { - throw new RuntimeException("Unexpected Status when creating Item: \""+commonPartXML - +"\" in Taxonomyauthority: \"" + vcsid +"\", Status:"+ statusCode); - } - newID = extractId(res); + int statusCode = res.getStatus(); + + if (!REQUEST_TYPE.isValidStatusCode(statusCode)) { + throw new RuntimeException("Could not create Item: \"" + commonPartXML + + "\" in Taxonomyauthority: \"" + vcsid + + "\" " + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + } + if (statusCode != EXPECTED_STATUS_CODE) { + throw new RuntimeException("Unexpected Status when creating Item: \"" + commonPartXML + + "\" in Taxonomyauthority: \"" + vcsid + "\", Status:" + statusCode); + } + newID = extractId(res); } finally { - res.releaseConnection(); + res.releaseConnection(); } - return newID; + return newID; } - + /** * Creates the from xml file. * @@ -203,12 +208,12 @@ public class TaxonomyAuthorityClientUtils { * @return new CSID as string * @throws Exception the exception */ - private String createItemInAuthorityFromXmlFile(String vcsid, String commonPartFileName, - TaxonomyAuthorityClient client) throws Exception { + private String createItemInAuthorityFromXmlFile(String vcsid, String commonPartFileName, + TaxonomyAuthorityClient client) throws Exception { byte[] b = FileUtils.readFileToByteArray(new File(commonPartFileName)); String commonPartXML = new String(b); - return createItemInAuthority(vcsid, commonPartXML, client ); - } + return createItemInAuthority(vcsid, commonPartXML, client); + } /** * Creates the Taxonomyauthority ref name. @@ -218,11 +223,12 @@ public class TaxonomyAuthorityClientUtils { * @return the string */ public static String createTaxonomyAuthRefName(String shortId, String displaySuffix) { - String refName = "urn:cspace:org.collectionspace.demo:taxonomyauthority:name(" - +shortId+")"; - if(displaySuffix!=null&&!displaySuffix.isEmpty()) - refName += "'"+displaySuffix+"'"; - return refName; + String refName = "urn:cspace:org.collectionspace.demo:taxonomyauthority:name(" + + shortId + ")"; + if (displaySuffix != null && !displaySuffix.isEmpty()) { + refName += "'" + displaySuffix + "'"; + } + return refName; } /** @@ -234,27 +240,28 @@ public class TaxonomyAuthorityClientUtils { * @return the string */ public static String createTaxonomyRefName( - String taxonomyAuthRefName, String shortId, String displaySuffix) { - String refName = taxonomyAuthRefName+":taxon:name("+shortId+")"; - if(displaySuffix!=null&&!displaySuffix.isEmpty()) - refName += "'"+displaySuffix+"'"; - return refName; + String taxonomyAuthRefName, String shortId, String displaySuffix) { + String refName = taxonomyAuthRefName + ":taxon:name(" + shortId + ")"; + if (displaySuffix != null && !displaySuffix.isEmpty()) { + refName += "'" + displaySuffix + "'"; + } + return refName; } public static String extractId(ClientResponse res) { MultivaluedMap mvm = res.getMetadata(); String uri = (String) ((ArrayList) mvm.get("Location")).get(0); - if(logger.isDebugEnabled()){ - logger.debug("extractId:uri=" + uri); + if (logger.isDebugEnabled()) { + logger.debug("extractId:uri=" + uri); } String[] segments = uri.split("/"); String id = segments[segments.length - 1]; - if(logger.isDebugEnabled()){ - logger.debug("id=" + id); + if (logger.isDebugEnabled()) { + logger.debug("id=" + id); } return id; } - + /** * Returns an error message indicating that the status code returned by a * specific call to a service does not fall within a set of valid status @@ -268,12 +275,10 @@ public class TaxonomyAuthorityClientUtils { * @return An error message. */ public static String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) { - return "Status code '" + statusCode + "' in response is NOT within the expected set: " + - requestType.validStatusCodesAsString(); + return "Status code '" + statusCode + "' in response is NOT within the expected set: " + + requestType.validStatusCodesAsString(); } - - /** * Produces a default displayName from the basic name and dates fields. * @see TaxonomyDocumentModelHandler.prepareDefaultDisplayName() which @@ -283,12 +288,9 @@ public class TaxonomyAuthorityClientUtils { * @return */ public static String prepareDefaultDisplayName( - String name ) { - StringBuilder newStr = new StringBuilder(); - newStr.append(name); - return newStr.toString(); + String name) { + StringBuilder newStr = new StringBuilder(); + newStr.append(name); + return newStr.toString(); } - - - } diff --git a/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java b/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java index 2342112ec..205f812b4 100644 --- a/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java +++ b/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java @@ -69,27 +69,25 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI private final String CLASS_NAME = TaxonomyAuthorityServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(TaxonomyAuthorityServiceTest.class); - @Override - public String getServicePathComponent() { - return TaxonomyAuthorityClient.SERVICE_PATH_COMPONENT; - } - - @Override - protected String getServiceName() { - return TaxonomyAuthorityClient.SERVICE_NAME; - } - + @Override + public String getServicePathComponent() { + return TaxonomyAuthorityClient.SERVICE_PATH_COMPONENT; + } + + @Override + protected String getServiceName() { + return TaxonomyAuthorityClient.SERVICE_NAME; + } + public String getItemServicePathComponent() { return AuthorityClient.ITEMS; } - final String TEST_NAME = "Centaurus pleurexanthemus Green 1832-"; final String TEST_SHORTID = "CentauruspleurexanthemusGreen1832"; // TODO Make rank be a controlled vocab term, assuming that's how we'll implement it. final String TEST_RANK = "5"; // TODO Make status type be a controlled vocab term. final String TEST_STATUS = "Approved"; - /** The known resource id. */ private String knownResourceId = null; private String knownResourceShortIdentifer = null; @@ -98,27 +96,24 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI private String knownItemResourceId = null; private String knownItemResourceShortIdentifer = null; private String knownContactResourceId = null; - /** The n items to create in list. */ private int nItemsToCreateInList = 3; - /** The all resource ids created. */ private List allResourceIdsCreated = new ArrayList(); - /** The all item resource ids created. */ private Map allItemResourceIdsCreated = - new HashMap(); - - protected void setKnownResource( String id, String shortIdentifer, - String refName ) { - knownResourceId = id; - knownResourceShortIdentifer = shortIdentifer; - knownResourceRefName = refName; + new HashMap(); + + protected void setKnownResource(String id, String shortIdentifer, + String refName) { + knownResourceId = id; + knownResourceShortIdentifer = shortIdentifer; + knownResourceRefName = refName; } - protected void setKnownItemResource( String id, String shortIdentifer ) { - knownItemResourceId = id; - knownItemResourceShortIdentifer = shortIdentifer; + protected void setKnownItemResource(String id, String shortIdentifer) { + knownItemResourceId = id; + knownItemResourceShortIdentifer = shortIdentifer; } /* (non-Javadoc) @@ -126,31 +121,31 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI */ @Override protected CollectionSpaceClient getClientInstance() { - return new TaxonomyAuthorityClient(); + return new TaxonomyAuthorityClient(); } - + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) */ @Override - protected AbstractCommonList getAbstractCommonList( - ClientResponse response) { + protected AbstractCommonList getAbstractCommonList( + ClientResponse response) { return response.getEntity(TaxonCommonList.class); } @Override protected PoxPayloadOut createInstance(String identifier) { - TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); + TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); String shortId = identifier; - String displayName = "displayName-" + shortId; - String baseRefName = - TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null); - PoxPayloadOut multipart = - TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance( - displayName, shortId, client.getCommonPartName()); - return multipart; + String displayName = "displayName-" + shortId; + String baseRefName = + TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null); + PoxPayloadOut multipart = + TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance( + displayName, shortId, client.getCommonPartName()); + return multipart; } - + // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- @@ -159,8 +154,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"create"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"create"}) public void create(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -174,39 +169,39 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Submit the request to the service and store the response. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); String shortId = createIdentifier(); - String displayName = "displayName-" + shortId; - String baseRefName = - TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null); - - PoxPayloadOut multipart = - TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance( - displayName, shortId, client.getCommonPartName()); - String newID = null; + String displayName = "displayName-" + shortId; + String baseRefName = + TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null); + + PoxPayloadOut multipart = + TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance( + displayName, shortId, client.getCommonPartName()); + String newID = null; ClientResponse res = client.create(multipart); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - // - // Specifically: - // Does it fall within the set of valid status codes? - // Does it exactly match the expected status code? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE); - - newID = TaxonomyAuthorityClientUtils.extractId(res); + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + // + // Specifically: + // Does it fall within the set of valid status codes? + // Does it exactly match the expected status code? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE); + + newID = TaxonomyAuthorityClientUtils.extractId(res); } finally { - res.releaseConnection(); + res.releaseConnection(); } // Store the ID returned from the first resource created // for additional tests below. - if (knownResourceId == null){ - setKnownResource( newID, shortId, baseRefName ); + if (knownResourceId == null) { + setKnownResource(newID, shortId, baseRefName); if (logger.isDebugEnabled()) { logger.debug(testName + ": knownResourceId=" + knownResourceId); } @@ -221,10 +216,10 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * * @param testName the test name */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"create"}, dependsOnMethods = {"create"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"create"}, dependsOnMethods = {"create"}) public void createItem(String testName) { - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testBanner(testName, CLASS_NAME)); } setupCreate(); @@ -240,26 +235,28 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI */ private String createItemInAuthority(String vcsid, String authRefName) { - final String testName = "createItemInAuthority("+vcsid+","+authRefName+")"; - if(logger.isDebugEnabled()){ + final String testName = "createItemInAuthority(" + vcsid + "," + authRefName + ")"; + if (logger.isDebugEnabled()) { logger.debug(testBanner(testName, CLASS_NAME)); } // Submit the request to the service and store the response. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); - Map shelf1Map = new HashMap(); + Map taxonMap = new HashMap(); // TODO Make loc type and status be controlled vocabs. - shelf1Map.put(TaxonomyJAXBSchema.NAME, TEST_NAME); - shelf1Map.put(TaxonomyJAXBSchema.RANK, TEST_RANK); - shelf1Map.put(TaxonomyJAXBSchema.TERM_STATUS, TEST_STATUS); - + taxonMap.put(TaxonomyJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID); + taxonMap.put(TaxonomyJAXBSchema.NAME, TEST_NAME); + taxonMap.put(TaxonomyJAXBSchema.RANK, TEST_RANK); + taxonMap.put(TaxonomyJAXBSchema.TERM_STATUS, TEST_STATUS); + // FIXME: Add additional fields in the Taxon record here. + String newID = TaxonomyAuthorityClientUtils.createItemInAuthority(vcsid, - authRefName, shelf1Map, client ); + authRefName, taxonMap, client); // Store the ID returned from the first item resource created // for additional tests below. - if (knownItemResourceId == null){ - setKnownItemResource(newID, TEST_SHORTID); + if (knownItemResourceId == null) { + setKnownItemResource(newID, TEST_SHORTID); if (logger.isDebugEnabled()) { logger.debug(testName + ": knownItemResourceId=" + newID); } @@ -273,10 +270,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI return newID; } - - // Failure outcomes - // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. /* (non-Javadoc) @@ -300,17 +294,16 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI public void createWithWrongXmlSchema(String testName) throws Exception { } - // --------------------------------------------------------------- // CRUD tests : CREATE LIST tests // --------------------------------------------------------------- // Success outcomes /* (non-Javadoc) - * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String) - */ + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String) + */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"createList"}, dependsOnGroups = {"create"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"createList"}, dependsOnGroups = {"create"}) public void createList(String testName) throws Exception { for (int i = 0; i < nItemsToCreateInList; i++) { create(testName); @@ -323,8 +316,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @param testName the test name * @throws Exception the exception */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"createList"}, dependsOnMethods = {"createList"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"createList"}, dependsOnMethods = {"createList"}) public void createItemList(String testName) throws Exception { // Add items to the initially-created, known parent record. for (int j = 0; j < nItemsToCreateInList; j++) { @@ -340,8 +333,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"read"}, dependsOnGroups = {"create"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"read"}, dependsOnGroups = {"create"}) public void read(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -349,34 +342,34 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI } // Perform setup. setupRead(); - + // Submit the request to the service and store the response. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); - String newID = null; + String newID = null; ClientResponse res = client.read(knownResourceId); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - //FIXME: remove the following try catch once Aron fixes signatures - try { - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - TaxonomyauthorityCommon taxonomyAuthority = - (TaxonomyauthorityCommon) extractPart(input, - client.getCommonPartName(), TaxonomyauthorityCommon.class); - Assert.assertNotNull(taxonomyAuthority); - } catch (Exception e) { - throw new RuntimeException(e); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + //FIXME: remove the following try catch once Aron fixes signatures + try { + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + TaxonomyauthorityCommon taxonomyAuthority = + (TaxonomyauthorityCommon) extractPart(input, + client.getCommonPartName(), TaxonomyauthorityCommon.class); + Assert.assertNotNull(taxonomyAuthority); + } catch (Exception e) { + throw new RuntimeException(e); + } } finally { - res.releaseConnection(); + res.releaseConnection(); } } @@ -386,12 +379,12 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @param testName the test name * @throws Exception the exception */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"read"}, dependsOnGroups = {"create"}) - public void readByName(String testName) throws Exception { + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"read"}, dependsOnGroups = {"create"}) + public void readByName(String testName) throws Exception { if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName+"("+knownResourceShortIdentifer+")", CLASS_NAME)); + logger.debug(testBanner(testName + "(" + knownResourceShortIdentifer + ")", CLASS_NAME)); } // Perform setup. setupRead(); @@ -400,39 +393,38 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.readByName(knownResourceShortIdentifer); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - //FIXME: remove the following try catch once Aron fixes signatures - try { - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - TaxonomyauthorityCommon taxonomyAuthority = (TaxonomyauthorityCommon) extractPart(input, - client.getCommonPartName(), TaxonomyauthorityCommon.class); - Assert.assertNotNull(taxonomyAuthority); - } catch (Exception e) { - throw new RuntimeException(e); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + //FIXME: remove the following try catch once Aron fixes signatures + try { + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + TaxonomyauthorityCommon taxonomyAuthority = (TaxonomyauthorityCommon) extractPart(input, + client.getCommonPartName(), TaxonomyauthorityCommon.class); + Assert.assertNotNull(taxonomyAuthority); + } catch (Exception e) { + throw new RuntimeException(e); + } } finally { - res.releaseConnection(); + res.releaseConnection(); } } - /** - * Read item. - * - * @param testName the test name - * @throws Exception the exception - */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"read"}, dependsOnMethods = {"read"}) + * Read item. + * + * @param testName the test name + * @throws Exception the exception + */ + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"read"}, dependsOnMethods = {"read"}) public void readItem(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -445,32 +437,36 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - // Check whether we've received a taxonomy. - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - TaxonCommon taxonomy = (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(taxonomy); - boolean showFull = true; - if(showFull && logger.isDebugEnabled()){ - logger.debug(testName + ": returned payload:"); - logger.debug(objectAsXmlString(taxonomy, TaxonCommon.class)); - } - Assert.assertEquals(taxonomy.getInAuthority(), knownResourceId); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Check whether we've received a taxon. + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + String xml = input.getXmlPayload(); // for debugging + if (logger.isDebugEnabled()) { // for debugging + logger.debug(testName + "#########" + xml); + } + String cpn = client.getItemCommonPartName(); // for debugging + TaxonCommon taxon = (TaxonCommon) extractPart(input, + client.getItemCommonPartName(), TaxonCommon.class); + Assert.assertNotNull(taxon); + boolean showFull = true; + if (showFull && logger.isDebugEnabled()) { + logger.debug(testName + ": returned payload:"); + logger.debug(objectAsXmlString(taxon, TaxonCommon.class)); + } + Assert.assertEquals(taxon.getInAuthority(), knownResourceId); + } finally { + res.releaseConnection(); + } } /** @@ -479,8 +475,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @param testName the test name * @throws Exception the exception */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"readItem", "updateItem"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"readItem", "updateItem"}) public void verifyItemDisplayName(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -493,103 +489,103 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - // Check whether taxonomy has expected displayName. - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - TaxonCommon taxonomy = (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(taxonomy); - String displayName = taxonomy.getDisplayName(); - // Make sure displayName matches computed form - String expectedDisplayName = - TaxonomyAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME); - Assert.assertNotNull(displayName, expectedDisplayName); - - // Update the shortName and verify the computed name is updated. - taxonomy.setCsid(null); - taxonomy.setDisplayNameComputed(true); - taxonomy.setTaxonFullName("updated-" + TEST_NAME); - expectedDisplayName = - TaxonomyAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME); - - // Submit the updated resource to the service and store the response. - PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - PayloadOutputPart commonPart = output.addPart(taxonomy, MediaType.APPLICATION_XML_TYPE); - commonPart.setLabel(client.getItemCommonPartName()); - res.releaseConnection(); - res = client.updateItem(knownResourceId, knownItemResourceId, output); - statusCode = res.getStatus(); - - // Check the status code of the response: does it match the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("updateItem: status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - // Retrieve the updated resource and verify that its contents exist. - input = new PoxPayloadIn(res.getEntity()); - TaxonCommon updatedTaxonomy = - (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(updatedTaxonomy); - - // Verify that the updated resource received the correct data. - Assert.assertEquals(updatedTaxonomy.getTaxonFullName(), taxonomy.getTaxonFullName(), - "Updated ForeName in Taxonomy did not match submitted data."); - // Verify that the updated resource computes the right displayName. - Assert.assertEquals(updatedTaxonomy.getDisplayName(), expectedDisplayName, - "Updated ForeName in Taxonomy not reflected in computed DisplayName."); - - // Now Update the displayName, not computed and verify the computed name is overriden. - taxonomy.setDisplayNameComputed(false); - expectedDisplayName = "TestName"; - taxonomy.setDisplayName(expectedDisplayName); - - // Submit the updated resource to the service and store the response. - output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - commonPart = output.addPart(taxonomy, MediaType.APPLICATION_XML_TYPE); - commonPart.setLabel(client.getItemCommonPartName()); - res.releaseConnection(); - res = client.updateItem(knownResourceId, knownItemResourceId, output); - statusCode = res.getStatus(); - - // Check the status code of the response: does it match the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("updateItem: status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - // Retrieve the updated resource and verify that its contents exist. - input = new PoxPayloadIn(res.getEntity()); - updatedTaxonomy = - (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(updatedTaxonomy); - - // Verify that the updated resource received the correct data. - Assert.assertEquals(updatedTaxonomy.isDisplayNameComputed(), false, - "Updated displayNameComputed in Taxonomy did not match submitted data."); - // Verify that the updated resource computes the right displayName. - Assert.assertEquals(updatedTaxonomy.getDisplayName(), - expectedDisplayName, - "Updated DisplayName (not computed) in Taxonomy not stored."); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Check whether taxon has expected displayName. + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + TaxonCommon taxon = (TaxonCommon) extractPart(input, + client.getItemCommonPartName(), TaxonCommon.class); + Assert.assertNotNull(taxon); + String displayName = taxon.getDisplayName(); + // Make sure displayName matches computed form + String expectedDisplayName = + TaxonomyAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME); + Assert.assertNotNull(displayName, expectedDisplayName); + + // Update the shortName and verify the computed name is updated. + taxon.setCsid(null); + taxon.setDisplayNameComputed(true); + taxon.setTaxonFullName("updated-" + TEST_NAME); + expectedDisplayName = + TaxonomyAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME); + + // Submit the updated resource to the service and store the response. + PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(taxon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getItemCommonPartName()); + res.releaseConnection(); + res = client.updateItem(knownResourceId, knownItemResourceId, output); + statusCode = res.getStatus(); + + // Check the status code of the response: does it match the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug("updateItem: status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Retrieve the updated resource and verify that its contents exist. + input = new PoxPayloadIn(res.getEntity()); + TaxonCommon updatedTaxon = + (TaxonCommon) extractPart(input, + client.getItemCommonPartName(), TaxonCommon.class); + Assert.assertNotNull(updatedTaxon); + + // Verify that the updated resource received the correct data. + Assert.assertEquals(updatedTaxon.getTaxonFullName(), taxon.getTaxonFullName(), + "Updated ForeName in Taxonomy did not match submitted data."); + // Verify that the updated resource computes the right displayName. + Assert.assertEquals(updatedTaxon.getDisplayName(), expectedDisplayName, + "Updated ForeName in Taxonomy not reflected in computed DisplayName."); + + // Now Update the displayName, not computed and verify the computed name is overriden. + taxon.setDisplayNameComputed(false); + expectedDisplayName = "TestName"; + taxon.setDisplayName(expectedDisplayName); + + // Submit the updated resource to the service and store the response. + output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + commonPart = output.addPart(taxon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getItemCommonPartName()); + res.releaseConnection(); + res = client.updateItem(knownResourceId, knownItemResourceId, output); + statusCode = res.getStatus(); + + // Check the status code of the response: does it match the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug("updateItem: status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Retrieve the updated resource and verify that its contents exist. + input = new PoxPayloadIn(res.getEntity()); + updatedTaxon = + (TaxonCommon) extractPart(input, + client.getItemCommonPartName(), TaxonCommon.class); + Assert.assertNotNull(updatedTaxon); + + // Verify that the updated resource received the correct data. + Assert.assertEquals(updatedTaxon.isDisplayNameComputed(), false, + "Updated displayNameComputed in Taxonomy did not match submitted data."); + // Verify that the updated resource computes the right displayName. + Assert.assertEquals(updatedTaxon.getDisplayName(), + expectedDisplayName, + "Updated DisplayName (not computed) in Taxonomy not stored."); + } finally { + res.releaseConnection(); + } } /** @@ -598,8 +594,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @param testName the test name * @throws Exception the exception */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"verifyItemDisplayName"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"verifyItemDisplayName"}) public void verifyIllegalItemDisplayName(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -607,60 +603,59 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI } // Perform setup. // FIXME: create a setup configuration for this operation. - setupUpdateWithWrongXmlSchema(); + setupUpdateWithWrongXmlSchema(); // Submit the request to the service and store the response. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode()); - - // Check whether Taxonomy has expected displayName. - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - TaxonCommon taxonomy = (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(taxonomy); - // Try to Update with computed false and no displayName - taxonomy.setDisplayNameComputed(false); - taxonomy.setDisplayName(null); - - // Submit the updated resource to the service and store the response. - PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - PayloadOutputPart commonPart = output.addPart(taxonomy, MediaType.APPLICATION_XML_TYPE); - commonPart.setLabel(client.getItemCommonPartName()); - res.releaseConnection(); - res = client.updateItem(knownResourceId, knownItemResourceId, output); - statusCode = res.getStatus(); - - // Check the status code of the response: does it match the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("updateItem: status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode()); + + // Check whether Taxonomy has expected displayName. + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + TaxonCommon taxon = (TaxonCommon) extractPart(input, + client.getItemCommonPartName(), TaxonCommon.class); + Assert.assertNotNull(taxon); + // Try to Update with computed false and no displayName + taxon.setDisplayNameComputed(false); + taxon.setDisplayName(null); + + // Submit the updated resource to the service and store the response. + PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(taxon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getItemCommonPartName()); + res.releaseConnection(); + res = client.updateItem(knownResourceId, knownItemResourceId, output); + statusCode = res.getStatus(); + + // Check the status code of the response: does it match the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug("updateItem: status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } } - // Failure outcomes /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"read"}, dependsOnMethods = {"read"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"read"}, dependsOnMethods = {"read"}) public void readNonExistent(String testName) { if (logger.isDebugEnabled()) { @@ -673,19 +668,19 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.read(NON_EXISTENT_ID); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } } /** @@ -693,8 +688,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * * @param testName the test name */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"read"}, dependsOnMethods = {"readItem"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"read"}, dependsOnMethods = {"readItem"}) public void readItemNonExistent(String testName) { if (logger.isDebugEnabled()) { @@ -707,21 +702,20 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, NON_EXISTENT_ID); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } - } + int statusCode = res.getStatus(); + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } + } // --------------------------------------------------------------- // CRUD tests : READ_LIST tests @@ -732,8 +726,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"readList"}, dependsOnGroups = {"createList", "read"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"readList"}, dependsOnGroups = {"createList", "read"}) public void readList(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -746,39 +740,39 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.readList(); try { - TaxonomyauthorityCommonList list = res.getEntity(); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if (iterateThroughList && logger.isDebugEnabled()) { - List items = - list.getTaxonomyauthorityListItem(); - int i = 0; - for (TaxonomyauthorityCommonList.TaxonomyauthorityListItem item : items) { - String csid = item.getCsid(); - logger.debug(testName + ": list-item[" + i + "] csid=" + - csid); - logger.debug(testName + ": list-item[" + i + "] displayName=" + - item.getDisplayName()); - logger.debug(testName + ": list-item[" + i + "] URI=" + - item.getUri()); - readItemList(csid, null); - i++; - } - } - } finally { - res.releaseConnection(); - } + TaxonomyauthorityCommonList list = res.getEntity(); + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Optionally output additional data about list members for debugging. + boolean iterateThroughList = false; + if (iterateThroughList && logger.isDebugEnabled()) { + List items = + list.getTaxonomyauthorityListItem(); + int i = 0; + for (TaxonomyauthorityCommonList.TaxonomyauthorityListItem item : items) { + String csid = item.getCsid(); + logger.debug(testName + ": list-item[" + i + "] csid=" + + csid); + logger.debug(testName + ": list-item[" + i + "] displayName=" + + item.getDisplayName()); + logger.debug(testName + ": list-item[" + i + "] URI=" + + item.getUri()); + readItemList(csid, null); + i++; + } + } + } finally { + res.releaseConnection(); + } } /** @@ -804,7 +798,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI } readItemList(null, knownResourceShortIdentifer); } - + /** * Read item list. * @@ -817,73 +811,71 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Perform setup. setupReadList(); - + // Submit the request to the service and store the response. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = null; - if(vcsid!= null) { - res = client.readItemList(vcsid, null, null); - } else if(shortId!= null) { - res = client.readItemListForNamedAuthority(shortId, null, null); + if (vcsid != null) { + res = client.readItemList(vcsid, null, null); + } else if (shortId != null) { + res = client.readItemListForNamedAuthority(shortId, null, null); } else { - Assert.fail("readItemList passed null csid and name!"); + Assert.fail("readItemList passed null csid and name!"); } try { - TaxonCommonList list = res.getEntity(); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - List items = - list.getTaxonListItem(); - int nItemsReturned = items.size(); - // There will be one item created, associated with a - // known parent resource, by the createItem test. - // - // In addition, there will be 'nItemsToCreateInList' - // additional items created by the createItemList test, - // all associated with the same parent resource. - int nExpectedItems = nItemsToCreateInList + 1; - if(logger.isDebugEnabled()){ - logger.debug(testName + ": Expected " - + nExpectedItems +" items; got: "+nItemsReturned); - } - Assert.assertEquals(nItemsReturned, nExpectedItems); - - int i = 0; - for (TaxonCommonList.TaxonListItem item : items) { - Assert.assertTrue((null != item.getRefName()), "Item refName is null!"); - Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!"); - // Optionally output additional data about list members for debugging. - boolean showDetails = true; - if (showDetails && logger.isDebugEnabled()) { - logger.debug(" " + testName + ": list-item[" + i + "] csid=" + - item.getCsid()); - logger.debug(" " + testName + ": list-item[" + i + "] refName=" + - item.getRefName()); - logger.debug(" " + testName + ": list-item[" + i + "] displayName=" + - item.getDisplayName()); - logger.debug(" " + testName + ": list-item[" + i + "] URI=" + - item.getUri()); - } - i++; - } - } finally { - res.releaseConnection(); - } - } + TaxonCommonList list = res.getEntity(); + int statusCode = res.getStatus(); + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + List items = + list.getTaxonListItem(); + int nItemsReturned = items.size(); + // There will be one item created, associated with a + // known parent resource, by the createItem test. + // + // In addition, there will be 'nItemsToCreateInList' + // additional items created by the createItemList test, + // all associated with the same parent resource. + int nExpectedItems = nItemsToCreateInList + 1; + if (logger.isDebugEnabled()) { + logger.debug(testName + ": Expected " + + nExpectedItems + " items; got: " + nItemsReturned); + } + Assert.assertEquals(nItemsReturned, nExpectedItems); + + int i = 0; + for (TaxonCommonList.TaxonListItem item : items) { + Assert.assertTrue((null != item.getRefName()), "Item refName is null!"); + Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!"); + // Optionally output additional data about list members for debugging. + boolean showDetails = true; + if (showDetails && logger.isDebugEnabled()) { + logger.debug(" " + testName + ": list-item[" + i + "] csid=" + + item.getCsid()); + logger.debug(" " + testName + ": list-item[" + i + "] refName=" + + item.getRefName()); + logger.debug(" " + testName + ": list-item[" + i + "] displayName=" + + item.getDisplayName()); + logger.debug(" " + testName + ": list-item[" + i + "] URI=" + + item.getUri()); + } + i++; + } + } finally { + res.releaseConnection(); + } + } // Failure outcomes // None at present. - // --------------------------------------------------------------- // CRUD tests : UPDATE tests // --------------------------------------------------------------- @@ -892,8 +884,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"update"}, dependsOnGroups = {"read", "readList"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"update"}, dependsOnGroups = {"read", "readList"}) public void update(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -906,57 +898,57 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.read(knownResourceId); try { - if(logger.isDebugEnabled()){ - logger.debug(testName + ": read status = " + res.getStatus()); - } - Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); - - if(logger.isDebugEnabled()){ - logger.debug("got TaxonomyAuthority to update with ID: " + knownResourceId); - } - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - TaxonomyauthorityCommon taxonomyAuthority = (TaxonomyauthorityCommon) extractPart(input, - client.getCommonPartName(), TaxonomyauthorityCommon.class); - Assert.assertNotNull(taxonomyAuthority); - - // Update the contents of this resource. - taxonomyAuthority.setDisplayName("updated-" + taxonomyAuthority.getDisplayName()); - taxonomyAuthority.setVocabType("updated-" + taxonomyAuthority.getVocabType()); - if(logger.isDebugEnabled()){ - logger.debug("to be updated TaxonomyAuthority"); - logger.debug(objectAsXmlString(taxonomyAuthority, TaxonomyauthorityCommon.class)); - } - - // Submit the updated resource to the service and store the response. - PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_PAYLOAD_NAME); - PayloadOutputPart commonPart = output.addPart(taxonomyAuthority, MediaType.APPLICATION_XML_TYPE); - commonPart.setLabel(client.getCommonPartName()); - res.releaseConnection(); - res = client.update(knownResourceId, output); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - // Retrieve the updated resource and verify that its contents exist. - input = new PoxPayloadIn(res.getEntity()); - TaxonomyauthorityCommon updatedTaxonomyAuthority = - (TaxonomyauthorityCommon) extractPart(input, - client.getCommonPartName(), TaxonomyauthorityCommon.class); - Assert.assertNotNull(updatedTaxonomyAuthority); - - // Verify that the updated resource received the correct data. - Assert.assertEquals(updatedTaxonomyAuthority.getDisplayName(), - taxonomyAuthority.getDisplayName(), - "Data in updated object did not match submitted data."); - } finally { - res.releaseConnection(); - } + if (logger.isDebugEnabled()) { + logger.debug(testName + ": read status = " + res.getStatus()); + } + Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); + + if (logger.isDebugEnabled()) { + logger.debug("got TaxonomyAuthority to update with ID: " + knownResourceId); + } + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + TaxonomyauthorityCommon taxonomyAuthority = (TaxonomyauthorityCommon) extractPart(input, + client.getCommonPartName(), TaxonomyauthorityCommon.class); + Assert.assertNotNull(taxonomyAuthority); + + // Update the contents of this resource. + taxonomyAuthority.setDisplayName("updated-" + taxonomyAuthority.getDisplayName()); + taxonomyAuthority.setVocabType("updated-" + taxonomyAuthority.getVocabType()); + if (logger.isDebugEnabled()) { + logger.debug("to be updated TaxonomyAuthority"); + logger.debug(objectAsXmlString(taxonomyAuthority, TaxonomyauthorityCommon.class)); + } + + // Submit the updated resource to the service and store the response. + PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(taxonomyAuthority, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getCommonPartName()); + res.releaseConnection(); + res = client.update(knownResourceId, output); + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Retrieve the updated resource and verify that its contents exist. + input = new PoxPayloadIn(res.getEntity()); + TaxonomyauthorityCommon updatedTaxonomyAuthority = + (TaxonomyauthorityCommon) extractPart(input, + client.getCommonPartName(), TaxonomyauthorityCommon.class); + Assert.assertNotNull(updatedTaxonomyAuthority); + + // Verify that the updated resource received the correct data. + Assert.assertEquals(updatedTaxonomyAuthority.getDisplayName(), + taxonomyAuthority.getDisplayName(), + "Data in updated object did not match submitted data."); + } finally { + res.releaseConnection(); + } } /** @@ -965,8 +957,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @param testName the test name * @throws Exception the exception */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"update"}, dependsOnMethods = {"update"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"update"}, dependsOnMethods = {"update"}) public void updateItem(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -980,59 +972,59 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); try { - if(logger.isDebugEnabled()){ - logger.debug(testName + ": read status = " + res.getStatus()); - } - Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); - - if(logger.isDebugEnabled()){ - logger.debug("got Taxonomy to update with ID: " + - knownItemResourceId + - " in TaxonomyAuthority: " + knownResourceId ); - } - PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); - TaxonCommon taxonomy = (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(taxonomy); - - // Update the contents of this resource. - taxonomy.setCsid(null); - taxonomy.setTaxonFullName("updated-" + taxonomy.getTaxonFullName()); - if(logger.isDebugEnabled()){ - logger.debug("to be updated Taxonomy"); - logger.debug(objectAsXmlString(taxonomy, - TaxonCommon.class)); - } - - // Submit the updated resource to the service and store the response. - PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); - PayloadOutputPart commonPart = output.addPart(taxonomy, MediaType.APPLICATION_XML_TYPE); - commonPart.setLabel(client.getItemCommonPartName()); - res.releaseConnection(); - res = client.updateItem(knownResourceId, knownItemResourceId, output); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - - // Retrieve the updated resource and verify that its contents exist. - input = new PoxPayloadIn(res.getEntity()); - TaxonCommon updatedTaxonomy = - (TaxonCommon) extractPart(input, - client.getItemCommonPartName(), TaxonCommon.class); - Assert.assertNotNull(updatedTaxonomy); - - // Verify that the updated resource received the correct data. - Assert.assertEquals(updatedTaxonomy.getTaxonFullName(), taxonomy.getTaxonFullName(), - "Data in updated Taxonomy did not match submitted data."); - } finally { - res.releaseConnection(); - } + if (logger.isDebugEnabled()) { + logger.debug(testName + ": read status = " + res.getStatus()); + } + Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); + + if (logger.isDebugEnabled()) { + logger.debug("got Taxonomy to update with ID: " + + knownItemResourceId + + " in TaxonomyAuthority: " + knownResourceId); + } + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + TaxonCommon taxon = (TaxonCommon) extractPart(input, + client.getItemCommonPartName(), TaxonCommon.class); + Assert.assertNotNull(taxon); + + // Update the contents of this resource. + taxon.setCsid(null); + taxon.setTaxonFullName("updated-" + taxon.getTaxonFullName()); + if (logger.isDebugEnabled()) { + logger.debug("to be updated Taxonomy"); + logger.debug(objectAsXmlString(taxon, + TaxonCommon.class)); + } + + // Submit the updated resource to the service and store the response. + PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(taxon, MediaType.APPLICATION_XML_TYPE); + commonPart.setLabel(client.getItemCommonPartName()); + res.releaseConnection(); + res = client.updateItem(knownResourceId, knownItemResourceId, output); + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Retrieve the updated resource and verify that its contents exist. + input = new PoxPayloadIn(res.getEntity()); + TaxonCommon updatedTaxon = + (TaxonCommon) extractPart(input, + client.getItemCommonPartName(), TaxonCommon.class); + Assert.assertNotNull(updatedTaxon); + + // Verify that the updated resource received the correct data. + Assert.assertEquals(updatedTaxon.getTaxonFullName(), taxon.getTaxonFullName(), + "Data in updated Taxonomy did not match submitted data."); + } finally { + res.releaseConnection(); + } } // Failure outcomes @@ -1061,11 +1053,11 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI /* (non-Javadoc) - * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String) - */ -@Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String) + */ + @Override + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -1079,24 +1071,24 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // The only relevant ID may be the one used in update(), below. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); String displayName = "displayName-NON_EXISTENT_ID"; - PoxPayloadOut multipart = TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance( - displayName, "nonEx", client.getCommonPartName()); + PoxPayloadOut multipart = TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance( + displayName, "nonEx", client.getCommonPartName()); ClientResponse res = client.update(NON_EXISTENT_ID, multipart); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } } /** @@ -1105,8 +1097,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @param testName the test name * @throws Exception the exception */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"}) public void updateNonExistentItem(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -1119,49 +1111,47 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); - Map nonexMap = new HashMap(); + Map nonexMap = new HashMap(); nonexMap.put(TaxonomyJAXBSchema.NAME, TEST_NAME); nonexMap.put(TaxonomyJAXBSchema.SHORT_IDENTIFIER, "nonEx"); nonexMap.put(TaxonomyJAXBSchema.TERM_STATUS, TEST_STATUS); - PoxPayloadOut multipart = - TaxonomyAuthorityClientUtils.createTaxonomyInstance( - TaxonomyAuthorityClientUtils.createTaxonomyRefName(knownResourceRefName, "nonEx", "Non Existent"), - nonexMap, client.getItemCommonPartName() ); + PoxPayloadOut multipart = + TaxonomyAuthorityClientUtils.createTaxonInstance( + TaxonomyAuthorityClientUtils.createTaxonomyRefName(knownResourceRefName, "nonEx", "Non Existent"), + nonexMap, client.getItemCommonPartName()); ClientResponse res = client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } } // --------------------------------------------------------------- // CRUD tests : DELETE tests // --------------------------------------------------------------- // Success outcomes - // Note: delete sub-resources in ascending hierarchical order, // before deleting their parents. - - /** - * Delete item. - * - * @param testName the test name - * @throws Exception the exception - */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - //groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"}) - groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"}) + /** + * Delete item. + * + * @param testName the test name + * @throws Exception the exception + */ + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + //groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"}) + groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"}) public void deleteItem(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -1170,37 +1160,37 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Perform setup. setupDelete(); - if(logger.isDebugEnabled()){ - logger.debug("parentcsid =" + knownResourceId + - " itemcsid = " + knownItemResourceId); + if (logger.isDebugEnabled()) { + logger.debug("parentcsid =" + knownResourceId + + " itemcsid = " + knownItemResourceId); } // Submit the request to the service and store the response. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); - ClientResponse res = - client.deleteItem(knownResourceId, knownItemResourceId); + ClientResponse res = + client.deleteItem(knownResourceId, knownItemResourceId); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"delete"}, dependsOnMethods = {"deleteItem"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"delete"}, dependsOnMethods = {"deleteItem"}) public void delete(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -1209,7 +1199,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Perform setup. setupDelete(); - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug("parentcsid =" + knownResourceId); } @@ -1217,19 +1207,19 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.delete(knownResourceId); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } } // Failure outcomes @@ -1237,8 +1227,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"delete"}, dependsOnMethods = {"delete"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"delete"}, dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -1251,19 +1241,19 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } } /** @@ -1271,8 +1261,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * * @param testName the test name */ - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - groups = {"delete"}, dependsOnMethods = {"deleteItem"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + groups = {"delete"}, dependsOnMethods = {"deleteItem"}) public void deleteNonExistentItem(String testName) { if (logger.isDebugEnabled()) { @@ -1285,19 +1275,19 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); ClientResponse res = client.deleteItem(knownResourceId, NON_EXISTENT_ID); try { - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } finally { - res.releaseConnection(); - } + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } finally { + res.releaseConnection(); + } } // --------------------------------------------------------------- @@ -1320,9 +1310,9 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("testSubmitRequest: url=" + url + - " status=" + statusCode); + if (logger.isDebugEnabled()) { + logger.debug("testSubmitRequest: url=" + url + + " status=" + statusCode); } Assert.assertEquals(statusCode, EXPECTED_STATUS); @@ -1344,9 +1334,9 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("testItemSubmitRequest: url=" + url + - " status=" + statusCode); + if (logger.isDebugEnabled()) { + logger.debug("testItemSubmitRequest: url=" + url + + " status=" + statusCode); } Assert.assertEquals(statusCode, EXPECTED_STATUS); @@ -1355,7 +1345,6 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // --------------------------------------------------------------- // Cleanup of resources created during testing // --------------------------------------------------------------- - /** * Deletes all resources created by tests, after all tests have been run. * @@ -1364,16 +1353,15 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * at any point during testing, even if some of those resources * may be expected to be deleted by certain tests. */ - - @AfterClass(alwaysRun=true) + @AfterClass(alwaysRun = true) public void cleanUp() { String noTest = System.getProperty("noTestCleanup"); - if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { + if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { if (logger.isDebugEnabled()) { logger.debug("Skipping Cleanup phase ..."); } return; - } + } if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } @@ -1389,15 +1377,15 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Note: Any non-success responses from the delete operation // below are ignored and not reported. ClientResponse res = - client.deleteItem(parentResourceId, itemResourceId); - res.releaseConnection(); + client.deleteItem(parentResourceId, itemResourceId); + res.releaseConnection(); } // Clean up parent resources. for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses from the delete operation // below are ignored and not reported. ClientResponse res = client.delete(resourceId); - res.releaseConnection(); + res.releaseConnection(); } } @@ -1407,7 +1395,6 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() */ - /** * Returns the root URL for the item service. * @@ -1439,6 +1426,4 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) { return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier; } - - } diff --git a/services/taxonomy/jaxb/src/main/java/org/collectionspace/services/TaxonomyJAXBSchema.java b/services/taxonomy/jaxb/src/main/java/org/collectionspace/services/TaxonomyJAXBSchema.java index c1aa4a368..94f24a51b 100644 --- a/services/taxonomy/jaxb/src/main/java/org/collectionspace/services/TaxonomyJAXBSchema.java +++ b/services/taxonomy/jaxb/src/main/java/org/collectionspace/services/TaxonomyJAXBSchema.java @@ -5,7 +5,7 @@ package org.collectionspace.services; import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; public interface TaxonomyJAXBSchema extends AuthorityItemJAXBSchema { - final static String TAXONOMY_COMMON = "taxonomy_common"; + final static String TAXON_COMMON = "taxon_common"; final static String NAME = "taxonFullName"; final static String RANK = "taxonRank"; diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java index ea1bb16ef..52be61353 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java @@ -117,6 +117,7 @@ public class TaxonomyAuthorityResource * * @return the item service name */ + @Override public String getItemServiceName() { return taxonomyItemServiceName; } -- 2.47.3