From 975556b8704e5ea2e3e509e2e2081774d17af48e Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 28 Nov 2018 18:44:18 +0530 Subject: added test cases to TimeTest.java to increase code coverage Issue-ID: APPC-1086 Change-Id: I204a69f765356a4ea045793b0fefb69b68a406bf Signed-off-by: Sandeep J --- .../src/test/java/org/onap/appc/util/TimeTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/TimeTest.java b/appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/TimeTest.java index 961a62c0a..3a73d7a2c 100644 --- a/appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/TimeTest.java +++ b/appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/TimeTest.java @@ -33,9 +33,12 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import org.junit.Test; @@ -147,4 +150,22 @@ public class TimeTest { Date expected=new Date("02/09/2004"); assertEquals(expected, date); } + + @Test + public void testTruncateDate() throws ParseException{ + Date date=Time.truncDate(new Date("02/09/2004")); + Date expected=new Date("02/09/2004"); + assertEquals(expected, date); + } + + @Test + public void testToDate() throws ParseException, DatatypeConfigurationException{ + Date date=new Date("02/09/2004"); + GregorianCalendar c = new GregorianCalendar(); + c.setTime(date); + XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); + Date actual= Time.toDate(calendar); + Date expected=new Date("02/09/2004"); + assertEquals(expected, actual); + } } -- cgit 1.2.3-korg