]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-202: Added tests for new 'showItems' query param for /vocabularies/${id} GET...
authorremillet <remillet@yahoo.com>
Tue, 16 Jan 2018 22:39:20 +0000 (14:39 -0800)
committerremillet <remillet@yahoo.com>
Tue, 16 Jan 2018 22:39:20 +0000 (14:39 -0800)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocab.res.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItems.res.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItemsLastPage.res.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItemsPaged.res.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/showItems-item-template.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/showItems-vocab.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/vocabulary.xml
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java

diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocab.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocab.res.xml
new file mode 100644 (file)
index 0000000..f6082f1
--- /dev/null
@@ -0,0 +1,15 @@
+<document name="vocabularies">
+    <ns2:vocabularies_common xmlns:ns2="http://collectionspace.org/services/vocabulary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <rev>3</rev>
+        <shortIdentifier>ShowItemsVocab</shortIdentifier>
+        <csid>${csid}</csid>
+        <displayName>ShowItems Vocabulary</displayName>
+        <description>
+            This is a test vocabulary for the ShowItems XMLReplay test group.
+        </description>
+        <source>XML Replay ShowItems test group.</source>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab)'ShowItems Vocabulary'
+        </refName>
+    </ns2:vocabularies_common>
+</document>
\ No newline at end of file
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItems.res.xml
new file mode 100644 (file)
index 0000000..1425b8e
--- /dev/null
@@ -0,0 +1,90 @@
+<document name="vocabularies">
+    <ns2:collectionspace_core xmlns:ns2="http://collectionspace.org/collectionspace_core/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <updatedBy>admin@core.collectionspace.org</updatedBy>
+        <createdBy>admin@core.collectionspace.org</createdBy>
+        <workflowState>project</workflowState>
+        <tenantId>1</tenantId>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab)'ShowItems Vocabulary'
+        </refName>
+        <uri>/vocabularies/${csid}</uri>
+    </ns2:collectionspace_core>
+    <ns2:vocabularies_common xmlns:ns2="http://collectionspace.org/services/vocabulary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <rev>3</rev>
+        <shortIdentifier>ShowItemsVocab</shortIdentifier>
+        <csid>${csid}</csid>
+        <displayName>ShowItems Vocabulary</displayName>
+        <description>
+            This is a test vocabulary for the ShowItems XMLReplay test group.
+        </description>
+        <source>XML Replay ShowItems test group.</source>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab)'ShowItems Vocabulary'
+        </refName>
+    </ns2:vocabularies_common>
+    <ns2:account_permission xmlns:ns2="http://collectionspace.org/services/authorization">
+        <account>
+            <accountId>fadf0bcf-7c34-40c3-b6e5-ab1988eba888</accountId>
+            <screenName>Administrator</screenName>
+            <userId>admin@core.collectionspace.org</userId>
+            <tenantId>1</tenantId>
+        </account>
+    </ns2:account_permission>
+    <ns2:abstract-common-list xmlns:ns2="http://collectionspace.org/services/jaxb">
+        <pageNum>0</pageNum>
+        <pageSize>${pgSz}</pageSize>
+        <itemsInPage>${itemsInPage}</itemsInPage>
+        <totalItems>${totalItems}</totalItems>
+        <fieldsReturned>
+            csid|uri|refName|updatedAt|workflowState|rev|sas|proposed|deprecated|termStatus|order|displayName|shortIdentifier
+        </fieldsReturned>
+        <list-item>
+            <csid>${createItem1}</csid>
+            <uri>
+                /vocabularies/${csid}/items/${createItem1}
+            </uri>
+            <refName>
+                urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab):item:name(ShowItemsItem1)'ShowsItems item ShowItemsItem1'
+            </refName>
+            <workflowState>project</workflowState>
+            <rev>0</rev>
+            <sas>false</sas>
+            <proposed>true</proposed>
+            <order>1</order>
+            <displayName>ShowsItems item ShowItemsItem1</displayName>
+            <shortIdentifier>ShowItemsItem1</shortIdentifier>
+        </list-item>
+        <list-item>
+            <csid>${createItem2}</csid>
+            <uri>
+                /vocabularies/${csid}/items/${createItem2}
+            </uri>
+            <refName>
+                urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab):item:name(ShowItemsItem2)'ShowsItems item ShowItemsItem2'
+            </refName>
+            <workflowState>project</workflowState>
+            <rev>0</rev>
+            <sas>false</sas>
+            <proposed>true</proposed>
+            <order>2</order>
+            <displayName>ShowsItems item ShowItemsItem2</displayName>
+            <shortIdentifier>ShowItemsItem2</shortIdentifier>
+        </list-item>
+        <list-item>
+            <csid>${createItem3}</csid>
+            <uri>
+                /vocabularies/${csid}/items/${createItem3}
+            </uri>
+            <refName>
+                urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab):item:name(ShowItemsItem3)'ShowsItems item ShowItemsItem3'
+            </refName>
+            <workflowState>project</workflowState>
+            <rev>0</rev>
+            <sas>false</sas>
+            <proposed>true</proposed>
+            <order>3</order>
+            <displayName>ShowsItems item ShowItemsItem3</displayName>
+            <shortIdentifier>ShowItemsItem3</shortIdentifier>
+        </list-item>
+    </ns2:abstract-common-list>
+</document>
\ No newline at end of file
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItemsLastPage.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItemsLastPage.res.xml
new file mode 100644 (file)
index 0000000..cd1bbe8
--- /dev/null
@@ -0,0 +1,58 @@
+<document name="vocabularies">
+    <ns2:collectionspace_core xmlns:ns2="http://collectionspace.org/collectionspace_core/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <updatedBy>admin@core.collectionspace.org</updatedBy>
+        <createdBy>admin@core.collectionspace.org</createdBy>
+        <workflowState>project</workflowState>
+        <tenantId>1</tenantId>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab)'ShowItems Vocabulary'
+        </refName>
+        <uri>/vocabularies/${csid}</uri>
+    </ns2:collectionspace_core>
+    <ns2:vocabularies_common xmlns:ns2="http://collectionspace.org/services/vocabulary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <rev>3</rev>
+        <shortIdentifier>ShowItemsVocab</shortIdentifier>
+        <csid>${csid}</csid>
+        <displayName>ShowItems Vocabulary</displayName>
+        <description>
+            This is a test vocabulary for the ShowItems XMLReplay test group.
+        </description>
+        <source>XML Replay ShowItems test group.</source>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab)'ShowItems Vocabulary'
+        </refName>
+    </ns2:vocabularies_common>
+    <ns2:account_permission xmlns:ns2="http://collectionspace.org/services/authorization">
+        <account>
+            <accountId>fadf0bcf-7c34-40c3-b6e5-ab1988eba888</accountId>
+            <screenName>Administrator</screenName>
+            <userId>admin@core.collectionspace.org</userId>
+            <tenantId>1</tenantId>
+        </account>
+    </ns2:account_permission>
+    <ns2:abstract-common-list xmlns:ns2="http://collectionspace.org/services/jaxb">
+        <pageNum>0</pageNum>
+        <pageSize>${pgSz}</pageSize>
+        <itemsInPage>${itemsInPage}</itemsInPage>
+        <totalItems>${totalItems}</totalItems>
+        <fieldsReturned>
+            csid|uri|refName|updatedAt|workflowState|rev|sas|proposed|deprecated|termStatus|order|displayName|shortIdentifier
+        </fieldsReturned>
+        <list-item>
+            <csid>${createItem3}</csid>
+            <uri>
+                /vocabularies/${csid}/items/${createItem3}
+            </uri>
+            <refName>
+                urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab):item:name(ShowItemsItem3)'ShowsItems item ShowItemsItem3'
+            </refName>
+            <workflowState>project</workflowState>
+            <rev>0</rev>
+            <sas>false</sas>
+            <proposed>true</proposed>
+            <order>3</order>
+            <displayName>ShowsItems item ShowItemsItem3</displayName>
+            <shortIdentifier>ShowItemsItem3</shortIdentifier>
+        </list-item>
+    </ns2:abstract-common-list>
+</document>
\ No newline at end of file
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItemsPaged.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/res/showVocabWithItemsPaged.res.xml
new file mode 100644 (file)
index 0000000..1bfa26d
--- /dev/null
@@ -0,0 +1,74 @@
+<document name="vocabularies">
+    <ns2:collectionspace_core xmlns:ns2="http://collectionspace.org/collectionspace_core/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <updatedBy>admin@core.collectionspace.org</updatedBy>
+        <createdBy>admin@core.collectionspace.org</createdBy>
+        <workflowState>project</workflowState>
+        <tenantId>1</tenantId>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab)'ShowItems Vocabulary'
+        </refName>
+        <uri>/vocabularies/${csid}</uri>
+    </ns2:collectionspace_core>
+    <ns2:vocabularies_common xmlns:ns2="http://collectionspace.org/services/vocabulary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <rev>3</rev>
+        <shortIdentifier>ShowItemsVocab</shortIdentifier>
+        <csid>${csid}</csid>
+        <displayName>ShowItems Vocabulary</displayName>
+        <description>
+            This is a test vocabulary for the ShowItems XMLReplay test group.
+        </description>
+        <source>XML Replay ShowItems test group.</source>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab)'ShowItems Vocabulary'
+        </refName>
+    </ns2:vocabularies_common>
+    <ns2:account_permission xmlns:ns2="http://collectionspace.org/services/authorization">
+        <account>
+            <accountId>fadf0bcf-7c34-40c3-b6e5-ab1988eba888</accountId>
+            <screenName>Administrator</screenName>
+            <userId>admin@core.collectionspace.org</userId>
+            <tenantId>1</tenantId>
+        </account>
+    </ns2:account_permission>
+    <ns2:abstract-common-list xmlns:ns2="http://collectionspace.org/services/jaxb">
+        <pageNum>0</pageNum>
+        <pageSize>${pgSz}</pageSize>
+        <itemsInPage>${itemsInPage}</itemsInPage>
+        <totalItems>${totalItems}</totalItems>
+        <fieldsReturned>
+            csid|uri|refName|updatedAt|workflowState|rev|sas|proposed|deprecated|termStatus|order|displayName|shortIdentifier
+        </fieldsReturned>
+        <list-item>
+            <csid>${createItem1}</csid>
+            <uri>
+                /vocabularies/${csid}/items/${createItem1}
+            </uri>
+            <refName>
+                urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab):item:name(ShowItemsItem1)'ShowsItems item ShowItemsItem1'
+            </refName>
+            <workflowState>project</workflowState>
+            <rev>0</rev>
+            <sas>false</sas>
+            <proposed>true</proposed>
+            <order>1</order>
+            <displayName>ShowsItems item ShowItemsItem1</displayName>
+            <shortIdentifier>ShowItemsItem1</shortIdentifier>
+        </list-item>
+        <list-item>
+            <csid>${createItem2}</csid>
+            <uri>
+                /vocabularies/${csid}/items/${createItem2}
+            </uri>
+            <refName>
+                urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab):item:name(ShowItemsItem2)'ShowsItems item ShowItemsItem2'
+            </refName>
+            <workflowState>project</workflowState>
+            <rev>0</rev>
+            <sas>false</sas>
+            <proposed>true</proposed>
+            <order>2</order>
+            <displayName>ShowsItems item ShowItemsItem2</displayName>
+            <shortIdentifier>ShowItemsItem2</shortIdentifier>
+        </list-item>
+    </ns2:abstract-common-list>
+</document>
\ No newline at end of file
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/showItems-item-template.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/showItems-item-template.xml
new file mode 100644 (file)
index 0000000..2d61b50
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document name="vocabularyitems">
+  <ns3:vocabularyitems_common xmlns:ns3="http://collectionspace.org/services/vocabulary"
+  xmlns:ns2="http://collectionspace.org/services/jaxb">
+    <displayName>${displayName}</displayName>
+    <shortIdentifier>${itemID}</shortIdentifier>
+    <refName>urn:cspace:org.collectionspace.demo:vocabulary:name(TestOrderVocab):item:name(${itemID})'${displayName}'</refName>
+    <order>${order}</order>
+    <description>This is a test vocabulary item</description>
+    <source>Some mythical book</source>
+    <sourcePage>The page should match the order:${order}</sourcePage>
+  </ns3:vocabularyitems_common>
+</document>
+
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/showItems-vocab.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/showItems-vocab.xml
new file mode 100644 (file)
index 0000000..b8a9e81
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document name="vocabularies">
+  <ns3:vocabularies_common xmlns:ns3="http://collectionspace.org/services/vocabulary"
+  xmlns:ns2="http://collectionspace.org/services/jaxb">
+    <displayName>ShowItems Vocabulary</displayName>
+    <shortIdentifier>ShowItemsVocab</shortIdentifier>
+    <description>This is a test vocabulary for the ShowItems XMLReplay test group.</description>
+    <source>XML Replay ShowItems test group.</source>
+ </ns3:vocabularies_common>
+</document>
+
index 64aa09f3e331db1a34b0c1a76dfac9fd0ae07ed3..92924270fcad1a141a5ffe46dd894771164fd130 100644 (file)
@@ -5,7 +5,112 @@
                <auth ID="admin@core.collectionspace.org">YWRtaW5AY29yZS5jb2xsZWN0aW9uc3BhY2Uub3JnOkFkbWluaXN0cmF0b3I=</auth>
                <auth ID="testAdministator">YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y</auth>
        </auths>
