public class InstantNotSupportedTest
{
private static class ClassWithInstant {
private Instant theInstant;
@Override
public String toString()
{
return "ClassWithInstant{" + "theInstant=" + theInstant + '}';
}
}
@Test
public void testToString() {
ToStringVerifier.forClass(ClassWithInstant.class)
.withClassName(NameStyle.SIMPLE_NAME)
.verify();
}
}
It throws this error: java.time.DateTimeException: Invalid value for NanoOfSecond (valid values 0 - 999999999): 1361563254
Of course, I could use sth like ".withPrefabValue(Instant.class, Instant.now())", but what if my class contains multiple fields of type Instant? The test will then not fail when I switch the field references in the toString() implementation.
What about adding a method like "withPrefabValueFactory(T, Supplier)"?
The following test fails:
It throws this error: java.time.DateTimeException: Invalid value for NanoOfSecond (valid values 0 - 999999999): 1361563254
Of course, I could use sth like ".withPrefabValue(Instant.class, Instant.now())", but what if my class contains multiple fields of type Instant? The test will then not fail when I switch the field references in the toString() implementation. What about adding a method like "withPrefabValueFactory(T, Supplier)"?