polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [20/50] polygene-java git commit: POLYGENE-263 - NoSuchCompositeTypeException reports where invisible types of desired type is located.
Date Mon, 10 Jul 2017 06:53:22 GMT
POLYGENE-263 - NoSuchCompositeTypeException reports where invisible types of desired type is located.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/5704bb82
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/5704bb82
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/5704bb82

Branch: refs/heads/es-jooq
Commit: 5704bb8204b3222879c469ce02a44dee629a17aa
Parents: 8ad89e8
Author: niclas <niclas@hedhman.org>
Authored: Sat Jun 24 14:10:43 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Sat Jun 24 14:10:43 2017 +0800

----------------------------------------------------------------------
 .../composite/NoSuchCompositeTypeException.java |  37 +++--
 .../composite/NoSuchTransientTypeException.java |   5 +-
 .../api/service/NoSuchServiceTypeException.java |   5 +-
 .../polygene/api/structure/LayerDescriptor.java |   3 +-
 .../unitofwork/NoSuchEntityTypeException.java   |   8 +-
 .../api/value/NoSuchValueTypeException.java     |   8 +-
 .../polygene/runtime/structure/LayerModel.java  |   5 +-
 .../runtime/structure/ModuleInstance.java       |  18 +--
 .../runtime/unitofwork/ModuleUnitOfWork.java    |   6 +-
 .../runtime/unitofwork/UnitOfWorkInstance.java  |   2 +-
 .../runtime/value/ValueBuilderInstance.java     |   2 +-
 .../polygene/runtime/value/ValueModel.java      |   2 +-
 .../composite/CompositeFactoryImplTest.java     |   1 +
 .../NoSuchEntityTypeExceptionTest.java          |  95 +++++++++++
 ...stractPolygeneMultiLayeredTestWithModel.java | 161 ++++++++++++++++++
 .../test/entity/model/EntityStoreTestSuite.java | 162 ++++---------------
 .../entity/model/monetary/CheckBookSlip.java    |  58 +++++++
 .../test/entity/model/monetary/Currency.java    |  11 +-
 .../cassandra/CassandraEntityStoreMixin.java    |   2 +-
 .../PreferencesEntityStoreMixin.java            |   2 +-
 20 files changed, 413 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java
index 64977ef..1d6f155 100644
--- a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java
@@ -21,6 +21,8 @@ package org.apache.polygene.api.composite;
 
 import java.util.stream.Stream;
 import org.apache.polygene.api.common.InvalidApplicationException;
+import org.apache.polygene.api.structure.LayerDescriptor;
+import org.apache.polygene.api.structure.ModuleDescriptor;
 import org.apache.polygene.api.structure.TypeLookup;
 
 import static java.util.stream.Collectors.joining;
@@ -36,14 +38,14 @@ public abstract class NoSuchCompositeTypeException extends InvalidApplicationExc
     private final String metaType;
     private final String candidateTypes;
 
-    protected NoSuchCompositeTypeException( String metaType, String compositeType, String moduleName, TypeLookup typeLookup )
+    protected NoSuchCompositeTypeException( String metaType, String compositeType, ModuleDescriptor module )
     {
-        super( "\n\tCould not find any visible " + metaType + " of type [" + compositeType + "] in module [" + moduleName + "]." );
+        super( "\n\tCould not find any visible " + metaType + " of type [" + compositeType + "] in module [" + module.name() + "]." );
         this.metaType = metaType;
         this.compositeType = compositeType;
-        this.moduleName = moduleName;
-        visibleTypes = formatVisibleTypes( typeLookup );
-        candidateTypes = findCandidateTypes( typeLookup );
+        this.moduleName = module.name();
+        visibleTypes = formatVisibleTypes( module.typeLookup() );
+        candidateTypes = findCandidateTypes( module );
     }
 
     public String compositeType()
@@ -86,18 +88,21 @@ public abstract class NoSuchCompositeTypeException extends InvalidApplicationExc
             .collect( joining( "\n", "\tVisible " + metaType + " types are:\n", "" ) );
     }
 
-    private String findCandidateTypes( TypeLookup typeLookup )
+    private String findCandidateTypes( ModuleDescriptor module )
     {
-        return "";
-//        return descriptors( typeLookup )
-//            .filter( type -> compositeType.equals( type.primaryType().getName() ) )
-//            .map( descriptor ->
-//                  {
-//                      Class<?> primarytype = descriptor.primaryType();
-//                      String typeName = primarytype.getName();
-//                      return "\t\t[ " + typeName + "] in [" + descriptor.module().name() + "] with visibility " + descriptor.visibility();
-//                  } )
-//            .collect( joining( "\n", "\tInvisible " + metaType + " types are:\n", "" ) );
+        return Stream.concat( Stream.of( module.layer() ), module.layer().usedLayers().layers() )
+                     .flatMap( LayerDescriptor::modules )
+                     .map( ModuleDescriptor::typeLookup )
+                     .flatMap( this::descriptors )
+                     .filter( type -> compositeType.equals( type.primaryType().getName() ) )
+                     .map( descriptor ->
+                           {
+                               Class<?> primarytype = descriptor.primaryType();
+                               String typeName = primarytype.getName();
+                               return "\t\t[ " + typeName + "] in [" + descriptor.module().name() + "] with visibility " + descriptor.visibility();
+                           } )
+                     .distinct()
+                     .collect( joining( "\n", "\tInvisible " + metaType + " types are:\n", "" ) );
     }
 
     protected abstract Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientTypeException.java b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientTypeException.java
