summaryrefslogtreecommitdiffstats
path: root/dmi-stub/dmi-stub-service/src/test/groovy/org
diff options
context:
space:
mode:
Diffstat (limited to 'dmi-stub/dmi-stub-service/src/test/groovy/org')
-rw-r--r--dmi-stub/dmi-stub-service/src/test/groovy/org/onap/cps/ncmp/dmi/rest/stub/utils/EventDateTimeFormatterSpec.groovy27
1 files changed, 27 insertions, 0 deletions
diff --git a/dmi-stub/dmi-stub-service/src/test/groovy/org/onap/cps/ncmp/dmi/rest/stub/utils/EventDateTimeFormatterSpec.groovy b/dmi-stub/dmi-stub-service/src/test/groovy/org/onap/cps/ncmp/dmi/rest/stub/utils/EventDateTimeFormatterSpec.groovy
new file mode 100644
index 00000000..9e229127
--- /dev/null
+++ b/dmi-stub/dmi-stub-service/src/test/groovy/org/onap/cps/ncmp/dmi/rest/stub/utils/EventDateTimeFormatterSpec.groovy
@@ -0,0 +1,27 @@
+package org.onap.cps.ncmp.dmi.rest.stub.utils;
+
+import spock.lang.Specification
+
+import java.time.Year
+
+class EventDateTimeFormatterSpec extends Specification {
+
+ def 'Get ISO formatted date and time.' () {
+ expect: 'iso formatted date and time starts with current year'
+ assert EventDateTimeFormatter.getCurrentIsoFormattedDateTime().startsWith(String.valueOf(Year.now()))
+ }
+
+ def 'Convert date time from string to OffsetDateTime type.'() {
+ when: 'date time as a string is converted to OffsetDateTime type'
+ def result = EventDateTimeFormatter.toIsoOffsetDateTime('2024-05-28T18:28:02.869+0100')
+ then: 'the result convert back back to a string is the same as the original timestamp (except the format of timezone offset)'
+ assert result.toString() == '2024-05-28T18:28:02.869+01:00'
+ }
+
+ def 'Convert blank string.' () {
+ expect: 'converting a blank string result in null'
+ assert EventDateTimeFormatter.toIsoOffsetDateTime(' ') == null
+ }
+
+}
+