You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2010/09/27 19:38:08 UTC

svn commit: r1001832 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ test/java/org/apache/chemistry/opencmis/inmemory/

Author: jens
Date: Mon Sep 27 17:38:07 2010
New Revision: 1001832

URL: http://svn.apache.org/viewvc?rev=1001832&view=rev
Log:
Fix avoid returning properties if they are not requested
add unit test

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java?rev=1001832&r1=1001831&r2=1001832&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java Mon Sep 27 17:38:07 2010
@@ -159,13 +159,14 @@ public class StoreManagerImpl implements
         if (includePropertyDefinitions) {
             result = typeColl;
         } else {
-            result = new ArrayList<TypeDefinitionContainer>(typeColl);
+            result = new ArrayList<TypeDefinitionContainer>(typeColl.size());
             // copy list and omit properties
-            for (TypeDefinitionContainer c : result) {
+            for (TypeDefinitionContainer c : typeColl) {
                 AbstractTypeDefinition td = ((AbstractTypeDefinition) c.getTypeDefinition()).clone();
                 TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td);
                 tdc.setChildren(c.getChildren());
                 td.setPropertyDefinitions(null);
+                result.add(tdc);
             }
         }
         return result;

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java?rev=1001832&r1=1001831&r2=1001832&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java Mon Sep 27 17:38:07 2010
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.in
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -290,25 +291,14 @@ public class RepositoryServiceTest exten
         String typeId = BaseTypeId.CMIS_DOCUMENT.value();
 
         // get types
-        List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, typeId, BigInteger.valueOf(-1),
+        List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, typeId, null,
                 false, null);
         assertNotNull(types);
         log.info("Repository " + repositoryId + " contains " + types.size() + " type(s).");
 
-        TypeDefinitionContainer typeWithProps = null;
         for (TypeDefinitionContainer type : types) {
-            if (type.getTypeDefinition().getId().equals(RepositoryTestTypeSystemCreator.COMPLEX_TYPE)) {
-                typeWithProps = type;
-                break;
-            }
+            assertNull(type.getTypeDefinition().getPropertyDefinitions());
         }
-        assertNotNull(typeWithProps);
-        TypeDefinition typeDef = typeWithProps.getTypeDefinition();
-        Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
-        log.info("Found type: " + typeDef.getId() + ", display name is: " + typeDef.getDisplayName());
-        log.info("  Base type is: " + typeDef.getBaseTypeId());
-        log.info("  Number of properties is: " + (propDefs == null ? 0 : propDefs.size()));
-        assertTrue(propDefs == null || propDefs.size() == 0);
         log.info("... testGetTypesWithoutProperties() finished.");
     }
 
@@ -349,6 +339,27 @@ public class RepositoryServiceTest exten
     }
 
     @Test
+    public void testGetTypeChildrenNoProperties() {
+        log.info("");
+        log.info("starting testGetTypeChildrenNoProperties()...");
+        String repositoryId = getRepositoryId();
+        String typeId = "cmis:document";
+
+        // get all children
+        BigInteger maxItems = BigInteger.valueOf(1000);
+        BigInteger skipCount = BigInteger.valueOf(0);
+        TypeDefinitionList children = fRepSvc.getTypeChildren(repositoryId, typeId, null, maxItems, skipCount, null);
+
+        children = fRepSvc.getTypeChildren(repositoryId, typeId, null, maxItems, null, null);
+
+        for (TypeDefinition type : children.getList()) {
+            assertNull(type.getPropertyDefinitions());
+        }
+
+        log.info("... testGetTypeChildrenNoProperties() finished.");
+    }
+    
+    @Test
     public void testGetWrongParameters() {
         log.info("");
         log.info("starting testGetWrongParameters()...");