index 45ecd17..8bc188c 100644
--- a/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientTypeException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/composite/NoSuchTransientTypeException.java
@@ -21,6 +21,7 @@
 package org.apache.polygene.api.composite;
 
 import java.util.stream.Stream;
+import org.apache.polygene.api.structure.ModuleDescriptor;
 import org.apache.polygene.api.structure.TypeLookup;
 
 import static java.util.stream.Collectors.joining;
@@ -30,9 +31,9 @@ import static java.util.stream.Collectors.joining;
  */
 public class NoSuchTransientTypeException extends NoSuchCompositeTypeException
 {
-    public NoSuchTransientTypeException( String typeName, String moduleName, TypeLookup typeLookup )
+    public NoSuchTransientTypeException( String typeName, ModuleDescriptor module )
     {
-        super( "TransientComposite", typeName, moduleName, typeLookup );
+        super( "TransientComposite", typeName, module );
     }
 
     protected Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceTypeException.java b/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceTypeException.java
index cc43627..b55270c 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceTypeException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/NoSuchServiceTypeException.java
@@ -25,6 +25,7 @@ import java.util.stream.Stream;
 import org.apache.polygene.api.composite.CompositeDescriptor;
 import org.apache.polygene.api.composite.ModelDescriptor;
 import org.apache.polygene.api.composite.NoSuchCompositeTypeException;
+import org.apache.polygene.api.structure.ModuleDescriptor;
 import org.apache.polygene.api.structure.TypeLookup;
 
 /**
@@ -32,9 +33,9 @@ import org.apache.polygene.api.structure.TypeLookup;
  */
 public class NoSuchServiceTypeException extends NoSuchCompositeTypeException
 {
-    public NoSuchServiceTypeException( String typeName, String moduleName, TypeLookup typeLookup )
+    public NoSuchServiceTypeException( String typeName, ModuleDescriptor module )
     {
-        super( "ServiceComposite", typeName, moduleName, typeLookup );
+        super( "ServiceComposite", typeName, module );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/api/src/main/java/org/apache/polygene/api/structure/LayerDescriptor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/structure/LayerDescriptor.java b/core/api/src/main/java/org/apache/polygene/api/structure/LayerDescriptor.java
index e8270ae..c68e02f 100644
--- a/core/api/src/main/java/org/apache/polygene/api/structure/LayerDescriptor.java
+++ b/core/api/src/main/java/org/apache/polygene/api/structure/LayerDescriptor.java
@@ -32,7 +32,6 @@ import org.apache.polygene.api.value.ValueDescriptor;
  */
 public interface LayerDescriptor
 {
-
     /**
      * @return the Layer's name
      */
@@ -45,6 +44,8 @@ public interface LayerDescriptor
      */
     UsedLayersDescriptor usedLayers();
 
+    Stream<? extends ModuleDescriptor> modules();
+
     Stream<? extends ObjectDescriptor> visibleObjects( Visibility visibility );
 
     Stream<? extends TransientDescriptor> visibleTransients( Visibility visibility );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java b/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java
index a020c6e..8dd5668 100644
--- a/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/unitofwork/NoSuchEntityTypeException.java
@@ -22,6 +22,7 @@ package org.apache.polygene.api.unitofwork;
 import java.util.stream.Stream;
 import org.apache.polygene.api.composite.CompositeDescriptor;
 import org.apache.polygene.api.composite.NoSuchCompositeTypeException;
+import org.apache.polygene.api.structure.ModuleDescriptor;
 import org.apache.polygene.api.structure.TypeLookup;
 
 import static java.util.stream.Collectors.joining;
@@ -30,12 +31,11 @@ import static java.util.stream.Collectors.joining;
  * Polygene exception to be thrown in case that an entity composite
  * was not found during a lookup call.
  */
-public class NoSuchEntityTypeException
-    extends NoSuchCompositeTypeException
+public class NoSuchEntityTypeException extends NoSuchCompositeTypeException
 {
-    public NoSuchEntityTypeException( String typeName, String moduleName, TypeLookup typeLookup )
+    public NoSuchEntityTypeException( String typeName, ModuleDescriptor module )
     {
-        super( "EntityComposite", typeName, moduleName, typeLookup  );
+        super( "EntityComposite", typeName, module );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueTypeException.java b/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueTypeException.java
index 77d2dc5..6538a31 100644
--- a/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueTypeException.java
+++ b/core/api/src/main/java/org/apache/polygene/api/value/NoSuchValueTypeException.java
@@ -22,6 +22,7 @@ package org.apache.polygene.api.value;
 import java.util.stream.Stream;
 import org.apache.polygene.api.composite.CompositeDescriptor;
 import org.apache.polygene.api.composite.NoSuchCompositeTypeException;
+import org.apache.polygene.api.structure.ModuleDescriptor;
 import org.apache.polygene.api.structure.TypeLookup;
 
 import static java.util.stream.Collectors.joining;
@@ -29,12 +30,11 @@ import static java.util.stream.Collectors.joining;
 /**
  * Thrown when no visible value of the requested type is found.
  */
-public class NoSuchValueTypeException
-    extends NoSuchCompositeTypeException
+public class NoSuchValueTypeException extends NoSuchCompositeTypeException
 {
-    public NoSuchValueTypeException( String valueType, String moduleName, TypeLookup typeLookup )
+    public NoSuchValueTypeException( String valueType, ModuleDescriptor module )
     {
-        super( "ValueComposite", valueType, moduleName, typeLookup );
+        super( "ValueComposite", valueType, module );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/runtime/src/main/java/org/apache/polygene/runtime/structure/LayerModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/LayerModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/LayerModel.java
index 59cf733..488283b 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/LayerModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/LayerModel.java
@@ -30,6 +30,7 @@ import org.apache.polygene.api.entity.EntityDescriptor;
 import org.apache.polygene.api.object.ObjectDescriptor;
 import org.apache.polygene.api.structure.Layer;
 import org.apache.polygene.api.structure.LayerDescriptor;
+import org.apache.polygene.api.structure.ModuleDescriptor;
 import org.apache.polygene.api.util.HierarchicalVisitor;
 import org.apache.polygene.api.util.VisitableHierarchy;
 import org.apache.polygene.api.value.ValueDescriptor;
@@ -75,9 +76,9 @@ public final class LayerModel
         return metaInfo.get( infoType );
     }
 
-    public Iterable<ModuleModel> modules()
+    public Stream<? extends ModuleDescriptor> modules()
     {
-        return modules;
+        return modules.stream();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
index 9422816..969ae18 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
@@ -118,8 +118,8 @@ public class ModuleInstance
 
     @SuppressWarnings( "LeakingThisInConstructor" )
     ModuleInstance( ModuleModel moduleModel, LayerDescriptor layer, TypeLookup typeLookup,
-                           ServicesModel servicesModel, ImportedServicesModel importedServicesModel
-    )
+                    ServicesModel servicesModel, ImportedServicesModel importedServicesModel
+                  )
     {
         // Constructor parameters
         model = moduleModel;
@@ -208,7 +208,7 @@ public class ModuleInstance
 
         if( model == null )
         {
-            throw new NoSuchTransientTypeException( mixinType.getName(), name(), typeLookup );
+            throw new NoSuchTransientTypeException( mixinType.getName(), descriptor() );
         }
 
         Map<AccessibleObject, Property<?>> properties = new HashMap<>();
@@ -250,7 +250,7 @@ public class ModuleInstance
 
         if( compositeModelModule == null )
         {
-            throw new NoSuchValueTypeException( mixinType.getName(), name(), typeLookup );
+            throw new NoSuchValueTypeException( mixinType.getName(), descriptor() );
         }
 
         StateResolver stateResolver = new InitialStateResolver( compositeModelModule.module() );
@@ -263,7 +263,7 @@ public class ModuleInstance
                                                          Function<AssociationDescriptor, EntityReference> associationFunction,
                                                          Function<AssociationDescriptor, Stream<EntityReference>> manyAssociationFunction,
                                                          Function<AssociationDescriptor, Stream<Map.Entry<String, EntityReference>>> namedAssociationFunction
-    )
+                                                       )
     {
         Objects.requireNonNull( propertyFunction, "propertyFunction" );
         Objects.requireNonNull( associationFunction, "associationFunction" );
@@ -274,7 +274,7 @@ public class ModuleInstance
 
         if( compositeModelModule == null )
         {
-            throw new NoSuchValueTypeException( mixinType.getName(), name(), typeLookup );
+            throw new NoSuchValueTypeException( mixinType.getName(), descriptor() );
         }
 
         StateResolver stateResolver = new FunctionStateResolver(
@@ -332,7 +332,7 @@ public class ModuleInstance
 
         if( model == null )
         {
-            throw new NoSuchValueTypeException( valueType.getName(), name(), typeLookup );
+            throw new NoSuchValueTypeException( valueType.getName(), descriptor() );
         }
 
         return new ValueBuilderWithPrototype<>( model, this, prototype );
@@ -347,7 +347,7 @@ public class ModuleInstance
 
         if( model == null )
         {
-            throw new NoSuchValueTypeException( mixinType.getName(), name(), typeLookup );
+            throw new NoSuchValueTypeException( mixinType.getName(), descriptor() );
         }
 
         try
@@ -380,7 +380,7 @@ public class ModuleInstance
         ModelDescriptor serviceModel = typeLookup.lookupServiceModel( serviceType );
         if( serviceModel == null )
         {
-            throw new NoSuchServiceTypeException( serviceType.getTypeName(), name(), typeLookup );
+            throw new NoSuchServiceTypeException( serviceType.getTypeName(), descriptor() );
         }
         return findServiceReferenceInstance( serviceModel );
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
index a863364..0cf26f0 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
@@ -181,7 +181,7 @@ public class ModuleUnitOfWork
 
         if( model == null )
         {
-            throw new NoSuchEntityTypeException( type.getName(), module.name(), module.typeLookup() );
+            throw new NoSuchEntityTypeException( type.getName(), module );
         }
 
         ModuleDescriptor modelModule = model.module();
@@ -238,7 +238,7 @@ public class ModuleUnitOfWork
 
         if( model == null )
         {
-            throw new NoSuchEntityTypeException( type.getName(), module.name(), module.typeLookup() );
+            throw new NoSuchEntityTypeException( type.getName(), module );
         }
 
         ModuleDescriptor modelModule = model.module();
@@ -283,7 +283,7 @@ public class ModuleUnitOfWork
 
         if( !models.iterator().hasNext() )
         {
-            throw new NoSuchEntityTypeException( type.getName(), module.name(), module.typeLookup() );
+            throw new NoSuchEntityTypeException( type.getName(), module );
         }
 
         return uow.get( EntityReference.create( identity ), this, models, type );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/UnitOfWorkInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/UnitOfWorkInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/UnitOfWorkInstance.java
index 927f04b..33745f7 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/UnitOfWorkInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/UnitOfWorkInstance.java
@@ -157,7 +157,7 @@ public final class UnitOfWorkInstance
                 }
                 else
                 {
-                    throw new NoSuchEntityTypeException( mixinType.getName(), module.name(), module.typeLookup() );
+                    throw new NoSuchEntityTypeException( mixinType.getName(), module );
                 }
             }
             // Create instance

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java
index d92ad72..6789d95 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueBuilderInstance.java
@@ -86,7 +86,7 @@ public final class ValueBuilderInstance<T>
 
         if( valueModel == null )
         {
-            throw new NoSuchValueTypeException( valueType.getName(), currentModule.name(), currentModule.typeLookup() );
+            throw new NoSuchValueTypeException( valueType.getName(), currentModule.descriptor() );
         }
         return new ValueBuilderWithPrototype<>( valueModel, currentModule, prototype() ).newInstance();
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
index 496e503..3f9703e 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
@@ -203,7 +203,7 @@ public final class ValueModel extends CompositeModel
         List<EntityDescriptor> descriptors = lookup.lookupEntityModels( rawClass );
         if( descriptors.size() == 0 )
         {
-            throw new NoSuchEntityTypeException( rawClass.getName(), module.name(), lookup );
+            throw new NoSuchEntityTypeException( rawClass.getName(), module );
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java
index adb0ccb..fd557e2 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeFactoryImplTest.java
@@ -22,6 +22,7 @@ package org.apache.polygene.runtime.composite;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.util.Properties;
+import org.apache.polygene.api.common.ConstructionException;
 import org.apache.polygene.test.AbstractPolygeneTest;
 import org.junit.Test;
 import org.apache.polygene.api.common.AppliesTo;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/runtime/src/test/java/org/apache/polygene/runtime/structure/NoSuchEntityTypeExceptionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/structure/NoSuchEntityTypeExceptionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/structure/NoSuchEntityTypeExceptionTest.java
new file mode 100644
index 0000000..a65802b
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/structure/NoSuchEntityTypeExceptionTest.java
@@ -0,0 +1,95 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  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.apache.polygene.runtime.structure;
+
+import org.apache.polygene.api.composite.NoSuchTransientTypeException;
+import org.apache.polygene.api.unitofwork.NoSuchEntityTypeException;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.value.NoSuchValueTypeException;
+import org.apache.polygene.api.value.ValueBuilder;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
+import org.apache.polygene.test.entity.model.AbstractPolygeneMultiLayeredTestWithModel;
+import org.apache.polygene.test.entity.model.monetary.CheckBookSlip;
+import org.apache.polygene.test.entity.model.monetary.Currency;
+import org.apache.polygene.test.entity.model.people.Person;
+import org.apache.polygene.test.entity.model.people.Rent;
+import org.junit.Test;
+
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+public class NoSuchEntityTypeExceptionTest extends AbstractPolygeneMultiLayeredTestWithModel
+{
+    @Test
+    public void givenNoVisibilityWhenCreatingValueExpectClearException()
+    {
+        try
+        {
+            ValueBuilder<Rent> builder = valueBuilderFactory.newValueBuilder( Rent.class );
+            fail( NoSuchValueTypeException.class.getSimpleName() + " should have been thrown." );
+        }
+        catch( NoSuchValueTypeException e )
+        {
+            String expectedString = "\tInvisible ValueComposite types are:" + System.getProperty( "line.separator" )
+                                    + "\t\t[ org.apache.polygene.test.entity.model.people.Rent] in [People Module] with visibility module";
+            assertThat( e.getMessage(), containsString( expectedString ) );
+        }
+    }
+
+    @Test
+    public void givenNoVisibilityWhenCreatingTransientExpectClearException()
+    {
+        try
+        {
+            CheckBookSlip slip = transientBuilderFactory.newTransient( CheckBookSlip.class );
+            fail( NoSuchTransientTypeException.class.getSimpleName() + " should have been thrown." );
+        }
+        catch( NoSuchTransientTypeException e )
+        {
+            String expectedString = "\tInvisible TransientComposite types are:" + System.getProperty( "line.separator" )
+                                    + "\t\t[ org.apache.polygene.test.entity.model.monetary.CheckBookSlip] in [Monetary Module] with visibility module";
+            assertThat( e.getMessage(), containsString( expectedString ) );
+        }
+    }
+
+    @Test
+    public void givenNoVisibilityWhenCreatingEntityExpectClearException()
+    {
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
+        {
+            Person p = uow.newEntity( Person.class );
+            fail( NoSuchEntityTypeException.class.getSimpleName() + " should have been thrown." );
+        }
+        catch( NoSuchEntityTypeException e )
+        {
+            String expectedString = "\tInvisible EntityComposite types are:" + System.getProperty( "line.separator" )
+                                    + "\t\t[ org.apache.polygene.test.entity.model.people.Person] in [People Module] with visibility layer";
+            assertThat( e.getMessage(), containsString( expectedString ) );
+        }
+    }
+
+    protected void defineStorageModule( ModuleAssembly module )
+    {
+        module.defaultServices();
+        module.services( MemoryEntityStoreService.class ).instantiateOnStartup();
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/AbstractPolygeneMultiLayeredTestWithModel.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/AbstractPolygeneMultiLayeredTestWithModel.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/AbstractPolygeneMultiLayeredTestWithModel.java
new file mode 100644
index 0000000..0c0500d
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/AbstractPolygeneMultiLayeredTestWithModel.java
@@ -0,0 +1,161 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  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.apache.polygene.test.entity.model;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.polygene.api.association.NamedAssociation;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.composite.TransientBuilderFactory;
+import org.apache.polygene.api.constraint.ConstraintViolationException;
+import org.apache.polygene.api.identity.Identity;
+import org.apache.polygene.api.injection.scope.Service;
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.object.ObjectFactory;
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.api.structure.ApplicationDescriptor;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.unitofwork.NoSuchEntityException;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.api.value.ValueBuilderFactory;
+import org.apache.polygene.bootstrap.ApplicationAssembly;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
+import org.apache.polygene.spi.serialization.JsonSerialization;
+import org.apache.polygene.test.AbstractPolygeneBaseTest;
+import org.apache.polygene.test.entity.model.legal.LegalService;
+import org.apache.polygene.test.entity.model.legal.Will;
+import org.apache.polygene.test.entity.model.legal.WillAmount;
+import org.apache.polygene.test.entity.model.legal.WillItem;
+import org.apache.polygene.test.entity.model.legal.WillPercentage;
+import org.apache.polygene.test.entity.model.monetary.CheckBookSlip;
+import org.apache.polygene.test.entity.model.monetary.Currency;
+import org.apache.polygene.test.entity.model.people.Address;
+import org.apache.polygene.test.entity.model.people.City;
+import org.apache.polygene.test.entity.model.people.Country;
+import org.apache.polygene.test.entity.model.people.PeopleRepository;
+import org.apache.polygene.test.entity.model.people.Person;
+import org.apache.polygene.test.entity.model.people.PhoneNumber;
+import org.apache.polygene.test.entity.model.people.Rent;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public abstract class AbstractPolygeneMultiLayeredTestWithModel extends AbstractPolygeneBaseTest
+{
+    private static final String FRIEND = "Friend";
+    private static final String COLLEAGUE = "Colleague";
+
+    protected ModuleAssembly configModule;
+
+    @Structure
+    protected ValueBuilderFactory valueBuilderFactory;
+
+    @Structure
+    protected TransientBuilderFactory transientBuilderFactory;
+
+    @Structure
+    protected UnitOfWorkFactory unitOfWorkFactory;
+
+    @Structure
+    protected ObjectFactory objectFactory;
+
+    @Override
+    protected void defineApplication( ApplicationAssembly applicationAssembly )
+        throws AssemblyException
+    {
+        LayerAssembly accessLayer = applicationAssembly.layer( "Access Layer" );
+        LayerAssembly domainLayer = applicationAssembly.layer( "Domain Layer" );
+        LayerAssembly infrastructureLayer = applicationAssembly.layer( "Infrastructure Layer" );
+        LayerAssembly configLayer = applicationAssembly.layer( "Configuration Layer" );
+        accessLayer.uses( domainLayer.uses( infrastructureLayer.uses( configLayer ) ) );
+        defineConfigModule( configLayer.module( "Configuration Module" ) );
+        defineSerializationModule( configLayer.module( "Serialization Module" ) );
+        defineStorageModule( infrastructureLayer.module( "Storage Module" ) );
+        defineMonetaryModule( domainLayer.module( "Monetary Module" ) );
+        definePeopleModule( domainLayer.module( "People Module" ) );
+        defineLegalModule( domainLayer.module( "Legal Module" ) );
+        defineTestModule( accessLayer.module( "TestCase Module" ) );
+    }
+
+    @Override
+    protected Application newApplicationInstance( ApplicationDescriptor applicationModel )
+    {
+        Application application = super.newApplicationInstance( applicationModel );
+        Module module = application.findModule( "Access Layer", "TestCase Module" );
+        module.injectTo( this );
+        return application;
+    }
+
+    protected void defineTestModule( ModuleAssembly module )
+    {
+        module.defaultServices();
+        module.objects( this.getClass() );
+    }
+
+    protected void definePeopleModule( ModuleAssembly module )
+    {
+        module.defaultServices();
+        module.entities( Address.class, Country.class, City.class, PhoneNumber.class );
+        module.entities( Person.class ).visibleIn( Visibility.layer );
+        module.services( PeopleRepository.class ).visibleIn( Visibility.application );
+        module.values( Rent.class );
+        module.objects( Rent.Builder.class ).visibleIn( Visibility.application );
+    }
+
+    protected void defineLegalModule( ModuleAssembly module )
+    {
+        module.defaultServices();
+        module.services( LegalService.class ).visibleIn( Visibility.application );
+        module.entities( Will.class );
+        module.values( WillAmount.class, WillItem.class, WillPercentage.class );
+    }
+
+    protected void defineMonetaryModule( ModuleAssembly module )
+    {
+        module.defaultServices();
+        module.values( Currency.class ).visibleIn( Visibility.layer );
+        module.transients( CheckBookSlip.class );
+        module.transients( Currency.Builder.class ).visibleIn( Visibility.application );
+    }
+
+    protected void defineSerializationModule( ModuleAssembly module )
+    {
+        module.defaultServices();
+        module.services( JsonSerialization.class ).visibleIn( Visibility.application );
+    }
+
+    protected abstract void defineStorageModule( ModuleAssembly module );
+
+    protected void defineConfigModule( ModuleAssembly module )
+    {
+        module.defaultServices();
+        module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.module );
+        configModule = module;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
index 20f0b1f..68b2b9a 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
@@ -23,28 +23,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.apache.polygene.api.association.NamedAssociation;
-import org.apache.polygene.api.common.Visibility;
 import org.apache.polygene.api.constraint.ConstraintViolationException;
 import org.apache.polygene.api.identity.Identity;
 import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.injection.scope.Structure;
-import org.apache.polygene.api.object.ObjectFactory;
-import org.apache.polygene.api.structure.Application;
-import org.apache.polygene.api.structure.ApplicationDescriptor;
-import org.apache.polygene.api.structure.Module;
 import org.apache.polygene.api.unitofwork.NoSuchEntityException;
 import org.apache.polygene.api.unitofwork.UnitOfWork;
-import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
 import org.apache.polygene.api.usecase.UsecaseBuilder;
-import org.apache.polygene.api.value.ValueBuilder;
-import org.apache.polygene.api.value.ValueBuilderFactory;
-import org.apache.polygene.bootstrap.ApplicationAssembly;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.LayerAssembly;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
-import org.apache.polygene.spi.serialization.JsonSerialization;
-import org.apache.polygene.test.AbstractPolygeneBaseTest;
 import org.apache.polygene.test.entity.model.legal.LegalService;
 import org.apache.polygene.test.entity.model.legal.Will;
 import org.apache.polygene.test.entity.model.legal.WillAmount;
@@ -65,28 +49,17 @@ import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInA
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertThat;
 
-public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
+public abstract class EntityStoreTestSuite extends AbstractPolygeneMultiLayeredTestWithModel
 {
     private static final String FRIEND = "Friend";
     private static final String COLLEAGUE = "Colleague";
 
-    protected ModuleAssembly configModule;
-
-    @Structure
-    private ObjectFactory obf;
-
-    @Structure
-    private ValueBuilderFactory vbf;
-
     @Service
     private LegalService legalService;
 
     @Service
     private PeopleRepository peopleRepository;
 
-    @Structure
-    private UnitOfWorkFactory uowf;
-
     private Identity switzerlandId;
     private Identity franceId;
     private Identity denmarkId;
@@ -112,7 +85,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Before
     public void setupTestData()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "TestData Generation" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "TestData Generation" ) ) )
         {
             testData();
             uow.complete();
@@ -122,7 +95,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void validateAllCountriesPresent()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCountriesPresent" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCountriesPresent" ) ) )
         {
             assertThat( peopleRepository.findCountryByCountryCode( "my" ).name().get(), equalTo( "Malaysia" ) );
             assertThat( peopleRepository.findCountryByCountryCode( "us" ).name().get(), equalTo( "United States" ) );
@@ -137,7 +110,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void validateAllCitiesPresent()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCitiesPresent" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCitiesPresent" ) ) )
         {
             assertThat( peopleRepository.findCity( zurichId ).name().get(), equalTo( "Zurich" ) );
             assertThat( peopleRepository.findCity( malmoId ).name().get(), equalTo( "Malmo" ) );
@@ -151,13 +124,13 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void validateAllAddressesPresent()
     {
-        Currency.Builder currencyBuilder = obf.newObject( Currency.Builder.class );
+        Currency.Builder currencyBuilder = transientBuilderFactory.newTransient( Currency.Builder.class );
         Currency eur1000 = currencyBuilder.create( 1000, "EUR" );
         Currency eur1500 = currencyBuilder.create( 1500, "EUR" );
         Currency chf2000 = currencyBuilder.create( 2000, "CHF" );
         Currency myr3000 = currencyBuilder.create( 3000, "MYR" );
         Currency sek9000 = currencyBuilder.create( 9000, "SEK" );
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllAddressesPresent" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllAddressesPresent" ) ) )
         {
             Address canary = peopleRepository.findAddress( canaryId );
             assertThat( canary.street().get(), equalTo( "10, CH5A, Jalan Cheras Hartamas" ) );
@@ -206,7 +179,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void validateAllPersonsPresent()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllPersonsPresent" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllPersonsPresent" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             assertThat( niclas.name().get(), equalTo( "Niclas" ) );
@@ -236,14 +209,14 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             PhoneNumber newNumber = peopleRepository.createPhoneNumber( "+86-185-21320803" );
             niclas.phoneNumbers().put( "Mobile", newNumber );
             uow.complete();
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             NamedAssociation<PhoneNumber> numbers = niclas.phoneNumbers();
@@ -262,7 +235,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void whenIteratingNamedAssociationExpectIterationInOrder()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             PhoneNumber newNumber1 = peopleRepository.createPhoneNumber( "+86-185-21320803" );
@@ -273,7 +246,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
             niclas.phoneNumbers().put( "German", newNumber3 );
             uow.complete();
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             assertThat( niclas.phoneNumbers(), containsInAnyOrder( "Home", "Chinese", "Swedish", "German" ) );
@@ -283,14 +256,14 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             PhoneNumber newNumber = peopleRepository.createPhoneNumber( "+86-185-21320803" );
             niclas.phoneNumbers().put( "Home", newNumber );
             uow.complete();
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             NamedAssociation<PhoneNumber> numbers = niclas.phoneNumbers();
@@ -305,7 +278,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void whenNullingOptionalAssociationExpectSuccess()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenNullingOptionalAssociationExpectSuccess" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenNullingOptionalAssociationExpectSuccess" ) ) )
         {
             Person toni = peopleRepository.findPersonByName( "Toni" );
             toni.spouse().set( null );
@@ -316,7 +289,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test( expected = ConstraintViolationException.class )
     public void whenNullingNonOptionalAssociationExpectFailure()
     {
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenNullingOptionalAssociationExpectSuccess" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenNullingOptionalAssociationExpectSuccess" ) ) )
         {
             Person toni = peopleRepository.findPersonByName( "Toni" );
             toni.nationality().set( null );
@@ -335,7 +308,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         Identity malaysiaId;
         Identity canaryId;
         Identity despairStId;
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             PhoneNumber newNumber1 = peopleRepository.createPhoneNumber( "+86-185-21320803" );
@@ -351,10 +324,10 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
 
             City zurich = peopleRepository.findCity( zurichId );
             Country switzerland = peopleRepository.findCountryByCountryCode( "ch" );
-            niclas.movedToNewAddress( "DespairStreet 12A", "43HQ21", zurich, switzerland, obf.newObject( Rent.Builder.class ).create( 1000, "EUR" ) );
+            niclas.movedToNewAddress( "DespairStreet 12A", "43HQ21", zurich, switzerland, objectFactory.newObject( Rent.Builder.class ).create( 1000, "EUR" ) );
             uow.complete();
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             assertThat( niclas.nationality().get().name().get(), equalTo( "Sweden" ) );
@@ -365,13 +338,13 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
             malaysiaId = niclas.oldAddresses().get( 0 ).country().get().identity().get();
             switzerlandId = niclas.address().get().country().get().identity().get();
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
             uow.remove( niclas );
             uow.complete();
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             Person niclas = peopleRepository.findPersonByName( "Niclas" );
         }
