package org.gbif.common.parsers.date;

import static junit.framework.TestCase.assertEquals;
import static org.gbif.common.parsers.date.DateComponentOrdering.DMY_FORMATS;

import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.TemporalAccessor;
import org.gbif.common.parsers.core.ParseResult;

import org.junit.Test;

public class PrefTexDateParserTest {

  private final TemporalParser parser =  PrefTextDateParser.getInstance(DMY_FORMATS);

  @Test
  public void testTextDateParsing(){
    ParseResult<TemporalAccessor> parseResult =  parser.parse("1/2/2000");
    assertEquals(LocalDate.of(2000, Month.FEBRUARY, 1), LocalDate.from(parseResult.getPayload()));
    parseResult =  parser.parse("2000-2-1");
    assertEquals(LocalDate.of(2000, Month.FEBRUARY, 1), LocalDate.from(parseResult.getPayload()));
    parseResult = parser.parse("23-March-1969");
    assertEquals(LocalDate.of(1969, Month.MARCH, 23), LocalDate.from(parseResult.getPayload()));
  }
}

@@ -162,16 +162,103 @@
 FORMATS;
+%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Aimport
@@ -1055,14 +1055,155 @@
 ad()));%0A
+    parseResult = parser.parse(%227/10/08%22);%0A    assertEquals(LocalDate.of(2008, Month.OCTOBER, 7), LocalDate.from(parseResult.getPayload()));%0A
   %7D%0A%7D%0A

Add tests for Pref