diff --git a/src/test/java/net/kemitix/mon/Address.java b/src/test/java/net/kemitix/mon/Address.java index 8bfbd37..5e8b0cb 100644 --- a/src/test/java/net/kemitix/mon/Address.java +++ b/src/test/java/net/kemitix/mon/Address.java @@ -33,7 +33,7 @@ class Address { private final String street; - String getStreet() { + protected String getStreet() { return street; } } diff --git a/src/test/java/net/kemitix/mon/Customer.java b/src/test/java/net/kemitix/mon/Customer.java index 594abd7..f96f133 100644 --- a/src/test/java/net/kemitix/mon/Customer.java +++ b/src/test/java/net/kemitix/mon/Customer.java @@ -33,7 +33,7 @@ class Customer { private final Address address; - Address getAddress() { + protected Address getAddress() { return address; } diff --git a/src/test/java/net/kemitix/mon/IdentityTest.java b/src/test/java/net/kemitix/mon/IdentityTest.java index c93a2e9..5a1b3f3 100644 --- a/src/test/java/net/kemitix/mon/IdentityTest.java +++ b/src/test/java/net/kemitix/mon/IdentityTest.java @@ -17,7 +17,7 @@ public class IdentityTest implements WithAssertions { //when final Identity idInt = idString.map(String::length); //then - idInt.map(id -> assertThat(id).isEqualTo(3)); + assertIdentityContains(idInt, 3); } @Test @@ -31,7 +31,11 @@ public class IdentityTest implements WithAssertions { .map(String::toLowerCase) .map(String::getBytes); //then - idBytes.map(bytes -> assertThat(bytes).isEqualTo("par".getBytes())); + assertIdentityContains(idBytes, "par".getBytes()); + } + + private void assertIdentityContains(final Identity identity, final T expected) { + identity.map(id -> assertThat(id).isEqualTo(expected)); } } diff --git a/src/test/java/net/kemitix/mon/MonTest.java b/src/test/java/net/kemitix/mon/MonTest.java index 91b51f0..96272c3 100644 --- a/src/test/java/net/kemitix/mon/MonTest.java +++ b/src/test/java/net/kemitix/mon/MonTest.java @@ -15,7 +15,7 @@ public class MonTest { //when final Mon wrap = Mon.of("test"); //then - wrap.map(value -> assertThat(value).isEqualTo("test")); + assertMonContains(wrap, "test"); } @Test @@ -25,7 +25,7 @@ public class MonTest { //when final Mon updated = wrap.map(a -> a + " more"); //then - updated.map(value -> assertThat(value).isEqualTo("test more")); + assertMonContains(updated, "test more"); } @Test @@ -35,7 +35,7 @@ public class MonTest { //when final Mon result = wrap.map(String::length); //then - result.map(value -> assertThat(value).isEqualTo(4)); + assertMonContains(result, 4); } @Test @@ -52,7 +52,7 @@ public class MonTest { final Optional> longAndInvalid = factory.apply("value is too long"); //then assertThat(shortAndValid).isNotEmpty(); - shortAndValid.ifPresent(valid -> valid.map(value -> assertThat(value).contains("value okay"))); + shortAndValid.ifPresent(valid -> assertMonContains(valid, "value okay")); assertThat(longAndInvalid).isEmpty(); } @@ -76,7 +76,7 @@ public class MonTest { final Mon> nonFlatMapped = wrap.map(Mon::of); final Mon result = wrap.flatMap(Mon::of); //then - result.map(value -> assertThat(value).isEqualTo("test")); + assertMonContains(result, "test"); nonFlatMapped.map(inner -> assertThat(result).isEqualTo(inner)); } @@ -144,4 +144,8 @@ public class MonTest { assertThat(one).isNotEqualTo(notAMon); assertThat(one).isNotEqualTo(null); } + + private void assertMonContains(final Mon wrap, final T expected) { + wrap.map(value -> assertThat(value).isEqualTo(expected)); + } } diff --git a/src/test/java/net/kemitix/mon/TypeAliasTest.java b/src/test/java/net/kemitix/mon/TypeAliasTest.java index 91687c3..069c6ab 100644 --- a/src/test/java/net/kemitix/mon/TypeAliasTest.java +++ b/src/test/java/net/kemitix/mon/TypeAliasTest.java @@ -60,7 +60,7 @@ public class TypeAliasTest { //given final String value = "value"; final AnAlias anAlias = AnAlias.of(value); - assertThat(anAlias.toString()).isEqualTo(value.toString()); + assertThat(anAlias.toString()).isEqualTo(value); } private static class AnAlias extends TypeAlias { @@ -74,7 +74,7 @@ public class TypeAliasTest { super(value); } - static AnAlias of(final String value) { + protected static AnAlias of(final String value) { return new AnAlias(value); } }