@@ -379,7 +352,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         {
             // expected
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             peopleRepository.findPhoneNumberById( homePhoneId );
         }
@@ -387,7 +360,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         {
             // expected
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             peopleRepository.findPhoneNumberById( chinesePhoneId );
         }
@@ -395,7 +368,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         {
             // expected
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             peopleRepository.findPhoneNumberById( swedishPhoneId );
         }
@@ -403,7 +376,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         {
             // expected
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             peopleRepository.findPhoneNumberById( germanPhoneId );
         }
@@ -411,7 +384,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         {
             // expected
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             peopleRepository.findAddress( canaryId );
         }
@@ -419,7 +392,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         {
             // expected
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             peopleRepository.findAddress( despairStId );
         }
@@ -427,7 +400,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         {
             // expected
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
         {
             peopleRepository.findCountryByIdentity( switzerlandId );
             peopleRepository.findCountryByIdentity( malaysiaId );
@@ -448,9 +421,9 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
     @Test
     public void givenEntityInheritanceWhenStoreRetrieveExpectSuccess()
     {
-        Currency.Builder currencyBuilder = obf.newObject( Currency.Builder.class );
+        Currency.Builder currencyBuilder = objectFactory.newObject( Currency.Builder.class );
         Identity willId;
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenEntityInheritanceWhenStoreRetrieveExpectSuccess" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenEntityInheritanceWhenStoreRetrieveExpectSuccess" ) ) )
         {
             Person peter = peopleRepository.findPersonByName( "Peter" );
             Person kalle = peopleRepository.findPersonByName( "Kalle" );
@@ -469,7 +442,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
             willId = will.identity().get();
             uow.complete();
         }
