added test cases to TimeTest.java
to increase code coverage
Issue-ID: APPC-1086
Change-Id: I204a69f765356a4ea045793b0fefb69b68a406bf
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
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 961a62c..3a73d7a 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.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 @@
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);
+ }
}