Commit f1105ca0 authored by Rostislav Vatolin [SLB]'s avatar Rostislav Vatolin [SLB]
Browse files

support old version of date representation

parent 1d592a6b
Pipeline #2627 failed with stage
in 22 seconds
......@@ -23,6 +23,9 @@ public class ExpirationDateDeserializer extends StdDeserializer<Date> {
if (expirationDate == null || StringUtils.isBlank(expirationDate.asText())) {
return Properties.DEFAULT_EXPIRATIONDATE;
}
if (expirationDate.isLong()) {
return new Date(expirationDate.asLong());
}
return Date.valueOf(LocalDate.parse(expirationDate.asText()));
}
}
......@@ -91,4 +91,18 @@ public class LegalTagSerializationTest {
Assert.assertEquals(Date.valueOf("9999-12-31"), legalTag.getProperties().getExpirationDate());
}
@Test
public void shouldParseDateInOldFormat() throws IOException {
final String input = "{\"id\":123,\"name\":\"name\",\"description\":\"desc\"," +
"\"properties\":{\"countryOfOrigin\":[\"US\",\"BY\"],\"contractId\":\"contrId\"," +
"\"expirationDate\": 1570863500000,\"originator\":\"company\"," +
"\"dataType\":\"dataType\",\"securityClassification\":\"securityClassification\"," +
"\"personalData\":\"data\",\"exportClassification\":\"exportClassification\"}," +
"\"isValid\":false}";
LegalTag legalTag = objectMapper.readValue(input, LegalTag.class);
Assert.assertEquals(Date.valueOf("2019-10-12").toLocalDate(), legalTag.getProperties().getExpirationDate().toLocalDate());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment