From: Aron Roberts Date: Thu, 12 May 2011 04:10:37 +0000 (+0000) Subject: CSPACE-3865: Added repeatables to client tests of Taxonomy service; also useful to... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=d3e1c00ee68972a17d2bb5477559d2d449e9372f;p=tmp%2Fjakarta-migration.git CSPACE-3865: Added repeatables to client tests of Taxonomy service; also useful to create samples for verification of work to be done in other layers. --- 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 c3209cd5e..f68033e3b 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 @@ -13,6 +13,8 @@ import javax.ws.rs.core.Response; import org.apache.commons.io.FileUtils; import org.collectionspace.services.TaxonJAXBSchema; import org.collectionspace.services.client.test.ServiceRequestType; +import org.collectionspace.services.taxonomy.TaxonAuthorGroupList; +import org.collectionspace.services.taxonomy.TaxonCitationList; import org.collectionspace.services.taxonomy.TaxonCommon; import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon; import org.dom4j.DocumentException; @@ -56,11 +58,14 @@ public class TaxonomyAuthorityClientUtils { /** * @param taxonomyAuthRefName The proper refName for this authority. * @param taxonInfo the properties for the new instance of a term in this authority. + * @param taxonAuthorGroupList an author group list (values of a repeatable group in the term record). + * @param taxonCitationList a citation list (values of a repeatable scalar in the term record). * @param headerLabel The common part label * @return The PoxPayloadOut payload for the create call */ public static PoxPayloadOut createTaxonInstance( String taxonomyAuthRefName, Map taxonInfo, + TaxonAuthorGroupList taxonAuthorGroupList, TaxonCitationList taxonCitationList, String headerLabel) { TaxonCommon taxon = new TaxonCommon(); String shortId = taxonInfo.get(TaxonJAXBSchema.SHORT_IDENTIFIER); @@ -93,12 +98,15 @@ public class TaxonomyAuthorityClientUtils { taxon.setTaxonomicStatus(value); } - // FIXME: Add additional fields in the Taxon record here, - // including at least one each of: - // * a repeatable field - // * a repeatable group of fields - // * a Boolean field - // * an authref field (when implemented) + if (taxonCitationList != null) { + taxon.setTaxonCitationList(taxonCitationList); + } + + if (taxonAuthorGroupList != null) { + taxon.setTaxonAuthorGroupList(taxonAuthorGroupList); + } + + // FIXME: Add the Boolean field isNamedHybrid in sample instances. PoxPayloadOut multipart = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME); PayloadOutputPart commonPart = multipart.addPart(taxon, @@ -121,7 +129,8 @@ public class TaxonomyAuthorityClientUtils { */ public static String createItemInAuthority(String vcsid, String TaxonomyauthorityRefName, Map taxonMap, - TaxonomyAuthorityClient client) { + TaxonAuthorGroupList taxonAuthorGroupList, + TaxonCitationList taxonCitationList, TaxonomyAuthorityClient client) { // Expected status code: 201 Created int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); // Type of service request being tested @@ -146,7 +155,7 @@ public class TaxonomyAuthorityClientUtils { } PoxPayloadOut multipart = createTaxonInstance(TaxonomyauthorityRefName, - taxonMap, client.getItemCommonPartName()); + taxonMap, taxonAuthorGroupList, taxonCitationList, client.getItemCommonPartName()); String newID = null; ClientResponse res = client.createItem(vcsid, multipart); try { 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 1d08c034a..c55861d43 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 @@ -36,6 +36,9 @@ import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.TaxonomyAuthorityClient; import org.collectionspace.services.client.TaxonomyAuthorityClientUtils; import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.taxonomy.TaxonAuthorGroup; +import org.collectionspace.services.taxonomy.TaxonAuthorGroupList; +import org.collectionspace.services.taxonomy.TaxonCitationList; import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon; import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList; import org.collectionspace.services.taxonomy.TaxonCommon; @@ -84,10 +87,15 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // TODO Re-implement the Taxon Rank field so as to provide an orderable // ranking value, as well as a display name. final String TEST_TAXON_RANK = "species"; + final String TEST_TAXON_AUTHOR = "J. Green"; + final String TEST_TAXON_AUTHOR_TYPE = "ascribed"; + final String TEST_TAXON_CITATION = "A Monograph of the Trilobites of North America"; final String TEST_TAXON_CURRENCY = "current"; final String TEST_TAXON_YEAR = "1832"; final String TEST_TAXONOMIC_STATUS = "valid"; final boolean TEST_TAXON_IS_NAMED_HYBRID = false; + final TaxonAuthorGroupList NULL_TAXON_AUTHOR_GROUP_LIST = null; + final TaxonCitationList NULL_TAXON_CITATION_LIST = null; /** The known resource id. */ private String knownResourceId = null; private String knownResourceShortIdentifer = null; @@ -254,6 +262,17 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI taxonMap.put(TaxonJAXBSchema.TAXON_CURRENCY, TEST_TAXON_CURRENCY); taxonMap.put(TaxonJAXBSchema.TAXON_YEAR, TEST_TAXON_YEAR); taxonMap.put(TaxonJAXBSchema.TAXONOMIC_STATUS, TEST_TAXONOMIC_STATUS); + + TaxonCitationList taxonCitationList = new TaxonCitationList(); + List taxonCitations = taxonCitationList.getTaxonCitation(); + taxonCitations.add(TEST_TAXON_CITATION); + + TaxonAuthorGroupList taxonAuthorGroupList = new TaxonAuthorGroupList(); + List taxonAuthorGroups = taxonAuthorGroupList.getTaxonAuthorGroup(); + TaxonAuthorGroup taxonAuthorGroup = new TaxonAuthorGroup(); + taxonAuthorGroup.setTaxonAuthor(TEST_TAXON_AUTHOR); + taxonAuthorGroup.setTaxonAuthorType(TEST_TAXON_AUTHOR_TYPE); + taxonAuthorGroups.add(taxonAuthorGroup); // FIXME: Add additional fields in the Taxon record here, // including at least one each of: @@ -263,7 +282,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // * an authref field (when implemented) String newID = TaxonomyAuthorityClientUtils.createItemInAuthority(vcsid, - authRefName, taxonMap, client); + authRefName, taxonMap, taxonAuthorGroupList, taxonCitationList, client); // Store the ID returned from the first item resource created // for additional tests below. @@ -1137,7 +1156,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI PoxPayloadOut multipart = TaxonomyAuthorityClientUtils.createTaxonInstance( TaxonomyAuthorityClientUtils.createTaxonomyRefName(knownResourceRefName, "nonEx", "Non Existent"), - nonexMap, client.getItemCommonPartName()); + nonexMap, NULL_TAXON_AUTHOR_GROUP_LIST, NULL_TAXON_CITATION_LIST, + client.getItemCommonPartName()); ClientResponse res = client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart); try { @@ -1208,8 +1228,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI * @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()) { @@ -1246,8 +1266,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()) {