diff options
-rw-r--r-- | appc-common/src/test/java/org/onap/appc/util/TimeTest.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/appc-common/src/test/java/org/onap/appc/util/TimeTest.java b/appc-common/src/test/java/org/onap/appc/util/TimeTest.java index aef02a293..6aaeb5899 100644 --- a/appc-common/src/test/java/org/onap/appc/util/TimeTest.java +++ b/appc-common/src/test/java/org/onap/appc/util/TimeTest.java @@ -25,11 +25,9 @@ package org.onap.appc.util; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Test; - +import java.text.ParseException; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.util.Calendar; @@ -37,6 +35,10 @@ import java.util.Date; import java.util.Locale; import java.util.TimeZone; +import javax.xml.datatype.XMLGregorianCalendar; + +import org.junit.Test; + public class TimeTest { @@ -113,7 +115,7 @@ public class TimeTest { @Test public void testSetDate() { - Calendar cal = Calendar.getInstance(); + Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2018); cal.set(Calendar.MONTH, 07); cal.set(Calendar.DAY_OF_MONTH, 03); @@ -123,6 +125,25 @@ public class TimeTest { @Test public void testStartOfDayLocal() { - assertTrue(Time.startOfDayLocal() instanceof Date); + assertTrue(Time.startOfDayLocal() instanceof Date); + } + + @Test + public void testTimeStamp() { + assertTrue(Time.timestamp() instanceof XMLGregorianCalendar); + } + + @Test + public void testDateToStringConverterMillis() { + String dateString=Time.dateToStringConverterMillis(new Date("02/09/2004")); + String expected="2004-02-09 00:00:00:000"; + assertEquals(expected, dateString); + } + + @Test + public void testStringToDateConverterMillis() throws ParseException{ + Date date=Time.stringToDateConverterMillis("2004-02-09 00:00:00:000"); + Date expected=new Date("02/09/2004"); + assertEquals(expected, date); } } |