From 73e59b0050fca191a7485557abca19eeac7ba1c0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 12 Oct 2018 20:42:11 +0100 Subject: [PATCH] Bump junit from 4.12 to 5.3.1 (#56) * Bump junit from 4.12 to 5.3.1 * [changelog] update * [jenkins] stop publishing to codacy and test build with java 11 --- CHANGELOG | 3 +- Jenkinsfile.groovy | 22 +-- pom.xml | 47 +++++- .../java/net/kemitix/mon/BeanBuilderTest.java | 6 +- src/test/java/net/kemitix/mon/EitherTest.java | 24 ++-- .../java/net/kemitix/mon/MaybeMonadTest.java | 10 +- src/test/java/net/kemitix/mon/MaybeTest.java | 70 ++++----- src/test/java/net/kemitix/mon/MonTest.java | 32 ++--- .../net/kemitix/mon/OptionalMonadTest.java | 10 +- .../java/net/kemitix/mon/ResultMonadTest.java | 10 +- src/test/java/net/kemitix/mon/ResultTest.java | 136 +++++++++--------- .../net/kemitix/mon/TypeAliasMonadTest.java | 10 +- .../java/net/kemitix/mon/TypeAliasTest.java | 24 ++-- .../net/kemitix/mon/combinator/AfterTest.java | 6 +- .../kemitix/mon/combinator/AroundTest.java | 6 +- .../kemitix/mon/combinator/BeforeTest.java | 6 +- .../kemitix/mon/lazy/LazySupplierTest.java | 31 ++-- .../kemitix/mon/tree/GeneralisedTreeTest.java | 16 +-- 18 files changed, 246 insertions(+), 223 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a9f4dbc..e7a4579 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,8 @@ CHANGELOG 1.2.1 ----- -* Bump kemitix-parent from 5.1.1 to 5.2.0 +* Bump kemitix-parent from 5.1.1 to 5.2.0 (#55) +* Bump junit from 4.12 to 5.3.1 [#56) 1.2.0 ----- diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 7f0eaa4..0f91efd 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,6 +1,5 @@ final String publicRepo = 'https://github.com/kemitix/' final String mvn = "mvn --batch-mode --update-snapshots --errors" -final dependenciesSupportJDK = 10 pipeline { agent any @@ -9,12 +8,6 @@ pipeline { steps { withMaven(maven: 'maven', jdk: 'JDK 1.8') { sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test" - // Code Coverage to Codacy - sh "${mvn} jacoco:report com.gavinmogan:codacy-maven-plugin:coverage " + - "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + - "-DprojectToken=`$JENKINS_HOME/codacy/token` " + - "-DapiToken=`$JENKINS_HOME/codacy/apitoken` " + - "-Dcommit=`git rev-parse HEAD`" // Code Coverage to Jenkins jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' // PMD to Jenkins @@ -58,19 +51,10 @@ pipeline { } } } - stage('Build Java 9') { - when { expression { dependenciesSupportJDK >= 9 } } + stage('Build Java 11') { steps { - withMaven(maven: 'maven', jdk: 'JDK 9') { - sh "${mvn} clean verify -Djava.version=9" - } - } - } - stage('Build Java 10') { - when { expression { dependenciesSupportJDK >= 10 } } - steps { - withMaven(maven: 'maven', jdk: 'JDK 10') { - sh "${mvn} clean verify -Djava.version=10" + withMaven(maven: 'maven', jdk: 'JDK 11') { + sh "${mvn} clean verify -Djava.version=11" } } } diff --git a/pom.xml b/pom.xml index 8b5b9e0..99e6f4b 100644 --- a/pom.xml +++ b/pom.xml @@ -33,13 +33,16 @@ 1.8 - 4.12 + 5.3.1 + 2.23.0 3.11.1 1.18.2 2.12 1.2.0 net.kemitix.mon 5.0.0 + 1.4.3 + 0.7 @@ -49,10 +52,21 @@ ${lombok.version} provided + - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + runtime + + + org.mockito + mockito-junit-jupiter + ${mockito.version} test @@ -63,6 +77,18 @@ + + + + org.junit + junit-bom + ${junit.version} + pom + import + + + + @@ -77,6 +103,19 @@ + + + org.pitest + pitest-maven + ${pitest-maven-plugin.version} + + + org.pitest + pitest-junit5-plugin + ${pitest-junit5-plugin.version} + + + diff --git a/src/test/java/net/kemitix/mon/BeanBuilderTest.java b/src/test/java/net/kemitix/mon/BeanBuilderTest.java index d36c69e..58b326a 100644 --- a/src/test/java/net/kemitix/mon/BeanBuilderTest.java +++ b/src/test/java/net/kemitix/mon/BeanBuilderTest.java @@ -5,15 +5,15 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import net.kemitix.mon.experimental.BeanBuilder; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.function.Consumer; import java.util.function.Supplier; -public class BeanBuilderTest implements WithAssertions { +class BeanBuilderTest implements WithAssertions { @Test - public void canCreateAndSetupObject() { + void canCreateAndSetupObject() { //given final Supplier template = () -> new DataObject("name"); final Consumer value = data -> data.setValue("value"); diff --git a/src/test/java/net/kemitix/mon/EitherTest.java b/src/test/java/net/kemitix/mon/EitherTest.java index 7508b39..7fd835f 100644 --- a/src/test/java/net/kemitix/mon/EitherTest.java +++ b/src/test/java/net/kemitix/mon/EitherTest.java @@ -2,12 +2,12 @@ package net.kemitix.mon; import net.kemitix.mon.experimental.either.Either; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class EitherTest implements WithAssertions { +class EitherTest implements WithAssertions { @Test - public void whenLeft_isLeft() { + void whenLeft_isLeft() { //when final Either either = Either.left(1); //then @@ -15,7 +15,7 @@ public class EitherTest implements WithAssertions { } @Test - public void whenLeft_isNotRight() { + void whenLeft_isNotRight() { //when final Either either = Either.left(1); //then @@ -23,7 +23,7 @@ public class EitherTest implements WithAssertions { } @Test - public void whenRight_isNotLeft() { + void whenRight_isNotLeft() { //when final Either either = Either.right("1"); //then @@ -31,7 +31,7 @@ public class EitherTest implements WithAssertions { } @Test - public void whenRight_isRight() { + void whenRight_isRight() { //when final Either either = Either.right("1"); //then @@ -39,7 +39,7 @@ public class EitherTest implements WithAssertions { } @Test - public void whenLeft_matchLeft() { + void whenLeft_matchLeft() { //given final Either either = Either.left(1); //then @@ -50,7 +50,7 @@ public class EitherTest implements WithAssertions { } @Test - public void whenRight_matchRight() { + void whenRight_matchRight() { //given final Either either = Either.right("1"); //then @@ -61,7 +61,7 @@ public class EitherTest implements WithAssertions { } @Test - public void givenLeft_whenMapLeft_thenMap() { + void givenLeft_whenMapLeft_thenMap() { //given final Either either = Either.left(2); //when @@ -74,7 +74,7 @@ public class EitherTest implements WithAssertions { } @Test - public void givenRight_whenMapRight_thenMap() { + void givenRight_whenMapRight_thenMap() { //given final Either either = Either.right("2"); //when @@ -87,7 +87,7 @@ public class EitherTest implements WithAssertions { } @Test - public void givenLeft_whenMapRight_thenDoNothing() { + void givenLeft_whenMapRight_thenDoNothing() { //given final Either either = Either.left(2); //when @@ -100,7 +100,7 @@ public class EitherTest implements WithAssertions { } @Test - public void givenRight_whenMapLeft_thenDoNothing() { + void givenRight_whenMapLeft_thenDoNothing() { //given final Either either = Either.right("2"); //when diff --git a/src/test/java/net/kemitix/mon/MaybeMonadTest.java b/src/test/java/net/kemitix/mon/MaybeMonadTest.java index bbb6618..4611aa3 100644 --- a/src/test/java/net/kemitix/mon/MaybeMonadTest.java +++ b/src/test/java/net/kemitix/mon/MaybeMonadTest.java @@ -2,11 +2,11 @@ package net.kemitix.mon; import net.kemitix.mon.maybe.Maybe; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.function.Function; -public class MaybeMonadTest implements WithAssertions { +class MaybeMonadTest implements WithAssertions { private final int v = 1; private final Function> f = i -> m(i * 2); @@ -17,7 +17,7 @@ public class MaybeMonadTest implements WithAssertions { } @Test - public void leftIdentity() { + void leftIdentity() { assertThat( m(v).flatMap(f) ).isEqualTo( @@ -26,7 +26,7 @@ public class MaybeMonadTest implements WithAssertions { } @Test - public void rightIdentity() { + void rightIdentity() { assertThat( m(v).flatMap(x -> m(x)) ).isEqualTo( @@ -35,7 +35,7 @@ public class MaybeMonadTest implements WithAssertions { } @Test - public void associativity() { + void associativity() { assertThat( m(v).flatMap(f).flatMap(g) ).isEqualTo( diff --git a/src/test/java/net/kemitix/mon/MaybeTest.java b/src/test/java/net/kemitix/mon/MaybeTest.java index af35dca..efc3fa9 100644 --- a/src/test/java/net/kemitix/mon/MaybeTest.java +++ b/src/test/java/net/kemitix/mon/MaybeTest.java @@ -2,7 +2,7 @@ package net.kemitix.mon; import net.kemitix.mon.maybe.Maybe; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Objects; import java.util.Optional; @@ -13,25 +13,25 @@ import java.util.stream.Stream; import static net.kemitix.mon.maybe.Maybe.*; -public class MaybeTest implements WithAssertions { +class MaybeTest implements WithAssertions { private static Predicate eq(final T value) { return v -> Objects.equals(value, v); } @Test - public void justMustBeNonNull() { + void justMustBeNonNull() { assertThatNullPointerException().isThrownBy(() -> just(null)) .withMessageContaining("value"); } @Test - public void nothingReusesTheSameInstance() { + void nothingReusesTheSameInstance() { assertThat(nothing()).isSameAs(nothing()); } @Test - public void equality() { + void equality() { assertThat(just(1)).isEqualTo(just(1)); assertThat(just(1)).isNotEqualTo(just(2)); assertThat(just(1)).isNotEqualTo(nothing()); @@ -40,19 +40,19 @@ public class MaybeTest implements WithAssertions { } @Test - public void maybeAllowsNull() { + void maybeAllowsNull() { assertThat(just(1)).isEqualTo(maybe(1)); assertThat(nothing()).isEqualTo(maybe(null)); } @Test - public void map() { + void map() { assertThat(just(1).map(v -> v + 1)).isEqualTo(just(2)); assertThat(nothing().map(v -> v)).isEqualTo(nothing()); } @Test - public void mapToNull_thenJustNull() { + void mapToNull_thenJustNull() { //given final Maybe maybe = just(1); //when @@ -65,7 +65,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void optional_mapToNull_thenJustNull() { + void optional_mapToNull_thenJustNull() { //given final Optional optional = Optional.ofNullable(1); //when @@ -75,49 +75,49 @@ public class MaybeTest implements WithAssertions { } @Test - public void justHashCode() { + void justHashCode() { assertThat(just(1).hashCode()).isNotEqualTo(just(2).hashCode()); } @Test - public void nothingHashCode() { + void nothingHashCode() { assertThat(nothing().hashCode()).isEqualTo(maybe(null).hashCode()); } @Test - public void orElseGet() { + void orElseGet() { assertThat(just(1).orElseGet(() -> -1)).isEqualTo(1); assertThat(nothing().orElseGet(() -> -1)).isEqualTo(-1); } @Test - public void orElse() { + void orElse() { assertThat(just(1).orElse(-1)).isEqualTo(1); assertThat(nothing().orElse(-1)).isEqualTo(-1); } @Test - public void filter() { + void filter() { assertThat(just(1).filter(eq(1))).isEqualTo(just(1)); assertThat(just(1).filter(eq(0))).isEqualTo(nothing()); assertThat(nothing().filter(eq(1))).isEqualTo(nothing()); } @Test - public void toOptional() { + void toOptional() { assertThat(just(1).toOptional()).isEqualTo(Optional.of(1)); assertThat(nothing() .toOptional()).isEqualTo(Optional.empty()); } @Test - public void fromOptional() { + void fromOptional() { assertThat(Optional.of(1).map(Maybe::just).orElseGet(Maybe::nothing)).isEqualTo(just(1)); assertThat(Optional.empty().map(Maybe::just).orElseGet(Maybe::nothing)).isEqualTo(nothing()); } @Test - public void peek() { + void peek() { final AtomicInteger ref = new AtomicInteger(0); assertThat(just(1).peek(x -> ref.incrementAndGet())).isEqualTo(just(1)); assertThat(ref.get()).isEqualTo(1); @@ -127,12 +127,12 @@ public class MaybeTest implements WithAssertions { } @Test - public void justOrThrowDoesNotThrow() { + void justOrThrowDoesNotThrow() { assertThatCode(() -> just(1).orElseThrow(IllegalStateException::new)).doesNotThrowAnyException(); } @Test - public void justOrThrowReturnsValue() { + void justOrThrowReturnsValue() { //given final Maybe maybe = just(1); //when @@ -142,13 +142,13 @@ public class MaybeTest implements WithAssertions { } @Test - public void nothingOrThrow() { + void nothingOrThrow() { assertThatThrownBy(() -> nothing().orElseThrow(IllegalStateException::new)).isInstanceOf( IllegalStateException.class); } @Test - public void justToStream() { + void justToStream() { //when final Stream stream = just(1).stream(); //then @@ -156,7 +156,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void nothingToStream() { + void nothingToStream() { //when final Stream stream = nothing().stream(); //then @@ -164,7 +164,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void justFlatMap() { + void justFlatMap() { //given final Maybe just1 = just(1); final Maybe just2 = just(2); @@ -178,7 +178,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void nothingFlatMap() { + void nothingFlatMap() { //given final Maybe nothing1 = nothing(); final Maybe nothing2 = nothing(); @@ -192,7 +192,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void justNothingFlatMap() { + void justNothingFlatMap() { //given final Maybe just1 = just(1); final Maybe nothing2 = nothing(); @@ -206,7 +206,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void just_ifNothing_isIgnored() { + void just_ifNothing_isIgnored() { //given final Maybe just = just(1); final AtomicBoolean capture = new AtomicBoolean(false); @@ -217,7 +217,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void nothing_ifNothing_isCalled() { + void nothing_ifNothing_isCalled() { //given final Maybe nothing = nothing(); final AtomicBoolean capture = new AtomicBoolean(false); @@ -228,7 +228,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void just_whenMatch_thenJustTriggers() { + void just_whenMatch_thenJustTriggers() { //given final Maybe maybe = just(1); //then @@ -239,7 +239,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void nothing_whenMatch_thenNothingTriggers() { + void nothing_whenMatch_thenNothingTriggers() { //given final Maybe maybe = nothing(); final AtomicBoolean flag = new AtomicBoolean(false); @@ -253,7 +253,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void just_isJust_isTrue() { + void just_isJust_isTrue() { //given final Maybe maybe = just(1); //when @@ -263,7 +263,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void just_isNothing_isFalse() { + void just_isNothing_isFalse() { //given final Maybe maybe = just(1); //when @@ -273,7 +273,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void nothing_isJust_isFalse() { + void nothing_isJust_isFalse() { //given final Maybe maybe = nothing(); //when @@ -283,7 +283,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void nothing_isNothing_isTrue() { + void nothing_isNothing_isTrue() { //given final Maybe maybe = nothing(); //when @@ -293,7 +293,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void just_or_ignoreTheAlternative() { + void just_or_ignoreTheAlternative() { //given final Maybe one = Maybe.just("one"); //when @@ -303,7 +303,7 @@ public class MaybeTest implements WithAssertions { } @Test - public void nothing_or_isTheAlternative() { + void nothing_or_isTheAlternative() { //given final Maybe one = Maybe.nothing(); //when diff --git a/src/test/java/net/kemitix/mon/MonTest.java b/src/test/java/net/kemitix/mon/MonTest.java index e54f9f9..54efb5b 100644 --- a/src/test/java/net/kemitix/mon/MonTest.java +++ b/src/test/java/net/kemitix/mon/MonTest.java @@ -1,6 +1,6 @@ package net.kemitix.mon; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Optional; import java.util.function.Function; @@ -8,10 +8,10 @@ import java.util.function.Function; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNullPointerException; -public class MonTest { +class MonTest { @Test - public void canCreateAndMapCanGetValue() { + void canCreateAndMapCanGetValue() { //when final Mon wrap = Mon.of("test"); //then @@ -26,7 +26,7 @@ public class MonTest { } @Test - public void canMap() { + void canMap() { //given final Mon wrap = Mon.of("test"); //when @@ -36,7 +36,7 @@ public class MonTest { } @Test - public void canMapInstance() { + void canMapInstance() { //given final Mon wrap = Mon.of("test"); //when @@ -46,7 +46,7 @@ public class MonTest { } @Test - public void createWithValidatorAndContinuations() { + void createWithValidatorAndContinuations() { //given final Function>> factory = Mon.factory( @@ -65,7 +65,7 @@ public class MonTest { @Test - public void canCompare() { + void canCompare() { //given final Mon one = Mon.of("test"); final Mon same = Mon.of("test"); @@ -76,7 +76,7 @@ public class MonTest { } @Test - public void canFlatMap() { + void canFlatMap() { //given final Mon wrap = Mon.of("test"); //when @@ -88,13 +88,13 @@ public class MonTest { } @Test - public void ofRequiresNonNull() { + void ofRequiresNonNull() { assertThatNullPointerException().isThrownBy(() -> Mon.of(null)); } @Test @SuppressWarnings("ResultOfMethodCallIgnored") - public void factoryRequiresValidator() { + void factoryRequiresValidator() { assertThatNullPointerException().isThrownBy( () -> Mon.factory(null, Optional::of, Optional::empty)) .withMessageContaining("validator"); @@ -102,7 +102,7 @@ public class MonTest { @Test @SuppressWarnings("ResultOfMethodCallIgnored") - public void factoryRequiresOnValid() { + void factoryRequiresOnValid() { assertThatNullPointerException().isThrownBy( () -> Mon.factory(v -> true, null, Optional::empty)) .withMessageContaining("onValid"); @@ -110,14 +110,14 @@ public class MonTest { @Test @SuppressWarnings("ResultOfMethodCallIgnored") - public void factoryRequiresOnInvalid() { + void factoryRequiresOnInvalid() { assertThatNullPointerException().isThrownBy( () -> Mon.factory(v -> true, Optional::of, null)) .withMessageContaining("onInvalid"); } @Test - public void factory() { + void factory() { //given final Function> evenMonFactory = Mon.factory((Integer v) -> v % 2 == 0, Optional::of, Optional::empty); @@ -131,7 +131,7 @@ public class MonTest { } @Test - public void shouldGetInvalidResultWhenFactoryApplyWithNull() { + void shouldGetInvalidResultWhenFactoryApplyWithNull() { //given final Function> factory = Mon.factory(v -> true, Optional::of, Optional::empty); //when @@ -141,7 +141,7 @@ public class MonTest { } @Test - public void shouldHaveHashCodeBasedOnContent() { + void shouldHaveHashCodeBasedOnContent() { //given final int hashOfOne = Mon.of("one") .hashCode(); @@ -155,7 +155,7 @@ public class MonTest { } @Test - public void shouldHaveEquals() { + void shouldHaveEquals() { //given final Mon one = Mon.of("one"); final Mon two = Mon.of("two"); diff --git a/src/test/java/net/kemitix/mon/OptionalMonadTest.java b/src/test/java/net/kemitix/mon/OptionalMonadTest.java index 8284a81..959813f 100644 --- a/src/test/java/net/kemitix/mon/OptionalMonadTest.java +++ b/src/test/java/net/kemitix/mon/OptionalMonadTest.java @@ -1,12 +1,12 @@ package net.kemitix.mon; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Optional; import java.util.function.Function; -public class OptionalMonadTest implements WithAssertions { +class OptionalMonadTest implements WithAssertions { private final int v = 1; private final Function> f = i -> o(i * 2); @@ -17,7 +17,7 @@ public class OptionalMonadTest implements WithAssertions { } @Test - public void leftIdentity() { + void leftIdentity() { assertThat( o(v).flatMap(f) ).isEqualTo( @@ -26,7 +26,7 @@ public class OptionalMonadTest implements WithAssertions { } @Test - public void rightIdentity() { + void rightIdentity() { assertThat( o(v).flatMap(x -> o(x)) ).isEqualTo( @@ -35,7 +35,7 @@ public class OptionalMonadTest implements WithAssertions { } @Test - public void associativity() { + void associativity() { assertThat( o(v).flatMap(f).flatMap(g) ).isEqualTo( diff --git a/src/test/java/net/kemitix/mon/ResultMonadTest.java b/src/test/java/net/kemitix/mon/ResultMonadTest.java index d82bd71..57d5959 100644 --- a/src/test/java/net/kemitix/mon/ResultMonadTest.java +++ b/src/test/java/net/kemitix/mon/ResultMonadTest.java @@ -2,11 +2,11 @@ package net.kemitix.mon; import net.kemitix.mon.result.Result; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.function.Function; -public class ResultMonadTest implements WithAssertions { +class ResultMonadTest implements WithAssertions { private final int v = 1; private final Function> f = i -> r(i * 2); @@ -17,7 +17,7 @@ public class ResultMonadTest implements WithAssertions { } @Test - public void leftIdentity() { + void leftIdentity() { assertThat( r(v).flatMap(f) ).isEqualTo( @@ -26,7 +26,7 @@ public class ResultMonadTest implements WithAssertions { } @Test - public void rightIdentity() { + void rightIdentity() { assertThat( r(v).flatMap(x -> r(x)) ).isEqualTo( @@ -35,7 +35,7 @@ public class ResultMonadTest implements WithAssertions { } @Test - public void associativity() { + void associativity() { assertThat( r(v).flatMap(f).flatMap(g) ).isEqualTo( diff --git a/src/test/java/net/kemitix/mon/ResultTest.java b/src/test/java/net/kemitix/mon/ResultTest.java index 2754456..d793dd4 100644 --- a/src/test/java/net/kemitix/mon/ResultTest.java +++ b/src/test/java/net/kemitix/mon/ResultTest.java @@ -7,7 +7,7 @@ import net.kemitix.mon.result.ErrorResultException; import net.kemitix.mon.result.UnexpectedErrorResultException; import net.kemitix.mon.result.Result; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.concurrent.Callable; @@ -15,10 +15,10 @@ import java.util.concurrent.atomic.AtomicReference; import static org.assertj.core.api.Assumptions.assumeThat; -public class ResultTest implements WithAssertions { +class ResultTest implements WithAssertions { @Test - public void equality() { + void equality() { assertThat(Result.ok(1)).isEqualTo(Result.ok(1)); assertThat(Result.ok(1)).isNotEqualTo(Result.ok(2)); final RuntimeException runtimeException = new RuntimeException(); @@ -30,12 +30,12 @@ public class ResultTest implements WithAssertions { } @Test - public void successHashCodesAreUnique() { + void successHashCodesAreUnique() { assertThat(Result.ok(1).hashCode()).isNotEqualTo(Result.ok(2).hashCode()); } @Test - public void errorHashCodesAreUnique() { + void errorHashCodesAreUnique() { // despite having 'equivalent' exceptions, the exceptions are distinct instances, so should be considered unique //given final RuntimeException exception1 = new RuntimeException("message"); @@ -46,7 +46,7 @@ public class ResultTest implements WithAssertions { } @Test - public void whenOk_isOkay() { + void whenOk_isOkay() { //when final Result result = Result.ok("good"); //then @@ -54,7 +54,7 @@ public class ResultTest implements WithAssertions { } @Test - public void whenOkay_isNotError() { + void whenOkay_isNotError() { //when final Result result = Result.ok("good"); //then @@ -62,7 +62,7 @@ public class ResultTest implements WithAssertions { } @Test - public void whenOkay_matchSuccess() { + void whenOkay_matchSuccess() { //given final Result result = Result.ok("good"); //then @@ -73,7 +73,7 @@ public class ResultTest implements WithAssertions { } @Test - public void whenError_isError() { + void whenError_isError() { //when final Result result = Result.error(new Exception()); //then @@ -81,7 +81,7 @@ public class ResultTest implements WithAssertions { } @Test - public void whenError_isNotSuccess() { + void whenError_isNotSuccess() { //when final Result result = Result.error(new Exception()); //then @@ -89,7 +89,7 @@ public class ResultTest implements WithAssertions { } @Test - public void whenError_matchError() { + void whenError_matchError() { //given final Result result = Result.error(new Exception("bad")); //then @@ -100,7 +100,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenFlatMapToOkay_isOkay() { + void okay_whenFlatMapToOkay_isOkay() { //given final Result result = Result.ok("good"); //when @@ -114,7 +114,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenFlatMapToError_isError() { + void okay_whenFlatMapToError_isError() { //given final Result result = Result.ok("good"); //when @@ -124,7 +124,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenFlatMapToOkay_isError() { + void error_whenFlatMapToOkay_isError() { //given final Result result = Result.error(new Exception("bad")); //when @@ -134,7 +134,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenFlatMapToError_isError() { + void error_whenFlatMapToError_isError() { //given final Result result = Result.error(new Exception("bad")); //when @@ -144,7 +144,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenMap_isOkay() { + void okay_whenMap_isOkay() { //given final Result okResult = Result.ok(1); //when @@ -158,7 +158,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenMap_isError() { + void error_whenMap_isError() { //given final RuntimeException exception = new RuntimeException(); final Result errorResult = Result.error(exception); @@ -173,7 +173,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenMaybe_wherePasses_isOkayJust() { + void okay_whenMaybe_wherePasses_isOkayJust() { //given final Result okResult = Result.ok(1); //when @@ -187,7 +187,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenMaybe_whereFails_isOkayNothing() { + void okay_whenMaybe_whereFails_isOkayNothing() { //given final Result okResult = Result.ok(1); //when @@ -201,7 +201,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenMaybe_wherePasses_isError() { + void error_whenMaybe_wherePasses_isError() { //given final RuntimeException exception = new RuntimeException(); final Result errorResult = Result.error(exception); @@ -216,7 +216,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenMaybe_whereFails_isError() { + void error_whenMaybe_whereFails_isError() { //given final RuntimeException exception = new RuntimeException(); final Result errorResult = Result.error(exception); @@ -231,7 +231,7 @@ public class ResultTest implements WithAssertions { } @Test - public void just_whenFromMaybe_isOkay() { + void just_whenFromMaybe_isOkay() { //given final Maybe just = Maybe.just(1); //when @@ -245,7 +245,7 @@ public class ResultTest implements WithAssertions { } @Test - public void nothing_whenFromMaybe_isError() { + void nothing_whenFromMaybe_isError() { //given final Maybe nothing = Maybe.nothing(); final RuntimeException exception = new RuntimeException(); @@ -260,7 +260,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenToMaybe_isJust() { + void okay_whenToMaybe_isJust() { //given final Result ok = Result.ok(1); //when @@ -270,7 +270,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenToMaybe_isNothing() { + void error_whenToMaybe_isNothing() { //given final Result error = Result.error(new RuntimeException()); //when @@ -280,7 +280,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenOrElseThrow_isValue() throws Throwable { + void okay_whenOrElseThrow_isValue() throws Throwable { //given final Result ok = Result.ok(1); //when @@ -290,7 +290,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenOrElseThrow_throws() { + void error_whenOrElseThrow_throws() { //given final RuntimeException exception = new RuntimeException(); final Result error = Result.error(exception); @@ -300,7 +300,8 @@ public class ResultTest implements WithAssertions { .hasCause(exception); } - @Test public void okay_whenOrElseThrowT_isValue() throws Exception { + @Test + void okay_whenOrElseThrowT_isValue() throws Exception { //given final Result ok = Result.ok(1); //when @@ -309,7 +310,7 @@ public class ResultTest implements WithAssertions { assumeThat(value).isEqualTo(1); } - @Test public void errorT_whenOrElseThrowT_throwsT() { + @Test void errorT_whenOrElseThrowT_throwsT() { //given final RuntimeException exception = new RuntimeException(); final Result error = Result.error(exception); @@ -317,7 +318,8 @@ public class ResultTest implements WithAssertions { assertThatThrownBy(() -> error.orElseThrow(RuntimeException.class)).isSameAs(exception); } - @Test public void errorR_whenOrElseThrowT_throwsWrappedR() { + @Test + void errorR_whenOrElseThrowT_throwsWrappedR() { //given final IOException exception = new IOException(); final Result error = Result.error(exception); @@ -327,7 +329,8 @@ public class ResultTest implements WithAssertions { .hasCause(exception); } - @Test public void okay_whenOrElseThrowUnchecked_isValue() { + @Test + void okay_whenOrElseThrowUnchecked_isValue() { //given final Result ok = Result.ok(1); //when @@ -336,7 +339,8 @@ public class ResultTest implements WithAssertions { assumeThat(value).isEqualTo(1); } - @Test public void error_whenOrElseThrowUnchecked_throwsWrapped() { + @Test + void error_whenOrElseThrowUnchecked_throwsWrapped() { //given final IOException exception = new IOException(); final Result error = Result.error(exception); @@ -347,7 +351,7 @@ public class ResultTest implements WithAssertions { } @Test - public void justOkay_whenInvert_thenOkayJust() { + void justOkay_whenInvert_thenOkayJust() { //given final Maybe> justSuccess = Maybe.just(Result.ok(1)); //when @@ -360,7 +364,7 @@ public class ResultTest implements WithAssertions { } @Test - public void JustError_whenInvert_isError() { + void JustError_whenInvert_isError() { //given final RuntimeException exception = new RuntimeException(); final Maybe> justError = Maybe.just(Result.error(exception)); @@ -374,7 +378,7 @@ public class ResultTest implements WithAssertions { } @Test - public void nothing_whenInvert_thenOkayNothing() { + void nothing_whenInvert_thenOkayNothing() { //given final Maybe> nothing = Maybe.nothing(); //when @@ -387,7 +391,7 @@ public class ResultTest implements WithAssertions { } @Test - public void useCase_whenOkay_thenReturnSuccess() { + void useCase_whenOkay_thenReturnSuccess() { //given final UseCase useCase = UseCase.isOkay(); //when @@ -400,7 +404,7 @@ public class ResultTest implements WithAssertions { } @Test - public void useCase_whenFirstReadIsError_thenReturnError() { + void useCase_whenFirstReadIsError_thenReturnError() { //given final UseCase useCase = UseCase.firstReadInvalid(); //when @@ -415,7 +419,7 @@ public class ResultTest implements WithAssertions { } @Test - public void useCase_whenSecondReadIsError_thenReturnError() { + void useCase_whenSecondReadIsError_thenReturnError() { //given final UseCase useCase = UseCase.secondReadInvalid(); //when @@ -431,7 +435,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_toString() { + void okay_toString() { //given final Result ok = Result.ok(1); //when @@ -441,7 +445,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_toString() { + void error_toString() { //given final Result error = Result.error(new RuntimeException("failed")); //when @@ -451,7 +455,7 @@ public class ResultTest implements WithAssertions { } @Test - public void value_whenResultOf_isOkay() { + void value_whenResultOf_isOkay() { //given final Callable c = () -> "okay"; //when @@ -464,7 +468,7 @@ public class ResultTest implements WithAssertions { } @Test - public void exception_whenResultOf_isError() { + void exception_whenResultOf_isError() { //given final Callable c = () -> { throw new IOException(); @@ -479,7 +483,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenPeek_isConsumed() { + void okay_whenPeek_isConsumed() { //given final Result result = Result.ok(1); final AtomicReference consumed = new AtomicReference<>(0); @@ -491,7 +495,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenPeek_isNotConsumed() { + void error_whenPeek_isNotConsumed() { //given final Result result = Result.error(new RuntimeException()); final AtomicReference consumed = new AtomicReference<>(0); @@ -503,7 +507,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenOnError_isIgnored() { + void okay_whenOnError_isIgnored() { //given final Result ok = Result.ok(1); //when @@ -511,7 +515,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenOnError_isConsumed() { + void error_whenOnError_isConsumed() { //given final RuntimeException exception = new RuntimeException(); final Result error = Result.error(exception); @@ -523,7 +527,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenRecover_thenNoChange() { + void okay_whenRecover_thenNoChange() { //given final Result ok = Result.ok(1); //when @@ -533,7 +537,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenRecover_isSuccess() { + void error_whenRecover_isSuccess() { //given final Result error = Result.error(new RuntimeException()); //when @@ -543,7 +547,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenRecover_whereError_isUpdatedError() { + void error_whenRecover_whereError_isUpdatedError() { //given final Result error = Result.error(new RuntimeException("original")); //when @@ -553,7 +557,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenAndThen_whereSuccess_isUpdatedSuccess() { + void okay_whenAndThen_whereSuccess_isUpdatedSuccess() { //given final Result ok = Result.ok(1); //when @@ -564,7 +568,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenAndThen_whereError_isError() { + void okay_whenAndThen_whereError_isError() { //given final Result ok = Result.ok(1); final RuntimeException exception = new RuntimeException(); @@ -578,7 +582,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whereAndThen_whereSuccess_isError() { + void error_whereAndThen_whereSuccess_isError() { //given final RuntimeException exception = new RuntimeException(); final Result error = Result.error(exception); @@ -590,7 +594,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenAndThen_whereError_isOriginalError() { + void error_whenAndThen_whereError_isOriginalError() { //given final RuntimeException exception1 = new RuntimeException(); final Result error = Result.error(exception1); @@ -604,7 +608,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenThenWith_whereOkay_isOriginalSuccess() { + void okay_whenThenWith_whereOkay_isOriginalSuccess() { //given final Result ok = Result.ok(1); //when @@ -616,7 +620,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okay_whenThenWith_whereError_thenError() { + void okay_whenThenWith_whereError_thenError() { //given final Result ok = Result.ok(1); final RuntimeException exception = new RuntimeException(); @@ -630,7 +634,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenThenWith_whereOkay_thenOriginalError() { + void error_whenThenWith_whereOkay_thenOriginalError() { //given final RuntimeException exception = new RuntimeException(); final Result error = Result.error(exception); @@ -643,7 +647,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenThenWith_whenError_thenOriginalError() { + void error_whenThenWith_whenError_thenOriginalError() { //given final RuntimeException exception = new RuntimeException(); final Result error = Result.error(exception); @@ -656,7 +660,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okayJust_whenFlatMapMaybe_whereOkayJust_thenIsOkayJust() { + void okayJust_whenFlatMapMaybe_whereOkayJust_thenIsOkayJust() { //given final Result> okJust = Result.ok(Maybe.just(1)); //when @@ -669,7 +673,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okayJust_whenFlatMapMaybe_whereOkayNothing_thenIsOkayNothing() { + void okayJust_whenFlatMapMaybe_whereOkayNothing_thenIsOkayNothing() { //given final Result> okJust = Result.ok(Maybe.just(1)); //when @@ -682,7 +686,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okayJust_whenFlatMapMaybe_whereError_thenIsError() { + void okayJust_whenFlatMapMaybe_whereError_thenIsError() { //given final Result> okJust = Result.ok(Maybe.just(1)); final RuntimeException exception = new RuntimeException(); @@ -696,7 +700,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okayNothing_whenFlatMapMaybe_thenDoNotApply() { + void okayNothing_whenFlatMapMaybe_thenDoNotApply() { //given final Result> okNothing = Result.ok(Maybe.nothing()); //when @@ -709,7 +713,7 @@ public class ResultTest implements WithAssertions { } @Test - public void error_whenFlatMapMaybe_thenDoNotApply() { + void error_whenFlatMapMaybe_thenDoNotApply() { //given final RuntimeException exception = new RuntimeException(); final Result> maybeResult = Result.error(exception); @@ -723,7 +727,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okayOkay_whenReduce_thenCombine() { + void okayOkay_whenReduce_thenCombine() { //given final Result result1 = Result.ok(1); final Result result10 = Result.ok(10); @@ -737,7 +741,7 @@ public class ResultTest implements WithAssertions { } @Test - public void okayError_whenReduce_thenError() { + void okayError_whenReduce_thenError() { //given final Result result1 = Result.ok(1); final RuntimeException exception = new RuntimeException(); @@ -752,7 +756,7 @@ public class ResultTest implements WithAssertions { } @Test - public void errorOkay_whenReduce_thenError() { + void errorOkay_whenReduce_thenError() { //given final RuntimeException exception = new RuntimeException(); final Result result1 = Result.error(exception); @@ -767,7 +771,7 @@ public class ResultTest implements WithAssertions { } @Test - public void errorError_whenReduce_thenError() { + void errorError_whenReduce_thenError() { //given final RuntimeException exception1 = new RuntimeException(); final Result result1 = Result.error(exception1); diff --git a/src/test/java/net/kemitix/mon/TypeAliasMonadTest.java b/src/test/java/net/kemitix/mon/TypeAliasMonadTest.java index 90c87df..1a665d9 100644 --- a/src/test/java/net/kemitix/mon/TypeAliasMonadTest.java +++ b/src/test/java/net/kemitix/mon/TypeAliasMonadTest.java @@ -1,11 +1,11 @@ package net.kemitix.mon; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.function.Function; -public class TypeAliasMonadTest implements WithAssertions { +class TypeAliasMonadTest implements WithAssertions { private final int v = 1; private final Function> f = i -> a(i * 2); @@ -16,7 +16,7 @@ public class TypeAliasMonadTest implements WithAssertions { } @Test - public void leftIdentity() { + void leftIdentity() { assertThat( a(v).flatMap(f) ).isEqualTo( @@ -25,7 +25,7 @@ public class TypeAliasMonadTest implements WithAssertions { } @Test - public void rightIdentity() { + void rightIdentity() { final AnAlias integerAnAlias = a(v).flatMap(x -> a(x)); assertThat( integerAnAlias @@ -35,7 +35,7 @@ public class TypeAliasMonadTest implements WithAssertions { } @Test - public void associativity() { + void associativity() { assertThat( a(v).flatMap(f).flatMap(g) ).isEqualTo( diff --git a/src/test/java/net/kemitix/mon/TypeAliasTest.java b/src/test/java/net/kemitix/mon/TypeAliasTest.java index 10497bf..7c89ad3 100644 --- a/src/test/java/net/kemitix/mon/TypeAliasTest.java +++ b/src/test/java/net/kemitix/mon/TypeAliasTest.java @@ -1,7 +1,7 @@ package net.kemitix.mon; import org.assertj.core.util.Strings; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; @@ -9,10 +9,10 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -public class TypeAliasTest { +class TypeAliasTest { @Test - public void shouldCreateATypeAliasAndGetTheValue() { + void shouldCreateATypeAliasAndGetTheValue() { //given final String value = "value"; //when @@ -27,7 +27,7 @@ public class TypeAliasTest { } @Test - public void shouldCreateATypeAliasWithNestedGenericTypes() { + void shouldCreateATypeAliasWithNestedGenericTypes() { //given final Iterable iterable = Collections.emptyList(); //when @@ -39,7 +39,7 @@ public class TypeAliasTest { } @Test - public void shouldCreateATypeAliasSubclassAndGetTheValue() { + void shouldCreateATypeAliasSubclassAndGetTheValue() { //given final String value = "value"; //when @@ -49,7 +49,7 @@ public class TypeAliasTest { } @Test - public void shouldNotBeEqualWhenValueTypesAreDifferent() { + void shouldNotBeEqualWhenValueTypesAreDifferent() { //given final TypeAlias stringTypeAlias = givenTypeAlias("1"); final TypeAlias integerTypeAlias = new TypeAlias(1) { @@ -59,7 +59,7 @@ public class TypeAliasTest { } @Test - public void shouldBeEqualWhenValuesAreTheSame() { + void shouldBeEqualWhenValuesAreTheSame() { //given final String value = "value"; final AnAlias anAlias1 = AnAlias.of(value); @@ -69,7 +69,7 @@ public class TypeAliasTest { } @Test - public void shouldNotBeEqualWhenValuesAreNotTheSame() { + void shouldNotBeEqualWhenValuesAreNotTheSame() { //given final AnAlias valueA = AnAlias.of("value a"); final AnAlias valueB = AnAlias.of("value b"); @@ -78,7 +78,7 @@ public class TypeAliasTest { } @Test - public void shouldBeEqualToRawValue() { + void shouldBeEqualToRawValue() { //given final String value = "value"; final AnAlias anAlias = AnAlias.of(value); @@ -87,7 +87,7 @@ public class TypeAliasTest { } @Test - public void shouldHaveHashCodeOfValue() { + void shouldHaveHashCodeOfValue() { //given final String value = "value"; final AnAlias anAlias = AnAlias.of(value); @@ -96,7 +96,7 @@ public class TypeAliasTest { } @Test - public void shouldHaveSameToStringAsAliasedType() { + void shouldHaveSameToStringAsAliasedType() { //given final List value = Arrays.asList(1, 2, 3); //when @@ -107,7 +107,7 @@ public class TypeAliasTest { } @Test - public void shouldMapTypeAlias() { + void shouldMapTypeAlias() { //given final AnAlias anAlias = AnAlias.of("text"); //when diff --git a/src/test/java/net/kemitix/mon/combinator/AfterTest.java b/src/test/java/net/kemitix/mon/combinator/AfterTest.java index 8d5a4eb..d7fc24a 100644 --- a/src/test/java/net/kemitix/mon/combinator/AfterTest.java +++ b/src/test/java/net/kemitix/mon/combinator/AfterTest.java @@ -1,6 +1,6 @@ package net.kemitix.mon.combinator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; @@ -8,10 +8,10 @@ import java.util.function.Function; import static org.assertj.core.api.Assertions.assertThat; -public class AfterTest { +class AfterTest { @Test - public void canCreateAfterCombinator() { + void canCreateAfterCombinator() { //given final List events = new ArrayList<>(); final Function squareDecorated = diff --git a/src/test/java/net/kemitix/mon/combinator/AroundTest.java b/src/test/java/net/kemitix/mon/combinator/AroundTest.java index ee94f2b..56d8a1b 100644 --- a/src/test/java/net/kemitix/mon/combinator/AroundTest.java +++ b/src/test/java/net/kemitix/mon/combinator/AroundTest.java @@ -1,6 +1,6 @@ package net.kemitix.mon.combinator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; @@ -8,10 +8,10 @@ import java.util.function.Function; import static org.assertj.core.api.Assertions.assertThat; -public class AroundTest { +class AroundTest { @Test - public void canCreateAnAroundCombinator() { + void canCreateAnAroundCombinator() { //given final List events = new ArrayList<>(); final Function squareDecorated = diff --git a/src/test/java/net/kemitix/mon/combinator/BeforeTest.java b/src/test/java/net/kemitix/mon/combinator/BeforeTest.java index d14d85c..992a18b 100644 --- a/src/test/java/net/kemitix/mon/combinator/BeforeTest.java +++ b/src/test/java/net/kemitix/mon/combinator/BeforeTest.java @@ -1,6 +1,6 @@ package net.kemitix.mon.combinator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; @@ -8,10 +8,10 @@ import java.util.function.Function; import static org.assertj.core.api.Assertions.assertThat; -public class BeforeTest { +class BeforeTest { @Test - public void canCreateBeforeCombinator() { + void canCreateBeforeCombinator() { //given final List events = new ArrayList<>(); final Function squareDecorated = diff --git a/src/test/java/net/kemitix/mon/lazy/LazySupplierTest.java b/src/test/java/net/kemitix/mon/lazy/LazySupplierTest.java index 78d7def..2cb86df 100644 --- a/src/test/java/net/kemitix/mon/lazy/LazySupplierTest.java +++ b/src/test/java/net/kemitix/mon/lazy/LazySupplierTest.java @@ -1,9 +1,7 @@ package net.kemitix.mon.lazy; import org.assertj.core.api.WithAssertions; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.Timeout; +import org.junit.jupiter.api.Test; import java.util.UUID; import java.util.concurrent.*; @@ -11,13 +9,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; -public class LazySupplierTest implements WithAssertions { - - @Rule - public final Timeout timeout = Timeout.seconds(1); +class LazySupplierTest implements WithAssertions { @Test - public void whenCreateLazyThenSupplierIsNotCalled() { + void whenCreateLazyThenSupplierIsNotCalled() { //given final AtomicBoolean supplierCalled = new AtomicBoolean(false); final Supplier supplier = () -> { @@ -31,7 +26,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenCreateLazyThenIsEvaluatedIsFalse() { + void whenCreateLazyThenIsEvaluatedIsFalse() { //given final Supplier supplier = UUID::randomUUID; //when @@ -41,7 +36,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenValueThenSupplierIsCalled() { + void whenValueThenSupplierIsCalled() { //given final AtomicBoolean supplierCalled = new AtomicBoolean(false); final Supplier supplier = () -> { @@ -56,7 +51,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenValueThenValueIsSameAsSupplier() { + void whenValueThenValueIsSameAsSupplier() { //given final UUID uuid = UUID.randomUUID(); final Supplier supplier = () -> uuid; @@ -68,7 +63,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenValueThenIsEvaluatedIsTrue() { + void whenValueThenIsEvaluatedIsTrue() { //given final Supplier supplier = () -> UUID.randomUUID(); final Lazy lazy = Lazy.of(supplier); @@ -79,7 +74,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenValueCalledTwiceThenSupplierIsNotCalledAgain() { + void whenValueCalledTwiceThenSupplierIsNotCalledAgain() { //given final AtomicInteger supplierCalledCounter = new AtomicInteger(0); final Supplier supplier = () -> { @@ -95,7 +90,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenMapLazyThenSupplierNotCalled() { + void whenMapLazyThenSupplierNotCalled() { //given final UUID uuid = UUID.randomUUID(); final AtomicBoolean supplierCalled = new AtomicBoolean(false); @@ -111,7 +106,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenMapLazyValueThenSupplierIsCalled() { + void whenMapLazyValueThenSupplierIsCalled() { //given final UUID uuid = UUID.randomUUID(); final AtomicBoolean supplierCalled = new AtomicBoolean(false); @@ -128,7 +123,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenMapLazyValueThenValueIsCorrect() { + void whenMapLazyValueThenValueIsCorrect() { //given final UUID uuid = UUID.randomUUID(); final AtomicBoolean supplierCalled = new AtomicBoolean(false); @@ -145,7 +140,7 @@ public class LazySupplierTest implements WithAssertions { } @Test - public void whenLazyValueCalledOnTwoThreadsThenSupplierIsOnlyCalledOnce() throws ExecutionException, InterruptedException { + void whenLazyValueCalledOnTwoThreadsThenSupplierIsOnlyCalledOnce() throws ExecutionException, InterruptedException { //given final AtomicInteger supplierCalledCounter = new AtomicInteger(0); final CountDownLatch latch = new CountDownLatch(1); @@ -173,4 +168,4 @@ public class LazySupplierTest implements WithAssertions { assertThat(supplierCalledCounter).hasValue(1); } -} \ No newline at end of file +} diff --git a/src/test/java/net/kemitix/mon/tree/GeneralisedTreeTest.java b/src/test/java/net/kemitix/mon/tree/GeneralisedTreeTest.java index 5771434..8cbaa35 100644 --- a/src/test/java/net/kemitix/mon/tree/GeneralisedTreeTest.java +++ b/src/test/java/net/kemitix/mon/tree/GeneralisedTreeTest.java @@ -1,17 +1,17 @@ package net.kemitix.mon.tree; import org.assertj.core.api.WithAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.UUID; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; -public class GeneralisedTreeTest implements WithAssertions { +class GeneralisedTreeTest implements WithAssertions { @Test - public void canCreateAnEmptyLeaf() { + void canCreateAnEmptyLeaf() { //when final Tree leaf = Tree.leaf(null); //then @@ -19,7 +19,7 @@ public class GeneralisedTreeTest implements WithAssertions { } @Test - public void canCreateANonEmptyLeaf() { + void canCreateANonEmptyLeaf() { //given final String item = "item"; //when @@ -29,7 +29,7 @@ public class GeneralisedTreeTest implements WithAssertions { } @Test - public void emptyLeafHasCountZero() { + void emptyLeafHasCountZero() { //given final Tree tree = Tree.leaf(null); //when @@ -39,7 +39,7 @@ public class GeneralisedTreeTest implements WithAssertions { } @Test - public void nonEmptyLeafHasCountOne() { + void nonEmptyLeafHasCountOne() { //given final Tree tree = Tree.leaf("value"); //when @@ -49,7 +49,7 @@ public class GeneralisedTreeTest implements WithAssertions { } @Test - public void canCreateTreeWithSubTrees() { + void canCreateTreeWithSubTrees() { //given final String treeItem = "tree"; final String leafItem = "leaf"; @@ -60,7 +60,7 @@ public class GeneralisedTreeTest implements WithAssertions { } @Test - public void canMapNestedTrees() { + void canMapNestedTrees() { //given final UUID uid1 = UUID.randomUUID(); final UUID uid2 = UUID.randomUUID();