chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1227203 - /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
Date Wed, 04 Jan 2012 16:03:43 GMT
Author: jens
Date: Wed Jan  4 16:03:43 2012
New Revision: 1227203

URL: http://svn.apache.org/viewvc?rev=1227203&view=rev
Log:
improve test getTypeDescendants without property definitions

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java?rev=1227203&r1=1227202&r2=1227203&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
Wed Jan  4 16:03:43 2012
@@ -180,7 +180,6 @@ public class RepositoryServiceTest exten
                                                                                         
   */, BigInteger.valueOf(-1),
                 Boolean.TRUE, null);
         assertNotNull(types);
-        log.info("Repository " + repositoryId + " contains " + types.size() + " type(s).");
 
         // check that we got all types
         int expectedSize = UnitTestTypeSystemCreator.getTypesList().size()
@@ -208,6 +207,38 @@ public class RepositoryServiceTest exten
     }
 
     @Test
+    public void testGetTypesWihtoutPropDefs() {
+        log.info("");
+        log.info("starting testGetTypesWihtoutPropDefs()...");
+        String repositoryId = getRepositoryId();
+
+        // get types
+        List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId,
BaseTypeId.CMIS_DOCUMENT.value(), BigInteger.valueOf(-1),
+                Boolean.FALSE, null);
+//        List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId,
"MyDocType1", BigInteger.valueOf(-1),
+//                Boolean.FALSE, null);
+        assertNotNull(types);
+
+        int totalSize = getRecursiveSize(types);
+        log.info("Found " + totalSize + " number of type definitions. ");
+
+        List<TypeDefinition> descendants = getTypeDefsFlattened(types);
+        for (TypeDefinition typeDef : descendants) {
+            assertNotNull(typeDef);
+            assertNotNull(typeDef.getId());
+            assertNotNull(typeDef.getBaseTypeId());
+            assertEquals(BaseTypeId.CMIS_DOCUMENT, typeDef.getBaseTypeId());
+            log.info("Found type: " + typeDef.getId() + ", display name is: " + typeDef.getDisplayName());
+            log.info("  Base type is: " + typeDef.getBaseTypeId());
+            Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
+            log.info("  Property definitions (must be null): " + propDefs);
+            assertNull(propDefs);
+        }
+
+        log.info("... testGetTypesWihtoutPropDefs() finished.");
+    }
+
+    @Test
     public void testGetAllTypesLimitedDepth() {
         log.info("");
         log.info("starting testGetAllTypesLimitedDepth()...");
@@ -286,25 +317,6 @@ public class RepositoryServiceTest exten
     }
 
     @Test
-    public void testGetTypesWithoutProperties() {
-        log.info("");
-        log.info("starting testGetTypesWithoutProperties()...");
-        String repositoryId = getRepositoryId();
-        String typeId = BaseTypeId.CMIS_DOCUMENT.value();
-
-        // get types
-        List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId,
typeId, null,
-                false, null);
-        assertNotNull(types);
-        log.info("Repository " + repositoryId + " contains " + types.size() + " type(s).");
-
-        for (TypeDefinitionContainer type : types) {
-            assertNull(type.getTypeDefinition().getPropertyDefinitions());
-        }
-        log.info("... testGetTypesWithoutProperties() finished.");
-    }
-
-    @Test
     public void testGetTypeChildren() {
         log.info("");
         log.info("starting testGetTypeChildren()...");
@@ -576,219 +588,17 @@ public class RepositoryServiceTest exten
         return size;
     }
 
