1 package org.onap.cps.ncmp.dmi.rest.stub.utils;
3 import spock.lang.Specification
7 class EventDateTimeFormatterSpec extends Specification {
9 def 'Get ISO formatted date and time.' () {
10 expect: 'iso formatted date and time starts with current year'
11 assert EventDateTimeFormatter.getCurrentIsoFormattedDateTime().startsWith(String.valueOf(Year.now()))
14 def 'Convert date time from string to OffsetDateTime type.'() {
15 when: 'date time as a string is converted to OffsetDateTime type'
16 def result = EventDateTimeFormatter.toIsoOffsetDateTime('2024-05-28T18:28:02.869+0100')
17 then: 'the result convert back back to a string is the same as the original timestamp (except the format of timezone offset)'
18 assert result.toString() == '2024-05-28T18:28:02.869+01:00'
21 def 'Convert blank string.' () {
22 expect: 'converting a blank string result in null'
23 assert EventDateTimeFormatter.toIsoOffsetDateTime(' ') == null