Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Lib
core
OS Core Common
Commits
f1105ca0
Commit
f1105ca0
authored
Jun 18, 2020
by
Rostislav Vatolin [SLB]
☕
Browse files
support old version of date representation
parent
1d592a6b
Pipeline
#2627
failed with stage
in 22 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/opengroup/osdu/core/common/model/legal/serialization/ExpirationDateDeserializer.java
View file @
f1105ca0
...
...
@@ -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
()));
}
}
src/test/java/org/opengroup/osdu/core/common/model/legal/LegalTagSerializationTest.java
View file @
f1105ca0
...
...
@@ -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
());
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment