You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2017/07/10 06:53:07 UTC

[05/50] polygene-java git commit: Adding a new test suite for persistence, that is somewhat understandable and not totally non-sense. Also, it is a multi-layered application, to ensure that Type Lookups are handled correctly. JDBM was first victim to get

Adding a new test suite for persistence, that is somewhat understandable and not totally non-sense. Also, it is a multi-layered application, to ensure that Type Lookups are handled correctly.
JDBM was first victim to get this new tests.

Signed-off-by: niclas <ni...@hedhman.org>


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

Branch: refs/heads/es-jooq
Commit: df5fd8af1499e7b0d2531116bed03c8bd17f0c95
Parents: 24fe603
Author: niclas <ni...@hedhman.org>
Authored: Thu Jun 15 13:48:35 2017 +0800
Committer: niclas <ni...@hedhman.org>
Committed: Thu Jun 15 13:48:36 2017 +0800

----------------------------------------------------------------------
 .../polygene/api/entity/EntityReference.java    |   2 +-
 .../polygene/api/identity/StringIdentity.java   |   2 +-
 .../api/identity/UuidGeneratorMixin.java        |   2 +-
 .../org/apache/polygene/api/OperatorsTest.java  |   2 +-
 .../polygene/api/type/ValueTypeFactoryTest.java |   2 +-
 .../polygene/api/unitofwork/RemovalTest.java    |   2 +-
 .../api/unitofwork/ToEntityConversionTest.java  |   2 +-
 .../api/unitofwork/ToValueConversionTest.java   |  12 +-
 .../association/NamedAssociationInstance.java   |   9 +-
 .../bootstrap/ImportedServiceAssemblyImpl.java  |   6 +-
 .../runtime/bootstrap/ModuleAssemblyImpl.java   |   4 +-
 .../bootstrap/ServiceDeclarationImpl.java       |   2 +-
 .../runtime/unitofwork/ModuleUnitOfWork.java    |   2 +-
 .../apache/polygene/api/common/RemovalTest.java |   2 +-
 .../qi377/SetAssociationInSideEffectTest.java   |   4 +-
 ...alueCollisionWithRelatedReturnTypesTest.java |   2 +-
 .../polygene/regression/qi382/Qi382Test.java    |   4 +-
 .../polygene/regression/qi383/Qi383Test.java    |   6 +-
 .../ImportedServiceActivationTest.java          |   2 +-
 .../polygene/runtime/entity/EntityTypeTest.java |   6 +-
 .../runtime/entity/EntityVisibilityTest.java    |   2 +-
 .../runtime/injection/ServiceInjectionTest.java |   2 +-
 .../injection/UnitOfWorkInjectionTest.java      |   2 +-
 .../runtime/mixin/AssemblyMixinTest.java        |   4 +-
 .../runtime/mixin/AssemblyRoleTest.java         |   4 +-
 .../polygene/runtime/mixin/JDKMixinTest.java    |   4 +-
 .../runtime/objects/ObjectVisibilityTest.java   |   2 +-
 .../runtime/query/IterableQuerySourceTest.java  |   2 +-
 .../apache/polygene/runtime/query/Network.java  |   4 +-
 .../runtime/service/ServiceVisibilityTest.java  |   2 +-
 .../transients/TransientVisibilityTest.java     |   2 +-
 .../unitofwork/PrivateEntityUnitOfWorkTest.java |   2 +-
 .../runtime/unitofwork/RemovalTest.java         |   2 +-
 .../runtime/value/AssociationToValueTest.java   |   4 +-
 .../value/ValueSerializationRegressionTest.java |   2 +-
 .../runtime/value/ValueVisibilityTest.java      |   2 +-
 .../runtime/value/ValueWithAssociationTest.java |   6 +-
 .../visibility/VisibilityInUnitOfWorkTest.java  |   4 +-
 .../importer/ServiceInstanceImporterTest.java   |   2 +-
 .../helpers/JSONMapEntityStoreMixin.java        |   2 +-
 .../helpers/MapEntityStoreMixin.java            |   2 +-
 .../spi/serialization/BuiltInConverters.java    |   2 +-
 .../spi/entitystore/Polygene142Test.java        |   2 +-
 .../test/entity/model/EntityStoreTestSuite.java | 546 +++++++++++++++++++
 .../test/entity/model/legal/LegalService.java   | 106 ++++
 .../polygene/test/entity/model/legal/Will.java  |  36 ++
 .../test/entity/model/legal/WillAmount.java     |  28 +
 .../test/entity/model/legal/WillBenefit.java    |  36 ++
 .../test/entity/model/legal/WillItem.java       |  30 +
 .../test/entity/model/legal/WillPercentage.java |  27 +
 .../test/entity/model/people/Address.java       |  37 ++
 .../polygene/test/entity/model/people/City.java |  28 +
 .../test/entity/model/people/Country.java       |  28 +
 .../entity/model/people/PeopleRepository.java   | 183 +++++++
 .../test/entity/model/people/Person.java        |  89 +++
 .../test/entity/model/people/PhoneNumber.java   |  55 ++
 .../polygene/test/entity/model/people/Rent.java |  48 ++
 .../test/indexing/AbstractQueryTest.java        |   6 +-
 .../apache/polygene/test/indexing/TestData.java |   8 +-
 .../metrics/AbstractPolygeneMetricsTest.java    |   4 +-
 ...AbstractValueCompositeSerializationTest.java |   8 +-
 .../cassandra/CassandraEntityStoreMixin.java    |   2 +-
 .../jdbm/JdbmEntityStoreTestSuite.java          |  55 ++
 .../AbstractSQLEntityStoreAssembler.java        |   2 +-
 .../polygene/index/rdf/RDFPerformanceTest.java  |   4 +-
 .../AbstractSQLIndexQueryAssembler.java         |   2 +-
 .../polygene/library/alarm/AlarmSystem.java     |   2 +-
 .../polygene/library/alarm/AlarmProxyTest.java  |   4 +-
 .../jmx/ConfigurationManagerService.java        |   2 +-
 .../rdf/entity/EntitySerializerTest.java        |   4 +-
 .../rdf/entity/EntityTypeSerializerTest.java    |   4 +-
 .../server/restlet/RequestReaderDelegator.java  |   2 +-
 .../server/restlet/ResponseWriterDelegator.java |   2 +-
 .../requestreader/DefaultRequestReader.java     |   4 +-
 .../library/rest/admin/EntityResource.java      |   2 +-
 .../library/rest/admin/DummyDataService.java    |   6 +-
 .../polygene/library/rest/admin/RestTest.java   |   8 +-
 .../library/restlet/crud/EntityResource.java    |   4 +-
 .../restlet/identity/IdentityManager.java       |   4 +-
 .../restlet/resource/EntryPointResource.java    |   6 +-
 .../restlet/resource/ResourceBuilder.java       |   2 +-
 .../sql/assembly/DataSourceAssembler.java       |   2 +-
 .../assembly/ExternalDataSourceAssembler.java   |   2 +-
 .../DataSourceConfigurationManagerService.java  |   2 +-
 .../moneytransfer/context/PayBillsContext.java  |   4 +-
 .../moneytransfer/context/PayBillsContext2.java |   4 +-
 .../dci/moneytransfer/test/AccountIds.java      |   8 +-
 .../sample/forum/data/entity/Forums.java        |   2 +-
 .../sample/forum/data/entity/Users.java         |   2 +-
 .../rest/resource/forum/BoardResource.java      |   2 +-
 .../rest/resource/forum/ForumResource.java      |   2 +-
 .../rest/resource/forum/ForumsResource.java     |   2 +-
 .../sample/rental/domain/dev/InitialData.java   |   2 +-
 .../polygene/sample/rental/web/BookingPage.java |   4 +-
 .../polygene/sample/rental/web/MainPage.java    |   2 +-
 .../AbstractEntityStorePerformanceTest.java     |   4 +-
 .../initialdata/SamplePersonInitialData.java    |   2 +-
 .../polygene/tutorials/hello/HelloTest4.java    |   2 +-
 98 files changed, 1474 insertions(+), 135 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
