polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [23/33] polygene-java git commit: Add coverage for clearing associations in EntityStore TCK
Date Tue, 23 May 2017 02:14:06 GMT
Add coverage for clearing associations in EntityStore TCK


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

Branch: refs/heads/yeoman-work
Commit: 00ded0ded94be20e22439be5c5a34ef324813985
Parents: ea8b709
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sun May 21 18:16:04 2017 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sun May 21 18:16:04 2017 +0200

----------------------------------------------------------------------
 .../cache/AbstractEntityStoreWithCacheTest.java |  6 +++---
 .../test/entity/AbstractEntityStoreTest.java    | 22 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/00ded0de/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractEntityStoreWithCacheTest.java
b/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractEntityStoreWithCacheTest.java
index a2f6d29..0abddb6 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractEntityStoreWithCacheTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractEntityStoreWithCacheTest.java
@@ -122,13 +122,13 @@ public abstract class AbstractEntityStoreWithCacheTest
     public void givenManyAssociationIsModifiedWhenUnitOfWorkCompletesThenStoreState()
         throws UnitOfWorkCompletionException
     {
-        super.givenManyAssociationIsModifiedWhenUnitOfWorkCompletesThenStoreState();
+        super.givenAssociationsModifiedWhenUnitOfWorkCompletesThenStoreState();
         if( cachePool != null )
         {
             MemoryCacheImpl<?> cache = cachePool.singleCache();
             assertThat( cache.size(), is( 1 ) );
-            assertThat( cache.gets(), is( 2 ) );
-            assertThat( cache.puts(), is( 2 ) );
+            assertThat( cache.gets(), is( 3 ) );
+            assertThat( cache.puts(), is( 3 ) );
             assertThat( cache.removes(), is( 0 ) );
             assertThat( cache.exists(), is( 0 ) );
         }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/00ded0de/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
b/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
index 2fec7df..a8bb82b 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
@@ -62,6 +62,7 @@ import static java.time.ZoneOffset.UTC;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
@@ -387,7 +388,7 @@ public abstract class AbstractEntityStoreTest
     }
 
     @Test
-    public void givenManyAssociationIsModifiedWhenUnitOfWorkCompletesThenStoreState()
+    public void givenAssociationsModifiedWhenUnitOfWorkCompletesThenStoreState()
         throws UnitOfWorkCompletionException
     {
         TestEntity testEntity;
@@ -402,7 +403,9 @@ public abstract class AbstractEntityStoreTest
         {
             UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
             testEntity = unitOfWork.get( testEntity );
+            testEntity.association().set( testEntity );
             testEntity.manyAssociation().add( 0, testEntity );
+            testEntity.namedAssociation().put( "test", testEntity );
             version = spi.entityStateOf( testEntity ).version();
 
             unitOfWork.complete();
@@ -411,6 +414,23 @@ public abstract class AbstractEntityStoreTest
             UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
             testEntity = unitOfWork.get( testEntity );
             String newVersion = spi.entityStateOf( testEntity ).version();
+            assertThat( "association persisted", testEntity.association().get(), equalTo(
testEntity ) );
+            assertThat( "many association persisted", testEntity.manyAssociation().get( 0
), equalTo( testEntity ) );
+            assertThat( "named association persisted", testEntity.namedAssociation().get(
"test" ), equalTo( testEntity ) );
+            assertThat( "version has not changed", newVersion, not( equalTo( version ) )
);
+
+            testEntity.association().set( null );
+            testEntity.manyAssociation().clear();
+            testEntity.namedAssociation().clear();
+            unitOfWork.complete();
+        }
+        {
+            UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
+            testEntity = unitOfWork.get( testEntity );
+            String newVersion = spi.entityStateOf( testEntity ).version();
+            assertThat( "association cleared", testEntity.association().get(), nullValue()
);
+            assertThat( "many association cleared", testEntity.manyAssociation().count(),
is( 0 ) );
+            assertThat( "named association cleared", testEntity.namedAssociation().count(),
is( 0 ) );
             assertThat( "version has not changed", newVersion, not( equalTo( version ) )
);
 
             unitOfWork.complete();


Mime
View raw message