Add some coverage for clearing associations
Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/ea8b7092 Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/ea8b7092 Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/ea8b7092 Branch: refs/heads/develop Commit: ea8b7092f7b4ac60d77f64197c0dcdd9fcb66bcc Parents: 7c6bc1b Author: Paul Merlin <[email protected]> Authored: Sun May 21 17:40:46 2017 +0200 Committer: Paul Merlin <[email protected]> Committed: Sun May 21 17:40:46 2017 +0200 ---------------------------------------------------------------------- .../runtime/entity/associations/AssociationTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ea8b7092/core/runtime/src/test/java/org/apache/polygene/runtime/entity/associations/AssociationTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/associations/AssociationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/associations/AssociationTest.java index f049c40..1e953ae 100644 --- a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/associations/AssociationTest.java +++ b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/associations/AssociationTest.java @@ -36,6 +36,10 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.test.EntityTestAssembler; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + /** * Tests for associations */ @@ -98,6 +102,12 @@ public class AssociationTest Assert.assertEquals( niclas.friend().get(), rickard ); Assert.assertEquals( niclas.members().get( 0 ), rickard ); + + // Empty associations + niclas.friend().set( null ); + niclas.members().clear(); + assertThat( niclas.friend().get(), nullValue() ); + assertThat( niclas.employers().count(), is( 0 ) ); } finally {
