From: Richard Millet Date: Wed, 7 Mar 2018 06:11:36 +0000 (-0800) Subject: DRYD-315: Added 'referenced' field to term list results to indicate if a term is... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=7b64d6e4973001baaa2ce83caa58ebbc647b22aa;p=tmp%2Fjakarta-migration.git DRYD-315: Added 'referenced' field to term list results to indicate if a term is currently referenced by other records. --- diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/ServiceResult.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/ServiceResult.java index 4736f5da4..67c23c442 100644 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/ServiceResult.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/ServiceResult.java @@ -61,7 +61,16 @@ public class ServiceResult { public String failureReason = ""; public String expectedContentExpanded = ""; public Header[] responseHeaders = new Header[0]; - public List expectedCodes = new ArrayList(); + + private List expectedCodes = new ArrayList(); + public List getExpectedCodes() { + return expectedCodes; + } + public void setExpectedCodes(List codes) { + expectedCodes = codes; + } + + public boolean expectedCodesStrict = false; public Map vars = new HashMap(); public void addVars(Map newVars){ vars.putAll(newVars); @@ -171,28 +180,43 @@ public class ServiceResult { if (overrideExpectedResult){ return true; } - //if (Tools.notEmpty(failureReason)){ - // return false; - //} - for (Integer oneExpected : expectedCodes){ - if (responseCode == oneExpected){ + + if (expectedCodesStrict && expectedCodes.size() > 0) { + // + // response code MUST match one of the stated expected response codes + // + for (Integer expected : expectedCodes) { + if (expected == responseCode) { + failureReason = ""; + return isDomWalkOK(); + } + } + failureReason = " : STATUS CODE UNEXPECTED; "; + return false; + } + + for (Integer expected : expectedCodes){ + if (responseCode == expected){ failureReason = ""; return isDomWalkOK(); } } - if ( expectedCodes.size()>0 && codeInSuccessRange(responseCode)){ //none found, but result expected. - for (Integer oneExpected : expectedCodes){ - if ( ! codeInSuccessRange(oneExpected)){ + + if (expectedCodes.size() > 0 && codeInSuccessRange(responseCode)) { //none found, but result expected. + for (Integer expected : expectedCodes) { + if (!codeInSuccessRange(expected)) { failureReason = ""; return isDomWalkOK(); } } } + boolean ok = codeInSuccessRange(responseCode); if (ok) { failureReason = ""; return isDomWalkOK(); } + failureReason = " : STATUS CODE UNEXPECTED; "; return false; } diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java index f0b53143a..467768c97 100644 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java @@ -249,7 +249,7 @@ public class XmlReplay { if (pr.autoDelete == true && Tools.notEmpty(pr.deleteURL)){ ServiceResult deleteResult = XmlReplayTransport.doDELETE(pr.deleteURL, pr.adminAuth, pr.testID, "[autodelete:"+logName+"]"); if (deleteResult.gotExpectedResult() == false || deleteResult.responseCode != 200) { - reattemptList.put(REATTEMPT_KEY + deleteFailures++, pr); // We need to try again after our dependents have been deleted. cow() + reattemptList.put(REATTEMPT_KEY + deleteFailures++, pr); // We need to try again after our dependents have been deleted. } results.add(deleteResult); } else { @@ -550,7 +550,8 @@ public class XmlReplay { evalStruct.jexl = jexl; for (Node testgroup : testgroupNodes) { - String testGroupID = testgroup.valueOf("@ID"); + boolean expectedCodesStrict = Tools.isTrue(testgroup.valueOf("@expectedCodesStrict")); + String testGroupID = testgroup.valueOf("@ID"); XmlReplayEval.MapContextWKeys jc = new XmlReplayEval.MapContextWKeys();//MapContext(); //Get a new JexlContext for each test group. evalStruct.jc = jc; autoDeletePOSTS = testgroup.valueOf("@autoDeletePOSTS"); @@ -631,11 +632,11 @@ public class XmlReplay { List expectedCodes = new ArrayList(); String expectedCodesStr = testNode.valueOf("expectedCodes"); - if (Tools.notEmpty(expectedCodesStr)){ - String[] codesArray = expectedCodesStr.split(","); - for (String code : codesArray){ - expectedCodes.add(new Integer(code.trim())); - } + if (Tools.notEmpty(expectedCodesStr)) { + String[] codesArray = expectedCodesStr.split(","); + for (String code : codesArray){ + expectedCodes.add(new Integer(code.trim())); + } } Node responseNode = testNode.selectSingleNode("response"); @@ -682,7 +683,7 @@ public class XmlReplay { serviceResult = XmlReplayTransport.doDELETE(pr.deleteURL, authForTest, testIDLabel, fromTestID); serviceResult.fromTestID = fromTestID; if (expectedCodes.size()>0){ - serviceResult.expectedCodes = expectedCodes; + serviceResult.setExpectedCodes(expectedCodes); } results.add(serviceResult); if (serviceResult.codeInSuccessRange(serviceResult.responseCode)){ //gotExpectedResult depends on serviceResult.expectedCodes. @@ -721,7 +722,8 @@ public class XmlReplay { serviceResult.adminAuth = authForCleanup; serviceResult.method = method; if (expectedCodes.size()>0){ - serviceResult.expectedCodes = expectedCodes; + serviceResult.setExpectedCodes(expectedCodes); + serviceResult.expectedCodesStrict = expectedCodesStrict; } if (Tools.isEmpty(serviceResult.testID)) serviceResult.testID = testIDLabel; if (Tools.isEmpty(serviceResult.testGroupID)) serviceResult.testGroupID = testGroupID; diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayReport.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayReport.java index 6d1315189..2b2a2c2d5 100644 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayReport.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayReport.java @@ -257,7 +257,7 @@ public class XmlReplayReport { +s.method+ SP +""+s.fullURL+"" +linesep + s.responseCode+ SP +lbl("gotExpected")+s.gotExpectedResult() +linesep + (Tools.notBlank(s.failureReason) ? s.failureReason +linesep : "" ) - + ( (s.expectedCodes.size()>0) ? lbl("expectedCodes")+s.expectedCodes+linesep : "" ) + + ( (s.getExpectedCodes().size()>0) ? lbl("expectedCodes")+s.getExpectedCodes()+linesep : "" ) //+ ( Tools.notEmpty(s.testGroupID) ? "testGroupID:"+s.testGroupID+linesep : "" ) //THIS WORKS, BUT IS VERBOSE: + ( Tools.notEmpty(s.fromTestID) ? "fromTestID:"+s.fromTestID+linesep : "" ) + ( Tools.notEmpty(s.responseMessage) ? lbl("msg")+s.responseMessage+linesep : "" ) diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTransport.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTransport.java index 04ebb6857..e13998347 100644 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTransport.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTransport.java @@ -192,15 +192,21 @@ public class XmlReplayTransport { XmlReplayEval evalStruct, String authForTest, String fromTestID) throws Exception { - byte[] b = FileUtils.readFileToByteArray(new File(fileName)); - String xmlString = new String(b); + byte[] b = null; + if (fileName != null && fileName.trim().isEmpty() == false) { + b = FileUtils.readFileToByteArray(new File(fileName)); + // + // Add the test ID so we can substitute instances of "${testID}" in the + // payload with the test ID. + // + String testId = fromTestID.split("\\.")[1]; // Get the unqualified (without the group ID part) test name + vars.put("Test.ID", testId); + } else { + System.out.println(String.format("WARNING: POST/PUT from test '%s' specified no payload file.", fromTestID)); + } + + String xmlString = b != null ? new String(b) : ""; String contentRaw = xmlString; - // - // Add the test ID so we can substitute instances of "${testID}" in the - // payload with the test ID. - // - String testId = fromTestID.split("\\.")[1]; // Get the unqualified (without the group ID part) test name - vars.put("Test.ID", testId); xmlString = evalStruct.eval(xmlString, evalStruct.serviceResultsMap, vars, evalStruct.jexl, evalStruct.jc); String urlString = protoHostPort + uri; diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ReplaceVocabItems/responses/ReplaceVocabItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ReplaceVocabItems/responses/ReplaceVocabItems.res.xml index 9eb678e11..a32ad4c3c 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ReplaceVocabItems/responses/ReplaceVocabItems.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ReplaceVocabItems/responses/ReplaceVocabItems.res.xml @@ -21,7 +21,7 @@ 3 3 - csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|deprecated|termStatus|description|source|order|displayName|shortIdentifier + csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|referenced|deprecated|termStatus|description|source|order|displayName|shortIdentifier diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/showVocabWithItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/showVocabWithItems.res.xml index ebdacf10c..39a3c9408 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/showVocabWithItems.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/showVocabWithItems.res.xml @@ -35,7 +35,7 @@ ${itemsInPage} ${totalItems} - csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|deprecated|termStatus|description|source|order|displayName|shortIdentifier + csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|referenced|deprecated|termStatus|description|source|order|displayName|shortIdentifier ${createItem1} diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/showVocabWithItemsPaged.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/showVocabWithItemsPaged.res.xml index a04c6f902..91a37cbe2 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/showVocabWithItemsPaged.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/showVocabWithItemsPaged.res.xml @@ -35,7 +35,7 @@ ${itemsInPage} ${totalItems} - csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|deprecated|termStatus|description|source|order|displayName|shortIdentifier + csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|referenced|deprecated|termStatus|description|source|order|displayName|shortIdentifier ${createItem1} diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddDeleteVocabItems/responses/updateAddDeleteVocabItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddDeleteVocabItems/responses/updateAddDeleteVocabItems.res.xml index eae901339..88d8737a3 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddDeleteVocabItems/responses/updateAddDeleteVocabItems.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddDeleteVocabItems/responses/updateAddDeleteVocabItems.res.xml @@ -21,7 +21,7 @@ 4 4 - csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|deprecated|termStatus|description|source|order|displayName|shortIdentifier + csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|referenced|deprecated|termStatus|description|source|order|displayName|shortIdentifier diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddOnlyVocabItems/responses/updateAddOnlyVocabItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddOnlyVocabItems/responses/updateAddOnlyVocabItems.res.xml index 2150bfa85..d38bd8d2c 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddOnlyVocabItems/responses/updateAddOnlyVocabItems.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddOnlyVocabItems/responses/updateAddOnlyVocabItems.res.xml @@ -21,7 +21,7 @@ 6 6 - csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|deprecated|termStatus|description|source|order|displayName|shortIdentifier + csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|referenced|deprecated|termStatus|description|source|order|displayName|shortIdentifier @@ -59,6 +59,18 @@ Added item C addeditemc + + + urn:cspace:testsci.collectionspace.org:vocabularies:name(createUpdateAddOnlyVocabItems):item:name(createItem301)'Updated createItem301' + + project + 1 + false + true + 3 + Updated createItem301 + createItem301 + urn:cspace:testsci.collectionspace.org:vocabularies:name(createUpdateAddOnlyVocabItems):item:name(createItem101)'createItem101' @@ -83,17 +95,5 @@ createItem201 createItem201 - - - urn:cspace:testsci.collectionspace.org:vocabularies:name(createUpdateAddOnlyVocabItems):item:name(createItem301)'Updated createItem301' - - project - 1 - false - true - 3 - Updated createItem301 - createItem301 - \ No newline at end of file diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddSoftDeleteVocabItems/responses/updateAddSoftDeleteVocabItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddSoftDeleteVocabItems/responses/updateAddSoftDeleteVocabItems.res.xml index 9f5991f24..679918765 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddSoftDeleteVocabItems/responses/updateAddSoftDeleteVocabItems.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/UpdateAddSoftDeleteVocabItems/responses/updateAddSoftDeleteVocabItems.res.xml @@ -21,7 +21,7 @@ 6 6 - csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|deprecated|termStatus|description|source|order|displayName|shortIdentifier + csid|uri|refName|updatedAt|workflowState|rev|sourcePage|sas|proposed|referenced|deprecated|termStatus|description|source|order|displayName|shortIdentifier @@ -59,6 +59,18 @@ Added item C addeditemc + + + urn:cspace:testsci.collectionspace.org:vocabularies:name(createUpdateAddSoftDeleteVocabItems):item:name(createItem301)'Updated createItem301' + + project + 1 + false + true + 1 + Updated createItem301 + createItem301 + urn:cspace:testsci.collectionspace.org:vocabularies:name(createUpdateAddSoftDeleteVocabItems):item:name(createItem101)'createItem101' @@ -83,17 +95,5 @@ createItem201 createItem201 - - - urn:cspace:testsci.collectionspace.org:vocabularies:name(createUpdateAddSoftDeleteVocabItems):item:name(createItem301)'Updated createItem301' - - project - 1 - false - true - 1 - Updated createItem301 - createItem301 - \ No newline at end of file diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/vocabulary.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/vocabulary.xml index 00b29687a..63a870bdb 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/vocabulary.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/vocabulary.xml @@ -313,12 +313,44 @@ 2 urn:cspace:testsci.collectionspace.org:vocabularies:name(createEmptyVocab):item:name(createItem2)'createItem2' - + + + + + 409 + DELETE + /cspace-services/vocabularies/${createEmptyVocab.CSID}/items/${createItem2.CSID} + + + + 409 + DELETE + /cspace-services/vocabularies/${createEmptyVocab.CSID}/items/${createItem2.CSID}?wf_deleted=true + + + + 409 + DELETE + /cspace-services/vocabularies/${createEmptyVocab.CSID}/items/${createItem2.CSID}?wf_deleted=false + + + 409 DELETE /cspace-services/vocabularies/${createEmptyVocab.CSID} + + 409 + DELETE + /cspace-services/vocabularies/${createEmptyVocab.CSID}?wf_deleted=true + + + 409 + DELETE + /cspace-services/vocabularies/${createEmptyVocab.CSID}?wf_deleted=false + + DELETE /cspace-services/objectexit/${createObjectExit.CSID} @@ -334,6 +366,107 @@ + + + + POST + /cspace-services/vocabularies/ + vocabulary/vocab-Template.xml + + + POST + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/items/ + vocabulary/vocab-Item-template.xml + + 1 + + + + POST + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/items/ + vocabulary/vocab-Item-template.xml + + 2 + + + + POST + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/items/ + vocabulary/vocab-Item-template.xml + + 3 + + + + POST + /cspace-services/objectexit + vocabulary/DeleteVocabWithItems/objectExit.xml + + 33.123 + urn:cspace:testsci.collectionspace.org:vocabularies:name(createEmptyVocabSoft):item:name(createItem2)'createItem2' + + + + + + 409 + PUT + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/items/${createItem2.CSID}/workflow/delete + + + + 409 + PUT + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/items/${createItem2.CSID}/workflow/delete?wf_deleted=true + + + + 409 + PUT + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/items/${createItem2.CSID}/workflow/delete?wf_deleted=false + + + + + 409,200 + PUT + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/workflow/delete + + + 409,400 + PUT + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/workflow/delete?wf_deleted=true + + + 409,400 + PUT + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID}/workflow/delete?wf_deleted=false + + + + DELETE + /cspace-services/objectexit/${createObjectExit.CSID} + + + DELETE + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID} + + + 404 + GET + /cspace-services/vocabularies/${createEmptyVocabSoft.CSID} + + +