2020-09-07 15:36:30 +02:00
|
|
|
package eu.dnetlib.ariadneplus.reader.utils;
|
|
|
|
|
2020-09-07 15:37:05 +02:00
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
2020-09-07 15:36:30 +02:00
|
|
|
public class ESUtilsTest {
|
2020-09-07 15:37:05 +02:00
|
|
|
|
2020-11-30 13:27:28 +01:00
|
|
|
// Elastic search format: yyyy-MM-dd or yyyy
|
|
|
|
|
2020-09-07 15:37:05 +02:00
|
|
|
@Test
|
|
|
|
public void testParseDate(){
|
|
|
|
String date = "2013-03-13";
|
|
|
|
String parsed = ESUtils.getESFormatDate(date);
|
|
|
|
Assert.assertEquals(date, parsed);
|
|
|
|
}
|
2020-11-30 13:27:28 +01:00
|
|
|
|
|
|
|
@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");
|
|
|
|
}
|
2021-01-26 16:39:47 +01:00
|
|
|
|
|
|
|
@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");
|
|
|
|
}
|
2020-09-07 15:36:30 +02:00
|
|
|
}
|