You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB
Java

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");
}
}