From 4ff6f2a5d19852018c718ea431baf6d1dedda051 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 24 Jul 2018 17:19:34 +0530 Subject: added some more test cases to TimeTest.java added some more test cases to increase code coverage Issue-ID: APPC-1086 Change-Id: I8f4458ddcc70d360eae71e41d1608d0529ed2269 Signed-off-by: Sandeep J --- .../src/test/java/org/onap/appc/util/TimeTest.java | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'appc-common') 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); } } -- cgit 1.2.3-korg