From 0f93915297f3f36ec4d5d759e4afa6424ad03543 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 31 Dec 2017 19:09:33 +0000 Subject: [PATCH 1/6] Reduce npath complexity of Mon.equals --- src/main/java/net/kemitix/mon/Mon.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/kemitix/mon/Mon.java b/src/main/java/net/kemitix/mon/Mon.java index b591044..11bf8e6 100644 --- a/src/main/java/net/kemitix/mon/Mon.java +++ b/src/main/java/net/kemitix/mon/Mon.java @@ -118,17 +118,8 @@ public class Mon implements Functor> { * @return true if they are the same */ @Override - @SuppressWarnings("npathcomplexity") public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - final Mon mon = (Mon) o; - - return value.equals(mon.value); + return this == o || o != null && getClass() == o.getClass() && value.equals(((Mon) o).value); } + } From 80023809a4597185eed6970058aae1076b4115ff Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 31 Dec 2017 19:21:58 +0000 Subject: [PATCH 2/6] Add test for normal Mon.factory() behaviour --- src/test/java/net/kemitix/mon/MonTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/net/kemitix/mon/MonTest.java b/src/test/java/net/kemitix/mon/MonTest.java index 3d8a660..7e5f8e2 100644 --- a/src/test/java/net/kemitix/mon/MonTest.java +++ b/src/test/java/net/kemitix/mon/MonTest.java @@ -113,6 +113,20 @@ public class MonTest { .withMessage("onInvalid"); } + @Test + public void factory() { + //given + final Function> evenMonFactory = + Mon.factory((Integer v) -> v % 2 == 0, Optional::of, Optional::empty); + //when + final Optional oddResult = evenMonFactory.apply(1); + final Optional evenResult = evenMonFactory.apply(2); + //then + assertThat(oddResult).isEmpty();// because 1 % 2 != 0 + assertThat(evenResult).isNotEmpty(); // because 2 % 2 == 0 + evenResult.ifPresent(value -> assertThat(value).isEqualTo(Mon.of(2))); + } + @Test public void shouldGetInvalidResultWhenFactoryApplyWithNull() { //given From 0424e939977567ac844765de730121b7a2a75cfb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 31 Dec 2017 19:22:28 +0000 Subject: [PATCH 3/6] Suppress warnings --- src/test/java/net/kemitix/mon/MonTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/net/kemitix/mon/MonTest.java b/src/test/java/net/kemitix/mon/MonTest.java index 7e5f8e2..abe6a55 100644 --- a/src/test/java/net/kemitix/mon/MonTest.java +++ b/src/test/java/net/kemitix/mon/MonTest.java @@ -93,6 +93,7 @@ public class MonTest { } @Test + @SuppressWarnings("ResultOfMethodCallIgnored") public void factoryRequiresValidator() { assertThatNullPointerException().isThrownBy( () -> Mon.factory(null, Optional::of, Optional::empty)) @@ -100,6 +101,7 @@ public class MonTest { } @Test + @SuppressWarnings("ResultOfMethodCallIgnored") public void factoryRequiresOnValid() { assertThatNullPointerException().isThrownBy( () -> Mon.factory(v -> true, null, Optional::empty)) @@ -107,6 +109,7 @@ public class MonTest { } @Test + @SuppressWarnings("ResultOfMethodCallIgnored") public void factoryRequiresOnInvalid() { assertThatNullPointerException().isThrownBy( () -> Mon.factory(v -> true, Optional::of, null)) From c545eed3f3f982580d092cc4bd1f33fbcacfbd40 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 20 Jan 2018 12:29:02 +0000 Subject: [PATCH 4/6] Use new assertj 3.9.0 method --- src/test/java/net/kemitix/mon/TypeAliasTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/kemitix/mon/TypeAliasTest.java b/src/test/java/net/kemitix/mon/TypeAliasTest.java index 08a5448..10497bf 100644 --- a/src/test/java/net/kemitix/mon/TypeAliasTest.java +++ b/src/test/java/net/kemitix/mon/TypeAliasTest.java @@ -92,7 +92,7 @@ public class TypeAliasTest { final String value = "value"; final AnAlias anAlias = AnAlias.of(value); //then - assertThat(anAlias.hashCode()).isEqualTo(value.hashCode()); + assertThat(anAlias).hasSameHashCodeAs(value); } @Test From f6ac679eca489f21729f048383848bd7ca28c74b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 20 Jan 2018 12:29:52 +0000 Subject: [PATCH 5/6] Set groupid explicitly --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 383e4de..e1b3a89 100644 --- a/pom.xml +++ b/pom.xml @@ -10,6 +10,7 @@ 5.1.0 + net.kemitix mon 0.5.0-SNAPSHOT From 94247a377e49386135e8331032325212f6b2dbc8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 2 Mar 2018 23:33:18 +0000 Subject: [PATCH 6/6] jenkins: enable test in java 9 --- Jenkinsfile.groovy | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 3f87b24..7bb06b5 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -19,13 +19,13 @@ pipeline { } } // requires maven-failsafe-plugin:2.21 when it is released -// stage('Java 9') { -// steps { -// withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { -// sh 'mvn clean install' -// } -// } -// } + stage('Java 9') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + sh 'mvn clean install' + } + } + } } } stage('Reporting') {