9e2291275ce90b9f895629730bcea15fed669e97
[cps/ncmp-dmi-plugin.git] /
1 package org.onap.cps.ncmp.dmi.rest.stub.utils;
2
3 import spock.lang.Specification
4
5 import java.time.Year
6
7 class EventDateTimeFormatterSpec extends Specification {
8
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()))
12     }
13
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'
19     }
20
21     def 'Convert blank string.' () {
22         expect: 'converting a blank string result in null'
23             assert EventDateTimeFormatter.toIsoOffsetDateTime(' ') == null
24     }
25
26 }
27