From b55e162f35808a657bf3b3e552e1376bba2b4aff Mon Sep 17 00:00:00 2001 From: Laramie Crocker Date: Wed, 1 Jun 2011 00:49:33 +0000 Subject: [PATCH] CSPACE-573 Added tests to test the new order field, to ensure that this order field is returned in list results, and that duplicate values for the order field is accepted. --- .../xmlreplay/ServiceResult.java | 1 + .../IntegrationTests/xmlreplay/XmlReplay.java | 1 + .../xmlreplay/XmlReplayEval.java | 1 + .../xmlreplay/XmlReplayReport.java | 1 + .../resources/test-data/xmlreplay/dev-all.xml | 4 ++ .../xmlreplay/vocabulary/1-vocab.xml | 12 ++++ .../test-data/xmlreplay/vocabulary/2-item.xml | 11 +++ .../vocabulary/res/GetVocabularyItems.res.xml | 31 ++++++++ .../xmlreplay/vocabulary/vocabulary.xml | 70 +++++++++++++++++++ .../test-data/xmlreplay/xml-replay-master.xml | 4 +- 10 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/1-vocab.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/2-item.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml create mode 100644 services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/vocabulary.xml 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 26b877cec..77a93ea08 100755 --- 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 @@ -57,6 +57,7 @@ public class ServiceResult { public String payloadStrictness = ""; public long contentLength = 0; public String failureReason = ""; + public String expectedContentExpanded = ""; public Header[] responseHeaders = new Header[0]; public List expectedCodes = new ArrayList(); public Map vars = new HashMap(); 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 ebf19c30e..41c18d30c 100755 --- 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 @@ -413,6 +413,7 @@ public class XmlReplay { String expectedPartContent = new String(b); Map vars = expectedResponseParts.varsList.get(0); //just one part, so just one varsList. Must be there, even if empty. expectedPartContent = evalStruct.eval(expectedPartContent, serviceResultsMap, vars, evalStruct.jexl, evalStruct.jc); + serviceResult.expectedContentExpanded = expectedPartContent; String label = "NOLABEL"; String leftID = "{from expected part, label:"+label+" filename: "+expectedResponseParts.responseFilename+"}"; String rightID = "{from server, label:"+label diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayEval.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayEval.java index bd34f2fa4..7e482471e 100755 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayEval.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayEval.java @@ -72,6 +72,7 @@ public class XmlReplayEval { String key = entry.getKey(); try { value = parse(value, jexl, jc); + vars.put(key, value); //replace template value with actual value. } catch (Exception e){ value = "ERROR: "+e; } 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 144856196..6bbdb80ff 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 @@ -196,6 +196,7 @@ public class XmlReplayReport { appendPayload(fb, serviceResult.requestPayload, "REQUEST", "REQUEST" + tocID); appendPayload(fb, serviceResult.requestPayloadsRaw, "REQUEST (RAW)", "REQUESTRAW" + tocID); appendPayload(fb, serviceResult.result, "RESPONSE", "RESPONSE" + tocID); + appendPayload(fb, serviceResult.expectedContentExpanded, "EXPECTED", "EXPECTED" + tocID); fb.append(BR); return fb.toString(); diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-all.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-all.xml index d4bc7a2b0..a3850b9fa 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-all.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-all.xml @@ -87,6 +87,10 @@ + + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/1-vocab.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/1-vocab.xml new file mode 100644 index 000000000..a53be47d1 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/1-vocab.xml @@ -0,0 +1,12 @@ + + + + TestOrder Vocabulary + TestOrderVocab + + urn:cspace:org.collectionspace.demo:vocabulary:name(TestOrderVocab)'TestOrder Vocabulary' + enum + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/2-item.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/2-item.xml new file mode 100644 index 000000000..e1a48f860 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/2-item.xml @@ -0,0 +1,11 @@ + + + + ${displayName} + ${itemID} + urn:cspace:org.collectionspace.demo:vocabulary:name(TestOrderVocab):item:name(${itemID})'${displayName}' + ${order} + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml new file mode 100644 index 000000000..f8c787427 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml @@ -0,0 +1,31 @@ + + + 0 + 3 + 3 + displayName|refName|shortIdentifier|order|uri|csid + + ${Item3DupeOrder.displayName} + ${Item3DupeOrder.itemID} + ${Item3DupeOrder.order} + /vocabularies/${Vocabulary1.CSID}/items/${Item3DupeOrder.CSID} + ${Item3DupeOrder.CSID} + + + ${Item2.displayName} + ${Item2.itemID} + ${Item2.order} + /vocabularies/${Vocabulary1.CSID}/items/${Item2.CSID} + ${Item2.CSID} + + + ${Item1.displayName} + ${Item1.itemID} + ${Item1.order} + /vocabularies/${Vocabulary1.CSID}/items/${Item1.CSID} + ${Item1.CSID} + + 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 new file mode 100644 index 000000000..8b2281404 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/vocabulary.xml @@ -0,0 +1,70 @@ + + + + + YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y + YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y + + + + + POST + /cspace-services/vocabularies/ + vocabulary/1-vocab.xml + + + POST + /cspace-services/vocabularies/${Vocabulary1.CSID}/items/ + vocabulary/2-item.xml + + VocabItem1 + 1 + TestOrder item ${itemID} order ${order} + + + + POST + /cspace-services/vocabularies/${Vocabulary1.CSID}/items/ + vocabulary/2-item.xml + + VocabItem2 + 2 + TestOrder item ${itemID} order ${order} + + + + POST + /cspace-services/vocabularies/${Vocabulary1.CSID}/items/ + vocabulary/2-item.xml + + VocabItem3 + 1 + TestOrder item ${itemID} order ${order} + + + + + GET + /cspace-services/vocabularies/ + + + + GET + /cspace-services/vocabularies/${Vocabulary1.CSID}/items/ + + + vocabulary/res/GetVocabularyItems.res.xml + + ${Item3DupeOrder.displayName} + + + + + + + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml index fdd89e3da..6b29eeb88 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml @@ -46,8 +46,8 @@ - - + + -- 2.47.3