You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TimeSpecimen Cannot be Created for Valid Implementations #111
For this particular test, SpecimenType.isTimeType() returns true for any type that implements TemporalAdjuster, but when creating the instance, TimeSpecimen only checks for the specific implementation MonthDay and throws otherwise.
So we either have to relax the TimeSpecimen to return MonthDay for anyTemporalAdjuster-implementation, or we make SpecimenType.isTimeType() stricter in detecting temporal types. I'd prefer the latter.
I also assume, the same problem happens for the TemporalAmount-interface while the Temporal-interface seems properly covered.
When I look at the code, it seems to me that we are doing classes/interfaces from
java.time.temporal package in an inconsistent way.
When we create a specimen that implements the Temporal interface, we try to call the "now"
method on it. This method is not required by the interface (but it works for a lot
of implementations, e.g. Instant).
When we create a TemporalAdjuster interface, we fail because this interface is recognized
as a TimeSpecimen, but it is not assignable to a Temporal interface.
When we create a TemporalAccessor interface, we treat it like just another interface.
Therefore creation works without treating it as time related.
When we create a JapaneseEra, we treat this as a TimeSpecimen and return an actual
valid JapaneseEra.
When we create a HijrahChronology, we treat this an ObjectSpecimen and therefore create
an invalid object (because we fill the private fields with nonsense values).
I prefer time based objects to behave "normally", i.e. a method that always succeeds
in valid object of a java.time.* class must always succeed in a JavaFixture created
object.
So something like Instant.getNano() should return a non-negative value that is
less than 999,999,999.
We could probably achieve this by creating these objects via
Activity
Nylle commentedon Sep 10, 2024
Here are a few more tests:
akutschera commentedon Jul 6, 2025
When I look at the code, it seems to me that we are doing classes/interfaces from
java.time.temporal package in an inconsistent way.
When we create a specimen that implements the Temporal interface, we try to call the "now"
method on it. This method is not required by the interface (but it works for a lot
of implementations, e.g. Instant).
When we create a TemporalAdjuster interface, we fail because this interface is recognized
as a TimeSpecimen, but it is not assignable to a Temporal interface.
When we create a TemporalAccessor interface, we treat it like just another interface.
Therefore creation works without treating it as time related.
When we create a JapaneseEra, we treat this as a TimeSpecimen and return an actual
valid JapaneseEra.
When we create a HijrahChronology, we treat this an ObjectSpecimen and therefore create
an invalid object (because we fill the private fields with nonsense values).
I prefer time based objects to behave "normally", i.e. a method that always succeeds
in valid object of a java.time.* class must always succeed in a JavaFixture created
object.
So something like Instant.getNano() should return a non-negative value that is
less than 999,999,999.
We could probably achieve this by creating these objects via