index 9952994..68e2232 100644
--- a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
@@ -41,7 +41,7 @@ public final class EntityReference
     public static EntityReference parseEntityReference(String identityString)
     {
         Objects.requireNonNull( identityString, "identityString must not be null" );
-        return new EntityReference( StringIdentity.fromString( identityString ) );
+        return new EntityReference( StringIdentity.identity( identityString ) );
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java b/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
index 7d85381..3eba611 100644
--- a/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
@@ -55,7 +55,7 @@ public class StringIdentity
         return value;
     }
 
-    public static Identity fromString(String serializedState)
+    public static Identity identity( String serializedState )
     {
         return new StringIdentity( serializedState );
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java b/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
index 0add4c6..6f85ca7 100644
--- a/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
@@ -27,6 +27,6 @@ public class UuidGeneratorMixin
     @Override
     public Identity generate(Class<?> compositeType)
     {
-        return StringIdentity.fromString(UUID.randomUUID().toString());
+        return StringIdentity.identity( UUID.randomUUID().toString() );
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java b/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
index 72f8c7f..f018907 100644
--- a/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
@@ -63,7 +63,7 @@ public class OperatorsTest
 
         try
         {
-            EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "123" ) );
+            EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
             entityBuilder.instance().value().set( assembler.module().newValue( TestValue.class ) );
             TestEntity testEntity = entityBuilder.newInstance();
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java b/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
index bd9ce3b..48ac6a5 100644
--- a/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
@@ -125,7 +125,7 @@ public class ValueTypeFactoryTest extends AbstractPolygeneTest
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
         {
             assertThat(
-                valueTypeFactory.valueTypeOf( module, uow.newEntity( SomeState.class, StringIdentity.fromString( "abc" ) ) ),
+                valueTypeFactory.valueTypeOf( module, uow.newEntity( SomeState.class, StringIdentity.identity( "abc" ) ) ),
                 instanceOf( EntityCompositeType.class ) );
         }
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
index 97b78db..f3a01d9 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
@@ -49,7 +49,7 @@ public class RemovalTest
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
         try
         {
-            EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "123" ) );
+            EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
             builder.instance().test().set( "habba" );
             TestEntity test = builder.newInstance();
             uow.remove( test );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
