commit
732c4f5206
5 changed files with 19 additions and 11 deletions
|
@ -33,7 +33,7 @@ class Address {
|
|||
|
||||
private final String street;
|
||||
|
||||
String getStreet() {
|
||||
protected String getStreet() {
|
||||
return street;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class Customer {
|
|||
|
||||
private final Address address;
|
||||
|
||||
Address getAddress() {
|
||||
protected Address getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class IdentityTest implements WithAssertions {
|
|||
//when
|
||||
final Identity<Integer> 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 <T> void assertIdentityContains(final Identity<T> identity, final T expected) {
|
||||
identity.map(id -> assertThat(id).isEqualTo(expected));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class MonTest {
|
|||
//when
|
||||
final Mon<String> 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<String> 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<Integer> 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<Mon<String>> 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<Mon<String>> nonFlatMapped = wrap.map(Mon::of);
|
||||
final Mon<String> 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 <T> void assertMonContains(final Mon<T> wrap, final T expected) {
|
||||
wrap.map(value -> assertThat(value).isEqualTo(expected));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String> {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue