Closed
Description
Hello Javers-Team,
I found a bug which affects the JsonConverter.
An error is thrown in the JsonConverter when the JSON includes an InitialValueChange.
Example:
I created a Diff of two objects. One has a new child with initial values. This diff is converted to JSON with:
Javers javers = JaversBuilder.javers().withTerminalChanges(false).build();
Diff diff = javers.compare(fooOldRevision, fooCurrent);
javers.getJsonConverter().toJson(diff);
The output-JSON of this is:
{
"changes": [
{
"changeType": "NewObject",
"globalId": {
"entity": "cms.domain.Bar",
"cdoId": "58e90e85-e7c6-47f1-96b2-e71b7d936132"
}
},
{
"changeType": "InitialValueChange",
"globalId": {
"entity": "cms.domain.Bar",
"cdoId": "58e90e85-e7c6-47f1-96b2-e71b7d936132"
},
"property": "id",
"propertyChangeType": "PROPERTY_VALUE_CHANGED"
}
]
}
If I now take this JSON and put it in the method
Diff diff = javers.getJsonConverter().fromJson(changes, Diff.class);
to convert it to a Diff again, an error is thrown: MALFORMED_CHANGE_TYPE_FIELD: no such Change type - 'InitialChange'
This error seems to be thrown in the ChangeTypeAdapter.class as the InitialValueChange.class is not part of the constructor of this class.
Thank you for your help!