Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 81BBD200B2D for ; Thu, 16 Jun 2016 12:05:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 806CD160A52; Thu, 16 Jun 2016 10:05:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C8DA7160A51 for ; Thu, 16 Jun 2016 12:05:36 +0200 (CEST) Received: (qmail 16232 invoked by uid 500); 16 Jun 2016 10:05:36 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 16222 invoked by uid 99); 16 Jun 2016 10:05:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jun 2016 10:05:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C9839DFDEF; Thu, 16 Jun 2016 10:05:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: niclas@apache.org To: commits@zest.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: zest-java git commit: Since the Jenkins build is broken anyway, I am committing this testcase, which exposes a Value Equality issue. The two values should be equal, but are not. Date: Thu, 16 Jun 2016 10:05:35 +0000 (UTC) archived-at: Thu, 16 Jun 2016 10:05:37 -0000 Repository: zest-java Updated Branches: refs/heads/develop 65c7df371 -> c62ee068d Since the Jenkins build is broken anyway, I am committing this testcase, which exposes a Value Equality issue. The two values should be equal, but are not. Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/c62ee068 Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/c62ee068 Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/c62ee068 Branch: refs/heads/develop Commit: c62ee068d5d82608bb3ab556899220c5ef2d389a Parents: 65c7df3 Author: Niclas Hedhman Authored: Thu Jun 16 18:05:30 2016 +0800 Committer: Niclas Hedhman Committed: Thu Jun 16 18:05:30 2016 +0800 ---------------------------------------------------------------------- .../zest/runtime/value/ValueEqualityTest.java | 43 +++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/c62ee068/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java index 91c5868..c88f4ae 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java @@ -19,6 +19,15 @@ */ package org.apache.zest.runtime.value; +import java.time.Duration; +import java.time.Period; +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.Map; +import org.apache.zest.api.common.UseDefaults; +import org.apache.zest.api.property.Property; +import org.apache.zest.api.value.ValueBuilder; +import org.apache.zest.test.value.AbstractValueCompositeSerializationTest; import org.junit.Test; import org.apache.zest.api.association.AssociationStateHolder; import org.apache.zest.api.value.ValueComposite; @@ -55,7 +64,7 @@ public class ValueEqualityTest public void assemble( ModuleAssembly module ) throws AssemblyException { - module.values( PrimitivesValue.class, Some.class, AnotherSome.class, Other.class ); + module.values( PrimitivesValue.class, Some.class, AnotherSome.class, Other.class, ComplexKey.class ); } // @@ -238,4 +247,36 @@ public class ValueEqualityTest some.hashCode(), not( equalTo( anotherSome.hashCode() ) ) ); } + + @Test + public void givenComplexKeyWhenEqualityCheckExpectEqual() + throws Exception + { + Map> map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + map4.put( Duration.of( 1000, ChronoUnit.MILLIS ), Period.of( 1, 2, 3 ) ); + map3.put( "habba", map4 ); + ValueBuilder builder1 = valueBuilderFactory.newValueBuilder( ComplexKey.class ); + builder1.prototype().durations().set( map3 ); + ComplexKey key1 = builder1.newInstance(); + + Map> map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + map2.put( Duration.of( 1000, ChronoUnit.MILLIS ), Period.of( 1, 2, 3 ) ); + map1.put( "habba", map2 ); + ValueBuilder builder2 = valueBuilderFactory.newValueBuilder( ComplexKey.class ); + builder2.prototype().durations().set( map1 ); + ComplexKey key2 = builder2.newInstance(); + + assertThat( key1, equalTo( key2 ) ); + } + + public interface ComplexKey + { + @UseDefaults + Property>> durations(); + } + + + }