-       <testGroup ID="TestOrder" autoDeletePOSTS="true">
+    
+    <!-- This test group tests the "showItems" query param that can be sent to the /vocabularies/${id} endpoint.
+        The "showItems=true" query param adds all the vocabularies items to the returned payload.
+    -->
+    <testGroup ID="TestShowItems" autoDeletePOSTS="true">
+        <test ID="createShowItemsVocab">
+            <method>POST</method>
+            <uri>/cspace-services/vocabularies/</uri>
+            <filename>vocabulary/ShowItems/showItems-vocab.xml</filename>
+        </test>
+        <test ID="createItem1" auth="test">
+            <method>POST</method>
+            <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}/items/</uri>
+            <filename>vocabulary/ShowItems/showItems-item-template.xml</filename>
+            <vars>
+                <var ID="itemID">ShowItemsItem1</var>
+                <var ID="order">1</var>
+                <var ID="displayName">ShowsItems item ${itemID}</var>
+            </vars>
+        </test>
+        <test ID="createItem2" auth="test">
+            <method>POST</method>
+            <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}/items/</uri>
+            <filename>vocabulary/ShowItems/showItems-item-template.xml</filename>
+            <vars>
+                <var ID="itemID">ShowItemsItem2</var>
+                <var ID="order">2</var>
+                <var ID="displayName">ShowsItems item ${itemID}</var>
+            </vars>
+        </test>
+        <test ID="createItem3" auth="test">
+            <method>POST</method>
+            <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}/items/</uri>
+            <filename>vocabulary/ShowItems/showItems-item-template.xml</filename>
+            <vars>
+                <var ID="itemID">ShowItemsItem3</var>
+                <var ID="order">3</var>
+                <var ID="displayName">ShowsItems item ${itemID}</var>
+            </vars>
+        </test>
+        <test ID="getShowItemsVocab">
+            <method>GET</method>
+            <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}</uri>
+            <response>
+                <vars>
+                    <var ID="csid">${createShowItemsVocab.CSID}</var>
+                </vars>
+                <expected level="ADDOK" />
+                <label>vocabularies_common</label>
+                <filename>vocabulary/ShowItems/res/showVocab.res.xml</filename>
+            </response>
+        </test>
+        <test ID="getShowItemsVocabWithItems">
+            <method>GET</method>
+            <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}?showItems=true</uri>
+            <response>
+                <vars>
+                    <var ID="pgSz">2500</var>
+                    <var ID="itemsInPage">3</var>
+                    <var ID="totalItems">3</var>
+                    <var ID="csid">${createShowItemsVocab.CSID}</var>
+                    <var ID="createItem1">${createItem1.CSID}</var>
+                    <var ID="createItem2">${createItem2.CSID}</var>
+                    <var ID="createItem3">${createItem3.CSID}</var>
+                </vars>
+                <expected level="ADDOK" />
+                <filename>vocabulary/ShowItems/res/showVocabWithItems.res.xml</filename>
+            </response>
+        </test>
+        <test ID="getShowItemsVocabWithItemsPaged">
+            <method>GET</method>
+            <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}?showItems=true&amp;pgSz=2</uri>
+            <response>
+                <vars>
+                    <var ID="pgSz">2</var>
+                    <var ID="itemsInPage">2</var>
+                    <var ID="totalItems">3</var>
+                    <var ID="csid">${createShowItemsVocab.CSID}</var>
+                    <var ID="createItem1">${createItem1.CSID}</var>
+                    <var ID="createItem2">${createItem2.CSID}</var>
+                    <var ID="createItem3">${createItem3.CSID}</var>
+                </vars>
+                <expected level="ADDOK" />
+                <filename>vocabulary/ShowItems/res/showVocabWithItemsPaged.res.xml</filename>
+            </response>
+        </test>
+        <test ID="getShowItemsVocabWithItemsLastPage">
+            <method>GET</method>
+            <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}?showItems=true&amp;pgSz=2&amp;pgNum=1</uri>
+            <response>
+                <vars>
+                    <var ID="pgSz">2</var>
+                    <var ID="itemsInPage">1</var>
+                    <var ID="totalItems">3</var>
+                    <var ID="csid">${createShowItemsVocab.CSID}</var>
+                    <var ID="createItem1">${createItem1.CSID}</var>
+                    <var ID="createItem2">${createItem2.CSID}</var>
+                    <var ID="createItem3">${createItem3.CSID}</var>
+                </vars>
+                <expected level="ADDOK" />
+                <filename>vocabulary/ShowItems/res/showVocabWithLastPage.res.xml</filename>
+            </response>
+        </test>
+    </testGroup>
+       
+    <testGroup ID="TestOrder" autoDeletePOSTS="true">
                <!-- The purpose of this testGroup is to test the new "order" field
              that was added in http://issues.collectionspace.org/browse/CSPACE-573
              and to ensure that this order field is returned in list results, 
index 30a48c913583717cd451763abc00fc5da535ede1..db1a002c005c6e4426bc2807b4e0f87b3cdb7ddd 100644 (file)
@@ -23,6 +23,7 @@
  */
 package org.collectionspace.services.vocabulary;
 
+import org.collectionspace.services.client.IClientQueryParams;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.VocabularyClient;
@@ -79,6 +80,14 @@ public class VocabularyResource extends
                MultivaluedMap<String,String> queryParams = uriInfo.getQueryParameters();
                String showItemsValue = (String)queryParams.getFirst(VocabularyClient.SHOW_ITEMS_QP);
             boolean showItems = Tools.isTrue(showItemsValue);
+            if (showItems == true) {
+               //
+               // We'll honor paging params if we find any; otherwise we'll set the page size to 0 to get ALL the items
+               //
+               if (queryParams.containsKey(IClientQueryParams.PAGE_SIZE_PARAM) == false) {
+                       queryParams.add(IClientQueryParams.PAGE_SIZE_PARAM, "0");
+               }
+            }
 
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(request, uriInfo);
             PoxPayloadOut payloadout = getAuthority(ctx, request, uriInfo, specifier, showItems);