I am using Lagom
framework with Java
. I have a model class which uses optional in the constructor argument. I have only one persistent entity based on this model class and have entity tests (using PersistentEntityTestDriver
) for this entity. The problem is all entity tests fail with this error -
java.lang.AssertionError:
Expected :[]
Actual :[[class java.util.Optional is not serializable, No configured serialization-bindings for class [com.sp.User]]
Sample User class -
class User {
public final UUID id;
public final ZonedDateTime date;
@JsonCreator
public User(@JsonProperty("id") UUID userId,
@JsonProperty("address") Optional<ZonedDateTime> date) {
this.id = id;
this.date = createdOn.orElse(getUtcDateTime());
}
}
How can I configure my service to serialize optional.