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
This commit is contained in:
Paul Campbell 2018-10-12 20:42:11 +01:00 committed by GitHub
parent f92c9cfa65
commit 73e59b0050
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 246 additions and 223 deletions

View file

@ -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
-----

View file

@ -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"
}
}
}

47
pom.xml
View file

@ -33,13 +33,16 @@
<properties>
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
<junit.version>5.3.1</junit.version>
<mockito.version>2.23.0</mockito.version>
<assertj.version>3.11.1</assertj.version>
<lombok.version>1.18.2</lombok.version>
<tiles-maven-plugin.version>2.12</tiles-maven-plugin.version>
<kemitix-maven-tiles.version>1.2.0</kemitix-maven-tiles.version>
<digraph-dependency.basePackage>net.kemitix.mon</digraph-dependency.basePackage>
<kemitix-checkstyle.version>5.0.0</kemitix-checkstyle.version>
<pitest-maven-plugin.version>1.4.3</pitest-maven-plugin.version>
<pitest-junit5-plugin.version>0.7</pitest-junit5-plugin.version>
</properties>
<dependencies>
@ -49,10 +52,21 @@
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@ -63,6 +77,18 @@
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
@ -77,6 +103,19 @@
</tiles>
</configuration>
</plugin><!-- tiles-maven-plugin -->
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>${pitest-maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>${pitest-junit5-plugin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

View file

@ -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<DataObject> template = () -> new DataObject("name");
final Consumer<DataObject> value = data -> data.setValue("value");

View file

@ -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<Integer, String> 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<Integer, String> 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<Integer, String> 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<Integer, String> 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<Integer, String> 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<Integer, String> 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<Integer, String> 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<Integer, String> 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<Integer, String> 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<Integer, String> either = Either.right("2");
//when

View file

@ -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<Integer, Maybe<Integer>> 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(

View file

@ -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 <T> Predicate<T> 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<Integer> 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<Integer> 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<Integer> 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<Integer> stream = just(1).stream();
//then
@ -156,7 +156,7 @@ public class MaybeTest implements WithAssertions {
}
@Test
public void nothingToStream() {
void nothingToStream() {
//when
final Stream<Object> stream = nothing().stream();
//then
@ -164,7 +164,7 @@ public class MaybeTest implements WithAssertions {
}
@Test
public void justFlatMap() {
void justFlatMap() {
//given
final Maybe<Integer> just1 = just(1);
final Maybe<Integer> just2 = just(2);
@ -178,7 +178,7 @@ public class MaybeTest implements WithAssertions {
}
@Test
public void nothingFlatMap() {
void nothingFlatMap() {
//given
final Maybe<Integer> nothing1 = nothing();
final Maybe<Integer> nothing2 = nothing();
@ -192,7 +192,7 @@ public class MaybeTest implements WithAssertions {
}
@Test
public void justNothingFlatMap() {
void justNothingFlatMap() {
//given
final Maybe<Integer> just1 = just(1);
final Maybe<Integer> nothing2 = nothing();
@ -206,7 +206,7 @@ public class MaybeTest implements WithAssertions {
}
@Test
public void just_ifNothing_isIgnored() {
void just_ifNothing_isIgnored() {
//given
final Maybe<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Object> 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<Object> 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<String> 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<String> one = Maybe.nothing();
//when

View file

@ -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<String> wrap = Mon.of("test");
//then
@ -26,7 +26,7 @@ public class MonTest {
}
@Test
public void canMap() {
void canMap() {
//given
final Mon<String> wrap = Mon.of("test");
//when
@ -36,7 +36,7 @@ public class MonTest {
}
@Test
public void canMapInstance() {
void canMapInstance() {
//given
final Mon<String> wrap = Mon.of("test");
//when
@ -46,7 +46,7 @@ public class MonTest {
}
@Test
public void createWithValidatorAndContinuations() {
void createWithValidatorAndContinuations() {
//given
final Function<String, Optional<Mon<String>>> factory =
Mon.factory(
@ -65,7 +65,7 @@ public class MonTest {
@Test
public void canCompare() {
void canCompare() {
//given
final Mon<String> one = Mon.of("test");
final Mon<String> same = Mon.of("test");
@ -76,7 +76,7 @@ public class MonTest {
}
@Test
public void canFlatMap() {
void canFlatMap() {
//given
final Mon<String> 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<Integer, Optional<?>> 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<Object, Optional<?>> 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<String> one = Mon.of("one");
final Mon<String> two = Mon.of("two");

View file

@ -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<Integer, Optional<Integer>> 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(

View file

@ -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<Integer, Result<Integer>> 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(

View file

@ -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<String> 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<String> 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<String> 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<String> 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<String> 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<Object> 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<String> 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<String> 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<String> 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<String> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Object> 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<Integer> 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<Object> 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<Integer> 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<Integer> 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<Integer> 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<Object> 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<Object> 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<Integer> 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<Object> 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<Result<Integer>> 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<Result<Object>> 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<Result<Integer>> 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<Integer> 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<Integer> 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<String> 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<String> 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<Integer> result = Result.ok(1);
final AtomicReference<Integer> 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<Integer> result = Result.error(new RuntimeException());
final AtomicReference<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Object> 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<Object> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Maybe<Integer>> 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<Maybe<Integer>> 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<Maybe<Integer>> 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<Maybe<Integer>> 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<Maybe<Integer>> 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<Integer> result1 = Result.ok(1);
final Result<Integer> 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<Integer> 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<Integer> 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<Integer> result1 = Result.error(exception1);

View file

@ -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<Integer, AnAlias<Integer>> 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<Integer> 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(

View file

@ -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<String> 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<String> stringTypeAlias = givenTypeAlias("1");
final TypeAlias<Integer> integerTypeAlias = new TypeAlias<Integer>(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<Integer> 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

View file

@ -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<String> events = new ArrayList<>();
final Function<Integer, Integer> squareDecorated =

View file

@ -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<String> events = new ArrayList<>();
final Function<Integer, Integer> squareDecorated =

View file

@ -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<String> events = new ArrayList<>();
final Function<Integer, Integer> squareDecorated =

View file

@ -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<UUID> supplier = () -> {
@ -31,7 +26,7 @@ public class LazySupplierTest implements WithAssertions {
}
@Test
public void whenCreateLazyThenIsEvaluatedIsFalse() {
void whenCreateLazyThenIsEvaluatedIsFalse() {
//given
final Supplier<UUID> 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<UUID> supplier = () -> {
@ -56,7 +51,7 @@ public class LazySupplierTest implements WithAssertions {
}
@Test
public void whenValueThenValueIsSameAsSupplier() {
void whenValueThenValueIsSameAsSupplier() {
//given
final UUID uuid = UUID.randomUUID();
final Supplier<UUID> supplier = () -> uuid;
@ -68,7 +63,7 @@ public class LazySupplierTest implements WithAssertions {
}
@Test
public void whenValueThenIsEvaluatedIsTrue() {
void whenValueThenIsEvaluatedIsTrue() {
//given
final Supplier<UUID> supplier = () -> UUID.randomUUID();
final Lazy<UUID> 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<UUID> 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);

View file

@ -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<String> 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<Object> tree = Tree.leaf(null);
//when
@ -39,7 +39,7 @@ public class GeneralisedTreeTest implements WithAssertions {
}
@Test
public void nonEmptyLeafHasCountOne() {
void nonEmptyLeafHasCountOne() {
//given
final Tree<String> 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();