]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6826: Ensured a default SELECT clause is part of all QueryContext instances.
authorremillet <remillet@yahoo.com>
Tue, 29 Mar 2016 17:35:14 +0000 (10:35 -0700)
committerremillet <remillet@yahoo.com>
Tue, 29 Mar 2016 17:35:14 +0000 (10:35 -0700)
services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java
services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java
services/index/client/src/test/java/org/collectionspace/services/client/test/IndexServiceTest.java

index abc45b68490e485a638c863711367b30ec6482c8..ea8bb775fb281e8f454e88eba800e3c2d74db7d9 100644 (file)
@@ -42,6 +42,8 @@ public interface IQueryManager {
     final static String SEARCH_TYPE_INVOCATION = "inv";
        final static String SEARCH_QUALIFIER_AND = SEARCH_TERM_SEPARATOR + "AND" + SEARCH_TERM_SEPARATOR;
        final static String SEARCH_QUALIFIER_OR = SEARCH_TERM_SEPARATOR + "OR" + SEARCH_TERM_SEPARATOR;
+    final static String DEFAULT_SELECT_CLAUSE = "SELECT * FROM ";
+       
 
        //
        // Nuxeo pseudo-values (and filters) for special document properties.
index e13d2ec77c056522f6e4e46fa24f3fda05e87027..84faf175bc349ffbffc462651484adef49caad7d 100644 (file)
@@ -1,5 +1,6 @@
 package org.collectionspace.services.common.query;
 
+import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.context.ServiceContext;
@@ -52,6 +53,7 @@ public class QueryContext {
             throw new IllegalArgumentException(
                     "Service context has no Tenant ID specified.");
         }
+        selectClause = IQueryManager.DEFAULT_SELECT_CLAUSE;
     }
 
     /**
@@ -137,8 +139,12 @@ public class QueryContext {
      * Gets the select clause.
      *
      * @return the select clause
+     * @throws Exception 
      */
-    public String getSelectClause() {
+    public String getSelectClause() throws Exception {
+       if (selectClause == null) {
+               throw new Exception("Select clause for query context was null.");
+       }
        return selectClause;
     }
     
index 98b5a62d5df60a21c79ea7866257ce3b45bd95d8..00a2a23ba05313e9bee54717bbc1dfa8cf66971b 100644 (file)
@@ -24,179 +24,15 @@ package org.collectionspace.services.client.test;
 
 import javax.ws.rs.core.Response;
 
-import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.index.IndexCommon;
-import org.collectionspace.services.client.DimensionClient;
-import org.collectionspace.services.client.index.IndexClient;
-import org.collectionspace.services.dimension.DimensionsCommon;
-import org.jboss.resteasy.client.ClientResponse;
-import org.testng.Assert;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
+ * IndexServiceTest, carries out tests against a deployed and running Index Service. <p/>
  * $LastChangedRevision:  $
  * $LastChangedDate:  $
  */
-public class IndexServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, IndexCommon> {
-
+public class IndexServiceTest {
     private final String CLASS_NAME = IndexServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
-    private String knownResourceId = null;
-
-    @Override
-       public String getServicePathComponent() {
-               return IndexClient.SERVICE_PATH_COMPONENT;
-       }
-
-       @Override
-       protected String getServiceName() {
-               return IndexClient.SERVICE_NAME;
-       }
-    
-    @Override
-    protected CollectionSpaceClient getClientInstance() {
-        return new DimensionClient();
-    }
-
-    //
-    // Test overrides
-    //
-    
-       @Override
-       public void create(String testName) throws Exception {
-               String csid = this.createTestObject(testName);
-               if (this.knownResourceId == null) {
-                       this.knownResourceId = csid;
-               }
-       }
-
-    @Override
-    public void read(String testName) throws Exception {
-//        setupRead();
-//        DimensionClient client = new DimensionClient();
-//        Response res = client.getIndex(knownResourceId);
-//        try {
-//             assertStatusCode(res, testName);
-//             PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
-//             IndexCommon indexsCommon = (IndexCommon) extractPart(input, IndexClient.SERVICE_COMMONPART_NAME, IndexCommon.class);
-//             if (logger.isDebugEnabled() == true) {
-//                     logger.debug("Index payload is: " + input.getXmlPayload());
-//             }
-//             Assert.assertNotNull(indexsCommon);
-//        } finally {
-//             if (res != null) {
-//                res.close();
-//            }
-//        }
-    }
-    
-    //
-    // FIXME: REM - This test should be a subclass of BaseServiceTest and *not* AbstractPoxServiceTestImpl
-    //
-    
-    @Override
-    public void update(String testName) throws Exception {
-        setupUpdate();
-    }    
-
-    @Override
-    public void delete(String testName) throws Exception {
-       // Do nothing.  N/A
-    }
-        
-    public void searchIndexDeleted(String testName) throws Exception {
-       // Do nothing.  N/A
-    }    
-
-       @Override
-       public void readList(String testName) throws Exception {
-               // Do nothing.  N/A
-       }       
-               
-       @Override
-    public void readPaginatedList(String testName) throws Exception {
-               // Do nothing.  N/A
-       }
-
-       @Override
-       public void CRUDTests(String testName) {
-               // TODO Auto-generated method stub              
-       }
-
-       @Override
-       protected IndexCommon updateInstance(IndexCommon commonPartObject) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       @Override
-       protected void compareUpdatedInstances(IndexCommon original,
-                       IndexCommon updated) throws Exception {
-               // TODO Auto-generated method stub
-               
-       }
-    
-       /*
-        * (non-Javadoc)
-        * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
-        */
-       @Override
-       public void createList(String testName) throws Exception {
-               //empty N/A
-       }
-    
-    public void testSubmitRequest() {
-       // Do nothing.  N/A
-    }
-
-    // ---------------------------------------------------------------
-    // Utility methods used by tests above
-    // ---------------------------------------------------------------
-    
-    @Override
-    protected PoxPayloadOut createInstance(String identifier) {
-        String dimensionsCommonPartName = new DimensionClient().getCommonPartName();
-       return createInstance(identifier, dimensionsCommonPartName);
-    }    
-    
-       @Override
-       protected PoxPayloadOut createInstance(String commonPartName,
-                       String identifier) {
-               return createDimensionInstance(commonPartName, identifier);
-       }
-    
-       /*
-        * We're using a DimensionsCommon instance to test the index service.
-        */
-    private PoxPayloadOut createDimensionInstance(String dimensionValue) {
-        String commonPartName = new DimensionClient().getCommonPartName();
-        return createDimensionInstance(commonPartName, dimensionValue);
-    }
-       
-       /*
-        * We're using a DimensionsCommon instance to test the index service.
-        */
-    private PoxPayloadOut createDimensionInstance(String commonPartName,
-               String dimensionValue) {
-        String measurementUnit = "measurementUnit-" + dimensionValue;
-        DimensionsCommon dimensionsCommon = new DimensionsCommon();
-        
-        dimensionsCommon.setMeasurementUnit(measurementUnit);
-        PoxPayloadOut multipart = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
-        PayloadOutputPart commonPart = multipart.addPart(commonPartName, dimensionsCommon);
-
-        if (logger.isDebugEnabled()) {
-            logger.debug("To be created, Dimensions common: " + commonPart.asXML());
-            logger.debug(objectAsXmlString(dimensionsCommon, DimensionsCommon.class));
-        }
-
-        return multipart;
-    }
-       
 }