-        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenEntityInheritanceWhenStoreRetrieveExpectSuccess" ) ) )
+        try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - givenEntityInheritanceWhenStoreRetrieveExpectSuccess" ) ) )
         {
             Person kalle = peopleRepository.findPersonByName( "Kalle" );
             Person oscar = peopleRepository.findPersonByName( "Oscar" );
@@ -525,7 +498,7 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         kualaLumpurId = kualalumpur.identity().get();
         City zurich = peopleRepository.createCity( "Zurich" );
         zurichId = zurich.identity().get();
-        Rent.Builder rentBuilder = obf.newObject( Rent.Builder.class );
+        Rent.Builder rentBuilder = objectFactory.newObject( Rent.Builder.class );
         Rent rentCanary = rentBuilder.create( 3000, "MYR" );
         Rent rentVarnhem = rentBuilder.create( 9000, "SEK" );
         Rent rentUnknown1 = rentBuilder.create( 1000, "EUR" );
@@ -567,77 +540,4 @@ public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
         niclasRels.put( COLLEAGUE, toni );
         niclasRels.put( COLLEAGUE, andreas );
     }
-
-    @Override
-    protected void defineApplication( ApplicationAssembly applicationAssembly )
-        throws AssemblyException
-    {
-        LayerAssembly accessLayer = applicationAssembly.layer( "Access Layer" );
-        LayerAssembly domainLayer = applicationAssembly.layer( "Domain Layer" );
-        LayerAssembly infrastructureLayer = applicationAssembly.layer( "Infrastructure Layer" );
-        LayerAssembly configLayer = applicationAssembly.layer( "Configuration Layer" );
-        accessLayer.uses( domainLayer.uses( infrastructureLayer.uses( configLayer ) ) );
-        defineConfigModule( configLayer.module( "Configuration Module" ) );
-        defineSerializationModule( configLayer.module( "Serialization Module" ) );
-        defineStorageModule( infrastructureLayer.module( "Storage Module" ) );
-        defineMonetaryModule( domainLayer.module( "Monetary Module" ) );
-        definePeopleModule( domainLayer.module( "People Module" ) );
-        defineLegalModule( domainLayer.module( "Legal Module" ) );
-        defineTestModule( accessLayer.module( "TestCase Module" ) );
-    }
-
-    @Override
-    protected Application newApplicationInstance( ApplicationDescriptor applicationModel )
-    {
-        Application application = super.newApplicationInstance( applicationModel );
-        Module module = application.findModule( "Access Layer", "TestCase Module" );
-        module.injectTo( this );
-        return application;
-    }
-
-    protected void defineTestModule( ModuleAssembly module )
-    {
-        module.defaultServices();
-        module.objects( this.getClass() );
-    }
-
-    protected void definePeopleModule( ModuleAssembly module )
-    {
-        module.defaultServices();
-        module.entities( Address.class, Country.class, City.class, PhoneNumber.class );
-        module.entities( Person.class ).visibleIn( Visibility.layer );
-        module.services( PeopleRepository.class ).visibleIn( Visibility.application );
-        module.values( Rent.class );
-        module.objects( Rent.Builder.class ).visibleIn( Visibility.application );
-    }
-
-    protected void defineLegalModule( ModuleAssembly module )
-    {
-        module.defaultServices();
-        module.services( LegalService.class ).visibleIn( Visibility.application );
-        module.entities( Will.class );
-        module.values( WillAmount.class, WillItem.class, WillPercentage.class );
-    }
-
-    protected void defineMonetaryModule( ModuleAssembly module )
-    {
-        module.defaultServices();
-        module.values( Currency.class ).visibleIn( Visibility.layer );
-        module.objects( Currency.Builder.class ).visibleIn( Visibility.application );
-    }
-
-    protected void defineSerializationModule( ModuleAssembly module )
-    {
-        module.defaultServices();
-        module.services( JsonSerialization.class ).visibleIn( Visibility.application );
-    }
-
-    protected abstract void defineStorageModule( ModuleAssembly module );
-
-    protected void defineConfigModule( ModuleAssembly module )
-    {
-        module.defaultServices();
-        module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.module );
-        configModule = module;
-    }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/CheckBookSlip.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/CheckBookSlip.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/CheckBookSlip.java
new file mode 100644
index 0000000..956b01d
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/CheckBookSlip.java
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  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.apache.polygene.test.entity.model.monetary;
+
+import org.apache.polygene.api.injection.scope.This;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
+
+@Mixins( CheckBookSlip.CheckBookSlipMixin.class )
+public interface CheckBookSlip
+{
+    String name();
+
+    Currency amount();
+
+    interface State
+    {
+        Property<String> name();
+
+        Property<Currency> amount();
+    }
+
+    class CheckBookSlipMixin
+        implements CheckBookSlip
+    {
+        @This
+        private State state;
+
+        @Override
+        public String name()
+        {
+            return state.name().get();
+        }
+
+        @Override
+        public Currency amount()
+        {
+            return state.amount().get();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/Currency.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/Currency.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/Currency.java
index 6ca2c9b..88a1c31 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/Currency.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/monetary/Currency.java
@@ -21,6 +21,7 @@ package org.apache.polygene.test.entity.model.monetary;
 
 import java.math.BigDecimal;
 import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.mixin.Mixins;
 import org.apache.polygene.api.property.Property;
 import org.apache.polygene.api.value.ValueBuilder;
 import org.apache.polygene.api.value.ValueBuilderFactory;
@@ -30,7 +31,15 @@ public interface Currency
     Property<BigDecimal> amount();
     Property<String> name();
 
-    class Builder
+    @Mixins( Currency.BuilderImpl.class)
+    interface Builder
+    {
+        Currency create( int amount, String currencyName );
+        Currency create( BigDecimal amount, String currencyName );
+    }
+
+    class BuilderImpl
+        implements Builder
     {
         @Structure
         private ValueBuilderFactory vbf;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
index 549e0dc..7ee85f8 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
@@ -153,7 +153,7 @@ public class CassandraEntityStoreMixin
         EntityDescriptor entityDescriptor = module.entityDescriptor( type );
         if( entityDescriptor == null )
         {
-            throw new NoSuchEntityTypeException( type, module.name(), module.typeLookup() );
+            throw new NoSuchEntityTypeException( type, module );
         }
         Map<String, String> storedProperties = row.getMap( PROPERTIES_COLUMN, String.class, String.class );
         Map<String, String> storedAssociations = row.getMap( ASSOCIATIONS_COLUMN, String.class, String.class );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5704bb82/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java b/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
index 5bf1597..9c61b50 100644
--- a/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreMixin.java
@@ -213,7 +213,7 @@ public class PreferencesEntityStoreMixin
             EntityDescriptor entityDescriptor = module.entityDescriptor( type );
             if( entityDescriptor == null )
             {
-                throw new NoSuchEntityTypeException( type, module.name(), module.typeLookup() );
+                throw new NoSuchEntityTypeException( type, module );
             }
 
             Map<QualifiedName, Object> properties = new HashMap<>();


Mime
View raw message