]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2508: Added a negative test for an unrecognized sort order identifier (not...
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 21 Jul 2010 02:27:35 +0000 (02:27 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 21 Jul 2010 02:27:35 +0000 (02:27 +0000)
services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java

index 3bd9e3443334460bd08d1dd4b693498c523f08d6..19ac2b65ee7c50bad0f7c404146b83804d6fe7ed 100644 (file)
@@ -1,18 +1,25 @@
 /**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
  *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
  *
- * Copyright © 2009 Regents of the University of California
+ *  Copyright © 2009 Regents of the University of California
  *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
  *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *  You may obtain a copy of the ECL 2.0 License at
+ *
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
  */
 
 package org.collectionspace.services.client;
@@ -36,7 +43,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 
 /**
- * MovementClient.java
+ * MovementProxy.java
  *
  * $LastChangedRevision$
  * $LastChangedDate$
index 7602981dad9b8a1b20ce7fbcd24d7fcdd24df92d..dbf260259e95d5b8472157e7ac53a9e180294afc 100644 (file)
@@ -385,6 +385,38 @@ public class MovementSortByTest extends BaseServiceTest {
 
     }
 
+    /*
+     * Tests whether a request to sort by an invalid identifier for the
+     * sort order (ascending or descending) is handled as expected.
+     */
+    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+    public void sortWithInvalidSortOrderIdentifier(String testName) throws Exception {
+
+        if (logger.isDebugEnabled()) {
+            logger.debug(testBanner(testName, CLASS_NAME));
+        }
+        // FIXME: Ultimately, this should return a BAD_REQUEST status.
+        testSetup(STATUS_INTERNAL_SERVER_ERROR, ServiceRequestType.READ);
+
+        // Submit the request to the service and store the response.
+        MovementClient client = new MovementClient();
+        final String INVALID_SORT_ORDER_IDENTIFIER = "NO_DIRECTION";
+        ClientResponse<MovementsCommonList> res =
+                client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE
+                + " " + INVALID_SORT_ORDER_IDENTIFIER);
+        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);
+
+    }
+
     /*
      * Tests whether a request to sort by a malformed field name is
      * handled as expected.
@@ -450,6 +482,9 @@ public class MovementSortByTest extends BaseServiceTest {
         // FIXME: While this convention - appending a suffix to the name of
         // the service's first unique URL path component - works, it would
         // be preferable to get the common schema name from configuration.
+        //
+        // Such configuration is provided for example, on the services side, in
+        // org.collectionspace.services.common.context.AbstractServiceContextImpl
         return getServicePathComponent() + "_" + "common";
     }
 
@@ -484,6 +519,10 @@ public class MovementSortByTest extends BaseServiceTest {
                 };
     }
 
+    /*
+     * Create multiple test records, initially in unsorted order,
+     * using values for various fields obtained from the data provider.
+     */
     @Test(dataProvider = "unsortedValues")
     public void createList(int expectedSortOrder, String movementNote,
             String locationDate) throws Exception {
@@ -494,7 +533,8 @@ public class MovementSortByTest extends BaseServiceTest {
         }
         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
 
-        // Create each unsorted record provided by the data provider.
+        // Iterates through the sets of values returned by the data provider,
+        // and creates a corresponding test record for each set of values.
         create(movementNote, locationDate);
     }