i have to convert an Option to Optional, and created the code for this but i believe it could be even shorter that the private method is not used.
Optional<Long> optionalLong ;
Optional<Instant> optionalInstant;
assertThat(createdOrder.acceptedTime, is( OptionalLongToOptionalInstant(expectedOrder.acceptedTime())));
private Optional<Instant> OptionalLongToOptionalInstant(Optional<Long> optionalLong ) {
if(optionalLong.isPresent()){
return Optional.of(Instant.ofEpochMilli(optionalLong.get()));
}
return Optional.empty();
}