index 055a1db..86ac547 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
@@ -65,7 +65,7 @@ public class ToEntityConversionTest
     public void testPropertyConversionToEntity()
         throws Exception
     {
-        Identity identity = StringIdentity.fromString( "Niclas" );
+        Identity identity = StringIdentity.identity( "Niclas" );
         ValueBuilder<SomeType> vb = valueBuilderFactory.newValueBuilder( SomeType.class );
         SomeType prototype = vb.prototype();
         prototype.identity().set( identity );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
index ae9c7c2..910cf72 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
@@ -73,11 +73,11 @@ public class ToValueConversionTest
         SomeType value;
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(usecase) )
         {
-            SomeType entity1 = createEntity( uow, StringIdentity.fromString( "Niclas" ) );
-            SomeType entity2 = createEntity( uow, StringIdentity.fromString( "Paul" ) );
-            SomeType entity3 = createEntity( uow, StringIdentity.fromString( "Jiri" ) );
-            SomeType entity4 = createEntity( uow, StringIdentity.fromString( "Kent" ) );
-            SomeType entity5 = createEntity( uow, StringIdentity.fromString( "Stan" ) );
+            SomeType entity1 = createEntity( uow, StringIdentity.identity( "Niclas" ) );
+            SomeType entity2 = createEntity( uow, StringIdentity.identity( "Paul" ) );
+            SomeType entity3 = createEntity( uow, StringIdentity.identity( "Jiri" ) );
+            SomeType entity4 = createEntity( uow, StringIdentity.identity( "Kent" ) );
+            SomeType entity5 = createEntity( uow, StringIdentity.identity( "Stan" ) );
             entity1.assoc().set( entity2 );
             entity1.many().add( entity3 );
             entity1.named().put( "kent", entity4 );
@@ -89,7 +89,7 @@ public class ToValueConversionTest
         }
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(usecase) )
         {
-            assertThat( value.identity().get(), equalTo( StringIdentity.fromString( "Niclas" ) ) );
+            assertThat( value.identity().get(), equalTo( StringIdentity.identity( "Niclas" ) ) );
             assertThat( value.name().get(), equalTo( "[Niclas]" ) );
 
             assertThat( uow.toValue( SomeType.class, value.assoc().get()).name().get(), equalTo( "[Paul]" ));

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
index e855c57..fffc760 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
@@ -74,7 +74,14 @@ public class NamedAssociationInstance<T> extends AbstractAssociationInstance<T>
     {
         Objects.requireNonNull( entity, "entity" );
         checkImmutable();
-        checkType( entity );
+        try
+        {
+            checkType( entity );
+        }
+        catch( IllegalArgumentException e )
+        {
+            throw new IllegalArgumentException( "Named association [" + name +"] must have Identity: " + entity );
+        }
         associationInfo.checkConstraints( entity );
         return namedAssociationState.put( name, EntityReference.create( ( (HasIdentity) entity ).identity().get() ) );
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
index 2c7905b..614df0b 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
@@ -78,7 +78,7 @@ public final class ImportedServiceAssemblyImpl
             }
             else
             {
-                id = StringIdentity.fromString( identity );
+                id = StringIdentity.identity( identity );
             }
 
             ImportedServiceModel serviceModel = new ImportedServiceModel( module,
@@ -103,7 +103,7 @@ public final class ImportedServiceAssemblyImpl
     {
         // Find reference that is not yet used
         int idx = 0;
-        Identity id = StringIdentity.fromString( serviceType.getSimpleName() );
+        Identity id = StringIdentity.identity( serviceType.getSimpleName() );
         boolean invalid;
         do
         {
@@ -113,7 +113,7 @@ public final class ImportedServiceAssemblyImpl
                 if( serviceModel.identity().equals( id ) )
                 {
                     idx++;
-                    id = StringIdentity.fromString( serviceType.getSimpleName() + "_" + idx );
+                    id = StringIdentity.identity( serviceType.getSimpleName() + "_" + idx );
                     invalid = true;
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
index f69fe9f..225857d 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -708,7 +708,7 @@ final class ModuleAssemblyImpl
         Class<?> serviceType = serviceTypes.findFirst()
                 .orElse(null); // Use the first, which *SHOULD* be the main serviceType
         int idx = 0;
-        Identity id = StringIdentity.fromString(serviceType.getSimpleName());
+        Identity id = StringIdentity.identity( serviceType.getSimpleName() );
         boolean invalid;
         do
         {
@@ -718,7 +718,7 @@ final class ModuleAssemblyImpl
                 if (serviceAssembly.identity() != null && serviceAssembly.identity().equals(id))
                 {
                     idx++;
-                    id = StringIdentity.fromString(serviceType.getSimpleName() + "_" + idx);
+                    id = StringIdentity.identity( serviceType.getSimpleName() + "_" + idx );
                     invalid = true;
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
index e5e17bb..92db867 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
@@ -59,7 +59,7 @@ public final class ServiceDeclarationImpl
         for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
         {
             if( identity != null ) {
-                serviceAssembly.identity = StringIdentity.fromString( identity );
+                serviceAssembly.identity = StringIdentity.identity( identity );
             }
         }
         return this;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/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 b836f67..071d2c3 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
@@ -264,7 +264,7 @@ public class ModuleUnitOfWork
             }
             else
             {
-                identity = StringIdentity.fromString( propertyState );
+                identity = StringIdentity.identity( propertyState );
             }
         }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java b/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
index 0c67baa..6c514c9 100644
--- a/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
@@ -48,7 +48,7 @@ public class RemovalTest
         throws Exception
     {
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
-        EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.fromString( "123" ) );
+        EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
         builder.instance().test().set( "habba" );
         TestEntity test = builder.newInstance();
         uow.remove( test );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
index 941099b..84b6aed 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
@@ -61,8 +61,8 @@ public class SetAssociationInSideEffectTest
     {
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Purchase Steinway" ) ) )
         {
-            Pianist chris = uow.newEntity( Pianist.class, StringIdentity.fromString( "Chris" ) );
-            Steinway modelD = uow.newEntity( Steinway.class, StringIdentity.fromString( "ModelD-274" ) );
+            Pianist chris = uow.newEntity( Pianist.class, StringIdentity.identity( "Chris" ) );
+            Steinway modelD = uow.newEntity( Steinway.class, StringIdentity.identity( "ModelD-274" ) );
 
             assertThat( modelD.owner().get(), is( nullValue() ) );
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
index 5e49acf..45e8658 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
@@ -36,7 +36,7 @@ public class ValueCollisionWithRelatedReturnTypesTest
     extends AbstractPolygeneTest
 {
 
-    public static final Identity NICLAS = StringIdentity.fromString( "niclas" );
+    public static final Identity NICLAS = StringIdentity.identity( "niclas" );
 
     @Override
     public void assemble( ModuleAssembly module )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
index dd818f9..140fd9d 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
@@ -44,8 +44,8 @@ import static org.junit.Assert.assertThat;
 public class Qi382Test extends AbstractPolygeneTest
 {
 
-    public static final Identity FERRARI = StringIdentity.fromString( "Ferrari" );
-    public static final Identity NICLAS = StringIdentity.fromString( "Niclas" );
+    public static final Identity FERRARI = StringIdentity.identity( "Ferrari" );
+    public static final Identity NICLAS = StringIdentity.identity( "Niclas" );
 
     @Override
     public void assemble( ModuleAssembly module )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
index ea15a4f..96f0cad 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
@@ -47,9 +47,9 @@ public class Qi383Test extends AbstractPolygeneTest
     {
         try( UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork() )
         {
-            unitOfWork.newEntity( Car.class, StringIdentity.fromString( "Ferrari" ) );
-            unitOfWork.newEntity( Car.class, StringIdentity.fromString( "Ford" ) );
-            unitOfWork.newEntity( Car.class, StringIdentity.fromString( "Ferrari" ) );
+            unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ferrari" ) );
+            unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ford" ) );
+            unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ferrari" ) );
             unitOfWork.complete();
         }
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
index db3cca8..07674f0 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
@@ -179,7 +179,7 @@ public class ImportedServiceActivationTest
             module -> {
                 module.importedServices( TestedService.class ).
                     importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER ).
-                          setMetaInfo( StringIdentity.fromString( "testimporter" ) ).
+                          setMetaInfo( StringIdentity.identity( "testimporter" ) ).
                           withActivators( TestedActivator.class ).
                           importOnStartup();
                 module.services( TestedServiceImporterService.class ).identifiedBy( "testimporter" );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
index ab7bf79..1c63573 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
@@ -40,9 +40,9 @@ public class EntityTypeTest
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
         try
         {
-            EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, StringIdentity.fromString( "123" ) );
-            EntityBuilder<Def> builder2 = uow.newEntityBuilder( Def.class, StringIdentity.fromString( "456" ) );
-            EntityBuilder<Abc> builder1 = uow.newEntityBuilder( Abc.class, StringIdentity.fromString( "789" ) );
+            EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, StringIdentity.identity( "123" ) );
+            EntityBuilder<Def> builder2 = uow.newEntityBuilder( Def.class, StringIdentity.identity( "456" ) );
+            EntityBuilder<Abc> builder1 = uow.newEntityBuilder( Abc.class, StringIdentity.identity( "789" ) );
         }
         finally
         {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
index 908e8f2..519d2a7 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
@@ -47,7 +47,7 @@ import org.junit.Test;
 public class EntityVisibilityTest
 {
 
-    public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+    public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
 
     private Energy4Java polygene;
     private Module module;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
index 9fa6411..637a141 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
@@ -82,7 +82,7 @@ public class ServiceInjectionTest
         ServiceUser user = factory.newObject( ServiceUser.class );
 
         assertEquals( "X", user.testSingle() );
-        assertThat( user.testIdentity(), equalTo( StringIdentity.fromString( "Foo" ) ) );
+        assertThat( user.testIdentity(), equalTo( StringIdentity.identity( "Foo" ) ) );
         assertEquals( "FooX", user.testServiceReference() );
         assertEquals( "Bar", user.testQualifier() );
         assertEquals( "A", user.testStringIterable() );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
index 105a698..cd61437 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
@@ -53,7 +53,7 @@ public class UnitOfWorkInjectionTest
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase );
         try
         {
-            Trial trial = uow.newEntity( Trial.class, StringIdentity.fromString( "123" ) );
+            Trial trial = uow.newEntity( Trial.class, StringIdentity.identity( "123" ) );
             trial.doSomething();
             uow.complete();
             uow = unitOfWorkFactory.newUnitOfWork( usecase );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
index 6432ccb..2b3b6af 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
@@ -62,11 +62,11 @@ public class AssemblyMixinTest
         throws UnitOfWorkCompletionException
     {
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
-        FooEntity entity = uow.newEntity( FooEntity.class, StringIdentity.fromString( "123" ) );
+        FooEntity entity = uow.newEntity( FooEntity.class, StringIdentity.identity( "123" ) );
         uow.complete();
 
         uow = unitOfWorkFactory.newUnitOfWork();
-        Foo foo = uow.get( Foo.class, StringIdentity.fromString( "123" ) );
+        Foo foo = uow.get( Foo.class, StringIdentity.identity( "123" ) );
 
         try
         {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
index 965d8a8..f051aec 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
@@ -71,11 +71,11 @@ public class AssemblyRoleTest
         throws UnitOfWorkCompletionException
     {
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
-        uow.newEntity( FooEntity.class, StringIdentity.fromString( "123" ) );
+        uow.newEntity( FooEntity.class, StringIdentity.identity( "123" ) );
         uow.complete();
 
         uow = unitOfWorkFactory.newUnitOfWork();
-        Foo foo = uow.get( Foo.class, StringIdentity.fromString( "123" ) );
+        Foo foo = uow.get( Foo.class, StringIdentity.identity( "123" ) );
 
         try
         {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
index 8bf7e41..831babd 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
@@ -98,8 +98,8 @@ public class JDKMixinTest extends AbstractPolygeneTest
         }
     }
 
-    private static final Identity EXTENDS_IDENTITY = StringIdentity.fromString( ExtendsJDKMixin.class.getName() );
-    private static final Identity COMPOSE_IDENTITY = StringIdentity.fromString( ComposeWithJDKMixin.class.getName() );
+    private static final Identity EXTENDS_IDENTITY = StringIdentity.identity( ExtendsJDKMixin.class.getName() );
+    private static final Identity COMPOSE_IDENTITY = StringIdentity.identity( ComposeWithJDKMixin.class.getName() );
     private static final Predicate<ServiceReference<?>> EXTENDS_IDENTITY_SPEC = new ServiceIdentitySpec(
         EXTENDS_IDENTITY );
     private static final Predicate<ServiceReference<?>> COMPOSE_IDENTITY_SPEC = new ServiceIdentitySpec(

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
index 33785ea..d80d4e5 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
@@ -47,7 +47,7 @@ import org.junit.Test;
 public class ObjectVisibilityTest
 {
 
-    public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+    public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
 
     private Energy4Java polygene;
     private Module module;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
index 9f93dbd..9dbf52f 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
@@ -214,7 +214,7 @@ public class IterableQuerySourceTest
     {
         QueryBuilder<Person> qb = qbf.newQueryBuilder( Person.class );
         Person person = templateFor( Person.class );
-        City kl = uow.get( City.class, StringIdentity.fromString( "kualalumpur" ));
+        City kl = uow.get( City.class, StringIdentity.identity( "kualalumpur" ) );
         Query<Person> query = qb.where(
             eq( person.mother().get().placeOfBirth(), kl )
         ).newQuery( Network.persons() );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
index a84aca2..727d168 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
@@ -44,8 +44,8 @@ import org.apache.polygene.runtime.query.model.values.ContactsValue;
  */
 class Network
 {
-    public static final Identity KUALALUMPUR = StringIdentity.fromString( "kualalumpur" );
-    public static final Identity PENANG = StringIdentity.fromString( "penang" );
+    public static final Identity KUALALUMPUR = StringIdentity.identity( "kualalumpur" );
+    public static final Identity PENANG = StringIdentity.identity( "penang" );
     private static List<Domain> domains;
     private static List<Person> persons;
     private static List<Male> males;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
index f1d2f5c..289be4b 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
@@ -46,7 +46,7 @@ import org.junit.Test;
 
 public class ServiceVisibilityTest
 {
-    public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+    public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
 
     private Energy4Java polygene;
     private Module module;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
index 2a80ff1..6e6abab 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
@@ -47,7 +47,7 @@ import org.junit.Test;
 
 public class TransientVisibilityTest
 {
-    public static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+    public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
     private Energy4Java polygene;
     private Module module;
     private Application app;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
index 8ee0fb0..425ae18 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
@@ -52,7 +52,7 @@ import static org.junit.Assert.fail;
  */
 public class PrivateEntityUnitOfWorkTest
 {
-    private static final Identity TEST_IDENTITY = StringIdentity.fromString( "1" );
+    private static final Identity TEST_IDENTITY = StringIdentity.identity( "1" );
 
     @Structure
     private UnitOfWorkFactory uowf;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
index 765fe6a..1a95f2f 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
@@ -40,7 +40,7 @@ public class RemovalTest
     extends AbstractPolygeneTest
 {
 
-    private static final Identity TEST_IDENTITY = StringIdentity.fromString( "123" );
+    private static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
 
     public void assemble(ModuleAssembly module )
         throws AssemblyException

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
index 2966ea5..ffbe234 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
@@ -151,7 +151,7 @@ public class AssociationToValueTest extends AbstractPolygeneTest
         public Person findPersonByName( String name )
         {
             UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
-            return uow.toValue( Person.class, uow.get( Person.class, StringIdentity.fromString( name ) ) );
+            return uow.toValue( Person.class, uow.get( Person.class, StringIdentity.identity( name ) ) );
         }
     }
 
@@ -206,7 +206,7 @@ public class AssociationToValueTest extends AbstractPolygeneTest
         private Person createPerson( String name )
         {
             UnitOfWork uow = uowf.currentUnitOfWork();
-            return uow.newEntity( Person.class, StringIdentity.fromString( name ) );
+            return uow.newEntity( Person.class, StringIdentity.identity( name ) );
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
index f29895d..f48bfe3 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
@@ -50,7 +50,7 @@ public class ValueSerializationRegressionTest extends AbstractPolygeneTest
         throws UnitOfWorkCompletionException
     {
         ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class );
-        builder.prototype().identity().set( StringIdentity.fromString( "1234" ) );
+        builder.prototype().identity().set( StringIdentity.identity( "1234" ) );
         builder.prototype().name().set( "Hedhman" );
         DualFaced value = builder.newInstance();
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
index b0d7336..191808b 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
@@ -48,7 +48,7 @@ import org.junit.Test;
 public class ValueVisibilityTest
 {
 
-    public static final Identity TEST_IDENTIY = StringIdentity.fromString( "123" );
+    public static final Identity TEST_IDENTIY = StringIdentity.identity( "123" );
     private Energy4Java polygene;
     private Module module;
     private Application app;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
index 02067e5..655505c 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
@@ -113,7 +113,7 @@ public class ValueWithAssociationTest extends AbstractPolygeneTest
         throws UnitOfWorkCompletionException
     {
         ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class );
-        builder.prototype().identity().set( StringIdentity.fromString( "1234" ) );
+        builder.prototype().identity().set( StringIdentity.identity( "1234" ) );
         builder.prototype().name().set( "Hedhman" );
         DualFaced value = builder.newInstance();
 
@@ -125,8 +125,8 @@ public class ValueWithAssociationTest extends AbstractPolygeneTest
 
         try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork())
         {
-            DualFaced entity = uow.get( DualFaced.class, StringIdentity.fromString( "1234" ) );
-            assertThat( entity.identity().get(), equalTo( StringIdentity.fromString( "1234" ) ) );
+            DualFaced entity = uow.get( DualFaced.class, StringIdentity.identity( "1234" ) );
+            assertThat( entity.identity().get(), equalTo( StringIdentity.identity( "1234" ) ) );
             assertThat( entity.name().get(), equalTo( "Hedhman" ) );
             uow.complete();
         }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
index 559605f..ec9d072 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
@@ -41,8 +41,8 @@ import org.junit.Test;
 public class VisibilityInUnitOfWorkTest
 {
 
-    public static final Identity TEST_IDENTITY1 = StringIdentity.fromString( "123" );
-    public static final Identity TEST_IDENTITY2 = StringIdentity.fromString( "345" );
+    public static final Identity TEST_IDENTITY1 = StringIdentity.identity( "123" );
+    public static final Identity TEST_IDENTITY2 = StringIdentity.identity( "345" );
 
     @Test
     public void givenTwoModulesWithServiceAndEntityInOneAndEntityInOtherWhenOtherEntityAccessServiceWhichUsesItsEntityExpectServiceToHaveVisibility()

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java b/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
index 2c566b4..237e8ab 100644
--- a/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
@@ -46,7 +46,7 @@ public class ServiceInstanceImporterTest
     {
         module.importedServices( TestService.class ).
             identifiedBy( "test" ).
-            setMetaInfo( StringIdentity.fromString( "testimporter" ) ).
+            setMetaInfo( StringIdentity.identity( "testimporter" ) ).
             importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER );
         module.services( TestImporterService.class ).identifiedBy( "testimporter" );
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
index b88c189..cedcedc 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -419,7 +419,7 @@ public class JSONMapEntityStoreMixin
 
             String version = parsedState.getString( JSONKeys.VERSION );
             Instant modified = Instant.ofEpochMilli( parsedState.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() );
-            Identity identity = StringIdentity.fromString( parsedState.getString( JSONKeys.IDENTITY ) );
+            Identity identity = StringIdentity.identity( parsedState.getString( JSONKeys.IDENTITY ) );
 
             // Check if version is correct
             JsonObject state;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
index 5e784f7..2c98677 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -382,7 +382,7 @@ public class MapEntityStoreMixin
 
             String version = parsedState.getString( JSONKeys.VERSION );
             Instant modified = Instant.ofEpochMilli( parsedState.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() );
-            Identity identity = StringIdentity.fromString( parsedState.getString( JSONKeys.IDENTITY ) );
+            Identity identity = StringIdentity.identity( parsedState.getString( JSONKeys.IDENTITY ) );
 
             // Check if version is correct
             JsonObject state;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java b/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
index 0c1b774..d86b81d 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
@@ -108,7 +108,7 @@ public interface BuiltInConverters
             @Override
             public Identity fromString( String string )
             {
-                return StringIdentity.fromString( string );
+                return StringIdentity.identity( string );
             }
         }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
----------------------------------------------------------------------
diff --git a/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java b/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
index 85bc744..b9030bd 100644
--- a/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
+++ b/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
@@ -61,7 +61,7 @@ public class Polygene142Test extends AbstractPolygeneTest
             value = serialization.deserialize( module, Regression142Type.class, serialized ); // ok
         }
         {
-            Identity valueId = StringIdentity.fromString( "abcdefg" );
+            Identity valueId = StringIdentity.identity( "abcdefg" );
             {
                 try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "create" ) ) )
                 {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/df5fd8af/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
new file mode 100644
index 0000000..507526d
--- /dev/null
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
@@ -0,0 +1,546 @@
+/*
+ *  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.Iterator;
+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.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.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.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public abstract class EntityStoreTestSuite extends AbstractPolygeneBaseTest
+{
+    private static final String FRIEND = "Friend";
+    private static final String COLLEAGUE = "Colleague";
+
+    @Structure
+    private ObjectFactory obf;
+
+    @Service
+    private LegalService legalService;
+
+    @Service
+    private PeopleRepository peopleRepository;
+
+    @Structure
+    private UnitOfWorkFactory uowf;
+    private Identity baselId;
+    private Identity montpellierId;
+    private Identity hannoverId;
+    private Identity malmoId;
+    private Identity cherasId;
+
+    private Identity unknown3Id;
+    private Identity unknown2Id;
+    private Identity unknown1Id;
+    private Identity varnhemId;
+    private Identity canaryId;
+
+    private Identity switzerlandId;
+    private Identity franceId;
+    private Identity denmarkId;
+    private Identity germanyId;
+    private Identity swedenId;
+    private Identity usId;
+    private Identity malaysiaId;
+
+    @Before
+    public void setupTestData()
+    {
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "TestData Generation" ) ) )
+        {
+            testData();
+            uow.complete();
+        }
+    }
+
+    @Test
+    public void validateAllCountriesPresent()
+    {
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCountriesPresent" ) ) )
+        {
+            assertThat( peopleRepository.findCountryByCountryCode( "my" ).name().get(), equalTo( "Malaysia" ) );
+            assertThat( peopleRepository.findCountryByCountryCode( "us" ).name().get(), equalTo( "United States" ) );
+            assertThat( peopleRepository.findCountryByCountryCode( "se" ).name().get(), equalTo( "Sweden" ) );
+            assertThat( peopleRepository.findCountryByCountryCode( "de" ).name().get(), equalTo( "Germany" ) );
+            assertThat( peopleRepository.findCountryByCountryCode( "dk" ).name().get(), equalTo( "Denmark" ) );
+            assertThat( peopleRepository.findCountryByCountryCode( "fr" ).name().get(), equalTo( "France" ) );
+            assertThat( peopleRepository.findCountryByCountryCode( "ch" ).name().get(), equalTo( "Switzerland" ) );
+        }
+    }
+
+    @Test
+    public void validateAllCitiesPresent()
+    {
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllCitiesPresent" ) ) )
+        {
+            assertThat( peopleRepository.findCity( baselId ).name().get(), equalTo( "Basel" ) );
+            assertThat( peopleRepository.findCity( malmoId ).name().get(), equalTo( "Malmo" ) );
+            assertThat( peopleRepository.findCity( cherasId ).name().get(), equalTo( "Cheras" ) );
+            assertThat( peopleRepository.findCity( hannoverId ).name().get(), equalTo( "Hannover" ) );
+            assertThat( peopleRepository.findCity( montpellierId ).name().get(), equalTo( "Montpellier" ) );
+        }
+    }
+
+    @Test
+    public void validateAllAddressesPresent()
+    {
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllAddressesPresent" ) ) )
+        {
+            Address canary = peopleRepository.findAddress( canaryId );
+            assertThat( canary.street().get(), equalTo( "10, CH5A, Jalan Cheras Hartamas" ) );
+            assertThat( canary.country().get().identity().get(), equalTo( malaysiaId ) );
+            assertThat( canary.city().get().identity().get(), equalTo( cherasId ) );
+            assertThat( canary.zipCode().get(), equalTo( "43200" ) );
+
+            Address varnhem = peopleRepository.findAddress( varnhemId );
+            assertThat( varnhem.street().get(), equalTo( "Varnhemsgatan 25" ) );
+            assertThat( varnhem.city().get().identity().get(), equalTo( malmoId ) );
+            assertThat( varnhem.country().get().identity().get(), equalTo( swedenId ) );
+            assertThat( varnhem.zipCode().get(), equalTo( "215 00" ) );
+
+            Address unknown = peopleRepository.findAddress( unknown1Id );
+            assertThat( unknown.street().get(), equalTo( "" ) );
+            assertThat( unknown.city().get().identity().get(), equalTo( montpellierId ) );
+            assertThat( unknown.country().get().identity().get(), equalTo( franceId ) );
+            assertThat( unknown.zipCode().get(), equalTo( "" ) );
+
+            unknown = peopleRepository.findAddress( unknown2Id );
+            assertThat( unknown.street().get(), equalTo( "" ) );
+            assertThat( unknown.city().get().identity().get(), equalTo( hannoverId ) );
+            assertThat( unknown.country().get().identity().get(), equalTo( germanyId ) );
+            assertThat( unknown.zipCode().get(), equalTo( "" ) );
+
+            unknown = peopleRepository.findAddress( unknown3Id );
+            assertThat( unknown.street().get(), equalTo( "" ) );
+            assertThat( unknown.city().get().identity().get(), equalTo( baselId ) );
+            assertThat( unknown.country().get().identity().get(), equalTo( switzerlandId ) );
+            assertThat( unknown.zipCode().get(), equalTo( "" ) );
+        }
+    }
+
+    @Test
+    public void validateAllPersonsPresent()
+    {
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - validateAllPersonsPresent" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+            assertThat( niclas.name().get(), equalTo( "Niclas" ) );
+            Person eric = peopleRepository.findPersonByName( "Eric" );
+            assertThat( eric.name().get(), equalTo( "Eric" ) );
+            Person paul = peopleRepository.findPersonByName( "Paul" );
+            assertThat( paul.name().get(), equalTo( "Paul" ) );
+            Person toni = peopleRepository.findPersonByName( "Toni" );
+            assertThat( toni.name().get(), equalTo( "Toni" ) );
+            Person janna = peopleRepository.findPersonByName( "Janna" );
+            assertThat( janna.name().get(), equalTo( "Janna" ) );
+            Person peter = peopleRepository.findPersonByName( "Peter" );
+            assertThat( peter.name().get(), equalTo( "Peter" ) );
+            Person oscar = peopleRepository.findPersonByName( "Oscar" );
+            assertThat( oscar.name().get(), equalTo( "Oscar" ) );
+            Person kalle = peopleRepository.findPersonByName( "Kalle" );
+            assertThat( kalle.name().get(), equalTo( "Kalle" ) );
+            Person andreas = peopleRepository.findPersonByName( "Andreas" );
+            assertThat( andreas.name().get(), equalTo( "Andreas" ) );
+        }
+    }
+
+    @Test
+    public void givenTestDataWhenAddingNewNamedAssociationExpectAssociationAdded()
+    {
+        try( UnitOfWork uow = uowf.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" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+            NamedAssociation<PhoneNumber> numbers = niclas.phoneNumbers();
+            assertThat( numbers.count(), equalTo( 2 ) );
+            PhoneNumber mobile = numbers.get( "Mobile" );
+            assertThat( mobile.countryCode().get(), equalTo( 86 ) );
+            assertThat( mobile.areaCode().get(), equalTo( 185 ) );
+            assertThat( mobile.number().get(), equalTo( "21320803" ) );
+            PhoneNumber home = numbers.get( "Home" );
+            assertThat( home.countryCode().get(), equalTo( 60 ) );
+            assertThat( home.areaCode().get(), equalTo( 16 ) );
+            assertThat( home.number().get(), equalTo( "7636344" ) );
+        }
+    }
+
+    @Test
+    public void whenIteratingNamedAssociationExpectIterationInOrder()
+    {
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+            PhoneNumber newNumber1 = peopleRepository.createPhoneNumber( "+86-185-21320803" );
+            niclas.phoneNumbers().put( "Chinese", newNumber1 );
+            PhoneNumber newNumber2 = peopleRepository.createPhoneNumber( "+46-70-9876543" );
+            niclas.phoneNumbers().put( "Swedish", newNumber2 );
+            PhoneNumber newNumber3 = peopleRepository.createPhoneNumber( "+49-444-2832989823" );
+            niclas.phoneNumbers().put( "German", newNumber3 );
+            uow.complete();
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+            Iterator<String> numbers = niclas.phoneNumbers().iterator();
+            assertThat( numbers.hasNext(), is( true ) );
+            assertThat( numbers.next(), equalTo( "Home" ) );
+            assertThat( numbers.hasNext(), is( true ) );
+            assertThat( numbers.next(), equalTo( "Chinese" ) );
+            assertThat( numbers.hasNext(), is( true ) );
+            assertThat( numbers.next(), equalTo( "Swedish" ) );
+            assertThat( numbers.hasNext(), is( true ) );
+            assertThat( numbers.next(), equalTo( "German" ) );
+        }
+    }
+
+    @Test
+    public void givenTestDataWhenAddingSameNamedAssociationExpectAssociationModified()
+    {
+        try( UnitOfWork uow = uowf.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" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+            NamedAssociation<PhoneNumber> numbers = niclas.phoneNumbers();
+            assertThat( numbers.count(), equalTo( 1 ) );
+            PhoneNumber home = numbers.get( "Home" );
+            assertThat( home.countryCode().get(), equalTo( 86 ) );
+            assertThat( home.areaCode().get(), equalTo( 185 ) );
+            assertThat( home.number().get(), equalTo( "21320803" ) );
+        }
+    }
+
+    @Test
+    public void whenNullingOptionalAssociationExpectSuccess()
+    {
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenNullingOptionalAssociationExpectSuccess" ) ) )
+        {
+            Person toni = peopleRepository.findPersonByName( "Toni" );
+            toni.spouse().set( null );
+            uow.complete();
+        }
+    }
+
+    @Test( expected = ConstraintViolationException.class )
+    public void whenNullingNonOptionalAssociationExpectFailure()
+    {
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenNullingOptionalAssociationExpectSuccess" ) ) )
+        {
+            Person toni = peopleRepository.findPersonByName( "Toni" );
+            toni.nationality().set( null );
+            uow.complete();
+        }
+    }
+
+    @Test
+    public void whenRemovingEntityExpectAggregatedEntitiesToBeRemoved()
+    {
+        Identity homePhoneId;
+        Identity chinesePhoneId;
+        Identity germanPhoneId;
+        Identity swedishPhoneId;
+        Identity switzerlandId;
+        Identity malaysiaId;
+        Identity canaryId;
+        Identity despairStId;
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+            PhoneNumber newNumber1 = peopleRepository.createPhoneNumber( "+86-185-21320803" );
+            niclas.phoneNumbers().put( "Chinese", newNumber1 );
+            PhoneNumber newNumber2 = peopleRepository.createPhoneNumber( "+46-70-9876543" );
+            niclas.phoneNumbers().put( "Swedish", newNumber2 );
+            PhoneNumber newNumber3 = peopleRepository.createPhoneNumber( "+49-444-2832989823" );
+            niclas.phoneNumbers().put( "German", newNumber3 );
+            homePhoneId = niclas.phoneNumbers().get( "Home" ).identity().get();
+            swedishPhoneId = niclas.phoneNumbers().get( "Swedish" ).identity().get();
+            chinesePhoneId = niclas.phoneNumbers().get( "Chinese" ).identity().get();
+            germanPhoneId = niclas.phoneNumbers().get( "German" ).identity().get();
+
+            City basel = peopleRepository.findCity( baselId );
+            Country switzerland = peopleRepository.findCountryByCountryCode( "ch" );
+            niclas.movedToNewAddress( "DespairStreet 12A", "43HQ21", basel, switzerland, obf.newObject( Rent.Builder.class ).create( 1000, "EUR" ) );
+            uow.complete();
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+            assertThat( niclas.nationality().get().name().get(), equalTo( "Sweden" ) );
+            assertThat( niclas.oldAddresses().count(), equalTo( 1 ) );
+            assertThat( niclas.address().get().country().get().name().get(), equalTo( "Switzerland" ) );
+            canaryId = niclas.oldAddresses().get( 0 ).identity().get();
+            despairStId = niclas.address().get().identity().get();
+            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" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+            uow.remove( niclas );
+            uow.complete();
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            Person niclas = peopleRepository.findPersonByName( "Niclas" );
+        }
+        catch( NoSuchEntityException e )
+        {
+            // expected
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            peopleRepository.findPhoneNumberById( homePhoneId );
+        }
+        catch( NoSuchEntityException e )
+        {
+            // expected
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            peopleRepository.findPhoneNumberById( chinesePhoneId );
+        }
+        catch( NoSuchEntityException e )
+        {
+            // expected
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            peopleRepository.findPhoneNumberById( swedishPhoneId );
+        }
+        catch( NoSuchEntityException e )
+        {
+            // expected
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            peopleRepository.findPhoneNumberById( germanPhoneId );
+        }
+        catch( NoSuchEntityException e )
+        {
+            // expected
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            peopleRepository.findAddress( canaryId );
+        }
+        catch( NoSuchEntityException e )
+        {
+            // expected
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            peopleRepository.findAddress( despairStId );
+        }
+        catch( NoSuchEntityException e )
+        {
+            // expected
+        }
+        try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenRemovingEntityExpectAggregatedEntitiesToBeRemoved" ) ) )
+        {
+            peopleRepository.findCountryByIdentity( switzerlandId );
+            peopleRepository.findCountryByIdentity( malaysiaId );
+
+            peopleRepository.findPersonByName( "Peter" );
+            peopleRepository.findPersonByName( "Andreas" );
+            peopleRepository.findPersonByName( "Toni" );
+            peopleRepository.findPersonByName( "Paul" );
+        }
+    }
+
+    @Test( expected = IllegalStateException.class )
+    public void whenNoActiveUnitOfWorkExpectIllegalStateException()
+    {
+        peopleRepository.findCountryByIdentity( switzerlandId );
+    }
+
+    private void testData()
+    {
+        Country malaysia = peopleRepository.createCountry( "my", "Malaysia" );
+        malaysiaId = malaysia.identity().get();
+        Country us = peopleRepository.createCountry( "us", "United States" );
+        usId = us.identity().get();
+        Country sweden = peopleRepository.createCountry( "se", "Sweden" );
+        swedenId = sweden.identity().get();
+        Country germany = peopleRepository.createCountry( "de", "Germany" );
+        germanyId = germany.identity().get();
+        Country denmark = peopleRepository.createCountry( "dk", "Denmark" );
+        denmarkId = denmark.identity().get();
+        Country france = peopleRepository.createCountry( "fr", "France" );
+        franceId = france.identity().get();
+        Country switzerland = peopleRepository.createCountry( "ch", "Switzerland" );
+        switzerlandId = switzerland.identity().get();
+        City cheras = peopleRepository.createCity( "Cheras" );
+        cherasId = cheras.identity().get();
+        City malmo = peopleRepository.createCity( "Malmo" );
+        malmoId = malmo.identity().get();
+        City hannover = peopleRepository.createCity( "Hannover" );
+        hannoverId = hannover.identity().get();
+        City montpellier = peopleRepository.createCity( "Montpellier" );
+        montpellierId = montpellier.identity().get();
+        City basel = peopleRepository.createCity( "Basel" );
+        baselId = basel.identity().get();
+        Rent.Builder rentBuilder = obf.newObject( Rent.Builder.class );
+        Rent rentCanary = rentBuilder.create( 3000, "MYR" );
+        Rent rentVarnhem = rentBuilder.create( 9000, "SEK" );
+        Rent rentUnknown1 = rentBuilder.create( 1200, "EUR" );
+        Rent rentUnknown2 = rentBuilder.create( 900, "EUR" );
+        Rent rentUnknown3 = rentBuilder.create( 2200, "EUR" );
+        Address canaryResidence = peopleRepository.createAddress( "10, CH5A, Jalan Cheras Hartamas", "43200", cheras, malaysia, rentCanary );
+        canaryId = canaryResidence.identity().get();
+        Address varnhem = peopleRepository.createAddress( "Varnhemsgatan 25", "215 00", malmo, sweden, rentVarnhem );
+        varnhemId = varnhem.identity().get();
+        Address unknown1 = peopleRepository.createAddress( "", "", montpellier, france, rentUnknown1 );
+        unknown1Id = unknown1.identity().get();
+        Address unknown2 = peopleRepository.createAddress( "", "", hannover, germany, rentUnknown2 );
+        unknown2Id = unknown2.identity().get();
+        Address unknown3 = peopleRepository.createAddress( "", "", basel, switzerland, rentUnknown3 );
+        unknown3Id = unknown3.identity().get();
+        Person eric = peopleRepository.createPerson( "Eric", malaysia, canaryResidence, null, null );
+        Person niclas = peopleRepository.createPerson( "Niclas", sweden, canaryResidence, null, peopleRepository.createPhoneNumber( "+60-16-7636344" ) );
+        niclas.children().add( eric );
+        Person kalle = peopleRepository.createPerson( "Kalle", sweden, varnhem, null, null );
+        Person oscar = peopleRepository.createPerson( "Oscar", sweden, varnhem, null, null );
+        Person peter = peopleRepository.createPerson( "Peter", germany, varnhem, null, peopleRepository.createPhoneNumber( "+46-70-1234567" ) );
+        peter.children().add( kalle );
+        peter.children().add( oscar );
+        Person paul = peopleRepository.createPerson( "Paul", france, unknown1, null, peopleRepository.createPhoneNumber( "+33-88-333666999" ) );
+        Person janna = peopleRepository.createPerson( "Janna", france, unknown2, null, peopleRepository.createPhoneNumber( "+49-11-22334455" ) );
+        Person toni = peopleRepository.createPerson( "Toni", france, unknown2, janna, peopleRepository.createPhoneNumber( "+49-12-99887766" ) );
+        janna.spouse().set( toni );
+        Person andreas = peopleRepository.createPerson( "Andreas", germany, unknown3, null, peopleRepository.createPhoneNumber( "+41-98-1234567" ) );
+        NamedAssociation<Person> niclasRels = niclas.relationships();
+        niclasRels.put( FRIEND, peter );
+        niclasRels.put( FRIEND, toni );
+        niclasRels.put( FRIEND, andreas );
+        niclasRels.put( FRIEND, paul );
+        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" ) );
+        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, City.class, PhoneNumber.class );
+        module.entities( Country.class, Person.class );
+        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, WillItem.class, WillPercentage.class, WillAmount.class );
+    }
+
+    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 );
+    }
+}