-//    public static class RepositoryTestTypeSystemCreator implements TypeCreator {
-//
-//        public static final String COMPLEX_TYPE = "ComplexType";
-//        public static final String TOPLEVEL_TYPE = "DocumentTopLevel";
-//        public static final String LEVEL1_TYPE = "DocumentLevel1";
-//        public static final String LEVEL2_TYPE = "DocumentLevel2";
-//
-//        public static final List<TypeDefinition> singletonTypes = buildTypesList();
-//
-//        public List<TypeDefinition> createTypesList() {
-//            return singletonTypes;
-//        }
-//
-//        private static List<TypeDefinition> buildTypesList() {
-//            List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
-//
-//            InMemoryDocumentTypeDefinition cmisType1 = new InMemoryDocumentTypeDefinition("MyDocType1",
-//                    "My Type 1 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-//            typesList.add(cmisType1);
-//
-//            InMemoryDocumentTypeDefinition cmisType2 = new InMemoryDocumentTypeDefinition("MyDocType2",
-//                    "My Type 2 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-//            typesList.add(cmisType2);
-//
-//            InMemoryDocumentTypeDefinition cmisType11 = new InMemoryDocumentTypeDefinition("MyDocType1.1",
-//                    "My Type 3 Level 2", cmisType1);
-//            typesList.add(cmisType11);
-//
-//            InMemoryDocumentTypeDefinition cmisType111 = new InMemoryDocumentTypeDefinition("MyDocType1.1.1",
-//                    "My Type 4 Level 3", cmisType11);
-//            typesList.add(cmisType111);
-//
-//            InMemoryDocumentTypeDefinition cmisType112 = new InMemoryDocumentTypeDefinition("MyDocType1.1.2",
-//                    "My Type 5 Level 3", cmisType11);
-//            typesList.add(cmisType112);
-//
-//            InMemoryDocumentTypeDefinition cmisType12 = new InMemoryDocumentTypeDefinition("MyDocType1.2",
-//                    "My Type 6 Level 2", cmisType1);
-//            typesList.add(cmisType12);
-//
-//            InMemoryDocumentTypeDefinition cmisType21 = new InMemoryDocumentTypeDefinition("MyDocType2.1",
-//                    "My Type 7 Level 2", cmisType2);
-//            typesList.add(cmisType21);
-//
-//            InMemoryDocumentTypeDefinition cmisType22 = new InMemoryDocumentTypeDefinition("MyDocType2.2",
-//                    "My Type 8 Level 2", cmisType2);
-//            typesList.add(cmisType22);
-//            InMemoryDocumentTypeDefinition cmisType23 = new InMemoryDocumentTypeDefinition("MyDocType2.3",
-//                    "My Type 9 Level 2", cmisType2);
-//            typesList.add(cmisType23);
-//            InMemoryDocumentTypeDefinition cmisType24 = new InMemoryDocumentTypeDefinition("MyDocType2.4",
-//                    "My Type 10 Level 2", cmisType2);
-//            typesList.add(cmisType24);
-//            InMemoryDocumentTypeDefinition cmisType25 = new InMemoryDocumentTypeDefinition("MyDocType2.5",
-//                    "My Type 11 Level 2", cmisType2);
-//            typesList.add(cmisType25);
-//
-//            InMemoryDocumentTypeDefinition cmisType26 = new InMemoryDocumentTypeDefinition("MyDocType2.6",
-//                    "My Type 12 Level 2", cmisType2);
-//            typesList.add(cmisType26);
-//            InMemoryDocumentTypeDefinition cmisType27 = new InMemoryDocumentTypeDefinition("MyDocType2.7",
-//                    "My Type 13 Level 2", cmisType2);
-//            typesList.add(cmisType27);
-//            InMemoryDocumentTypeDefinition cmisType28 = new InMemoryDocumentTypeDefinition("MyDocType2.8",
-//                    "My Type 14 Level 2", cmisType2);
-//            typesList.add(cmisType28);
-//            InMemoryDocumentTypeDefinition cmisType29 = new InMemoryDocumentTypeDefinition("MyDocType2.9",
-//                    "My Type 15 Level 2", cmisType2);
-//            typesList.add(cmisType29);
-//
-//            // create a complex type with properties
-//            InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(COMPLEX_TYPE,
-//                    "Complex type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-//
-//            // create a boolean property definition
-//
-//            Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String,
PropertyDefinition<?>>();
-//
-//            PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
-//                    "Sample Boolean Property");
-//            propertyDefinitions.put(prop.getId(), prop);
-//
-//            prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
-//                    "Sample Boolean multi-value Property");
-//            propertyDefinitions.put(prop.getId(), prop);
-//
-//            PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
-//                    "Sample DateTime Property");
-//            propertyDefinitions.put(prop2.getId(), prop2);
-//
-//            prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
-//                    "Sample DateTime multi-value Property");
-//            propertyDefinitions.put(prop2.getId(), prop2);
-//
-//            PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
-//                    "Sample Decimal Property");
-//            propertyDefinitions.put(prop3.getId(), prop3);
-//
-//            prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV",
-//                    "Sample Decimal multi-value Property");
-//            propertyDefinitions.put(prop3.getId(), prop3);
-//
-//            PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
-//                    "Sample Html Property");
-//            propertyDefinitions.put(prop4.getId(), prop4);
-//
-//            prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV", "Sample Html
multi-value Property");
-//            propertyDefinitions.put(prop4.getId(), prop4);
-//
-//            PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp",
"Sample Id Property");
-//            propertyDefinitions.put(prop5.getId(), prop5);
-//
-//            prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV", "Sample Id Html
multi-value Property");
-//            propertyDefinitions.put(prop5.getId(), prop5);
-//
-//            PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
-//                    "Sample Int Property");
-//            propertyDefinitions.put(prop6.getId(), prop6);
-//
-//            prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV", "Sample
Int multi-value Property");
-//            propertyDefinitions.put(prop6.getId(), prop6);
-//
-//            PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
-//                    "Sample String Property");
-//            propertyDefinitions.put(prop7.getId(), prop7);
-//
-//            PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp",
-//                    "Sample Uri Property");
-//            propertyDefinitions.put(prop8.getId(), prop8);
-//
-//            prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV", "Sample Uri
multi-value Property");
-//            propertyDefinitions.put(prop8.getId(), prop8);
-//
-//            PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
-//                    "Sample Pick List Property");
-//            List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
-//            ChoiceImpl<String> elem = new ChoiceImpl<String>();
-//            elem.setValue(Collections.singletonList("red"));
-//            choiceList.add(elem);
-//            elem = new ChoiceImpl<String>();
-//            elem.setValue(Collections.singletonList("green"));
-//            choiceList.add(elem);
-//            elem = new ChoiceImpl<String>();
-//            elem.setValue(Collections.singletonList("blue"));
-//            choiceList.add(elem);
-//            elem = new ChoiceImpl<String>();
-//            elem.setValue(Collections.singletonList("black"));
-//            choiceList.add(elem);
-//            prop9.setChoices(choiceList);
-//            prop9.setDefaultValue(Collections.singletonList("blue"));
-//
-//            /*
-//             * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
-//             * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");
-//             * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
-//             * PropertyCreationHelper.addElemToPicklist(prop9, "black");
-//             * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /
-//             */
-//
-//            cmisComplexType.addCustomPropertyDefinitions(propertyDefinitions);
-//
-//            // add type to types collection
-//            typesList.add(cmisComplexType);
-//
-//            // create a type hierarchy with inherited properties
-//            InMemoryDocumentTypeDefinition cmisDocTypeTopLevel = new InMemoryDocumentTypeDefinition(TOPLEVEL_TYPE,
-//                    "Document type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-//
-//            InMemoryDocumentTypeDefinition cmisDocTypeLevel1 = new InMemoryDocumentTypeDefinition(LEVEL1_TYPE,
-//                    "Document type with inherited properties, Level 2", cmisDocTypeTopLevel);
-//
-//            InMemoryDocumentTypeDefinition cmisDocTypeLevel2 = new InMemoryDocumentTypeDefinition(LEVEL2_TYPE,
-//                    "Document type with inherited properties, Level 3", cmisDocTypeLevel1);
-//
-//            propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-//            PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
-//                    "Sample String Property");
-//            propertyDefinitions.put(propTop.getId(), propTop);
-//            cmisDocTypeTopLevel.addCustomPropertyDefinitions(propertyDefinitions);
-//
-//            propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-//            PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
-//                    "String Property Level 1");
-//            propertyDefinitions.put(propLevel1.getId(), propLevel1);
-//            cmisDocTypeLevel1.addCustomPropertyDefinitions(propertyDefinitions);
-//
-//            propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-//            PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
-//                    "String Property Level 2");
-//            propertyDefinitions.put(propLevel2.getId(), propLevel2);
-//            cmisDocTypeLevel2.addCustomPropertyDefinitions(propertyDefinitions);
-//
-//            // add type to types collection
-//            typesList.add(cmisDocTypeTopLevel);
-//            typesList.add(cmisDocTypeLevel1);
-//            typesList.add(cmisDocTypeLevel2);
-//
-//            return typesList;
-//        }
-//
-//        public static List<TypeDefinition> getTypesList() {
-//            return singletonTypes;
-//        }
-//
-//        public static TypeDefinition getTypeById(String typeId) {
-//            for (TypeDefinition typeDef : singletonTypes) {
-//                if (typeDef.getId().equals(typeId)) {
-//                    return typeDef;
-//                }
-//            }
-//            return null;
-//        }
-//
-//    }
+    private List<TypeDefinition> getTypeDefsFlattened(List<TypeDefinitionContainer>
types) {
+        List<TypeDefinition> flattened = new ArrayList<TypeDefinition>();
+        
+        for (TypeDefinitionContainer type : types) {
+            flattened.add(type.getTypeDefinition());
+            if (null != type.getChildren()) {
+                List<TypeDefinition> children = getTypeDefsFlattened(type.getChildren());
+                flattened.addAll(children);
+            }
+        }
 
+        return flattened;
+    }
 }



Mime
View raw message