package eu.dnetlib.ariadneplus.reader.utils; import org.junit.Assert; import org.junit.Test; public class ESUtilsTest { // Elastic search format: yyyy-MM-dd or yyyy @Test public void testParseDate(){ String date = "2013-03-13"; String parsed = ESUtils.getESFormatDate(date); Assert.assertEquals(date, parsed); } @Test public void testBSTDate(){ String date = "Fri May 15 13:21:02 BST 2020"; String parsed = ESUtils.getESFormatDate(date); Assert.assertEquals(parsed, "2020-05-15"); } @Test public void testYearDate(){ String date = "2012"; String parsed = ESUtils.getESFormatDate(date); Assert.assertEquals(parsed, "2012"); } @Test public void testEmtyDate(){ String date = ""; String parsed = ESUtils.getESFormatDate(date); Assert.assertEquals(parsed, "0000"); } @Test public void testErrorDate(){ String date = "????"; String parsed = ESUtils.getESFormatDate(date); Assert.assertEquals(parsed, "0000"); } }