Update unit test
This commit is contained in:
parent
9c8da51277
commit
abb32b796a
|
@ -1,6 +1,5 @@
|
|||
package net.filebot.similarity;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -17,9 +16,9 @@ import java.util.function.Predicate;
|
|||
import java.util.regex.MatchResult;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import net.filebot.web.SimpleDate;
|
||||
import one.util.streamex.IntStreamEx;
|
||||
import one.util.streamex.StreamEx;
|
||||
|
||||
public class DateMatcher {
|
||||
|
@ -155,7 +154,7 @@ public class DateMatcher {
|
|||
|
||||
protected SimpleDate process(MatchResult match) {
|
||||
try {
|
||||
String dateString = IntStream.rangeClosed(1, match.groupCount()).mapToObj(match::group).collect(joining(DELIMITER));
|
||||
String dateString = IntStreamEx.rangeClosed(1, match.groupCount()).mapToObj(match::group).joining(DELIMITER);
|
||||
LocalDate date = LocalDate.parse(dateString, format);
|
||||
|
||||
if (sanity == null || sanity.test(date)) {
|
||||
|
|
|
@ -26,7 +26,7 @@ public class DateMatcherTest {
|
|||
@Test
|
||||
public void parseLocale() {
|
||||
assertEquals("2016-03-01", new DateMatcher(DateMatcher.DEFAULT_SANITY, Locale.GERMAN).match("01 März 2016").toString());
|
||||
assertEquals("2016-03-01", new DateMatcher(DateMatcher.DEFAULT_SANITY, Locale.GERMAN).match("1 March 2016").toString()); // always parse English
|
||||
assertEquals("2016-03-02", new DateMatcher(DateMatcher.DEFAULT_SANITY, Locale.ENGLISH, Locale.GERMAN).match("01 März 2016 to 2 March 2016").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue