From 186808b695fbd1f5c3cafe4ee2732749f9bf47a1 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 21 Oct 2016 03:48:33 +0800 Subject: [PATCH] Update unit tests --- source/net/filebot/similarity/EpisodeMetrics.java | 2 +- test/net/filebot/format/ExpressionFormatTest.java | 4 ++-- test/net/filebot/similarity/EpisodeMetricsTest.java | 6 +++--- test/net/filebot/similarity/SeasonEpisodeMatcherTest.java | 4 +--- test/net/filebot/ui/SupportDialogTest.java | 8 ++++---- test/net/filebot/web/TMDbClientTest.java | 4 ++-- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/source/net/filebot/similarity/EpisodeMetrics.java b/source/net/filebot/similarity/EpisodeMetrics.java index 8507ff10..0a8eeb07 100644 --- a/source/net/filebot/similarity/EpisodeMetrics.java +++ b/source/net/filebot/similarity/EpisodeMetrics.java @@ -217,7 +217,7 @@ public enum EpisodeMetrics implements SimilarityMetric { Episode e = (Episode) object; Stream primaryNames = Stream.of(e.getSeriesName(), e.getTitle()); - Stream aliasNames = e.getSeriesInfo().getAliasNames().stream().limit(MAX_FIELDS); + Stream aliasNames = e.getSeriesInfo() == null ? Stream.empty() : e.getSeriesInfo().getAliasNames().stream().limit(MAX_FIELDS); Stream names = Stream.concat(primaryNames, aliasNames).filter(s -> s != null && s.length() > 0).map(Normalization::removeTrailingBrackets).distinct(); return copyOf(names.limit(MAX_FIELDS).toArray(), MAX_FIELDS); diff --git a/test/net/filebot/format/ExpressionFormatTest.java b/test/net/filebot/format/ExpressionFormatTest.java index 5f1a1c1f..9aaa73ff 100644 --- a/test/net/filebot/format/ExpressionFormatTest.java +++ b/test/net/filebot/format/ExpressionFormatTest.java @@ -100,7 +100,7 @@ public class ExpressionFormatTest { format.format(new SimpleBindings()); // check message - assertEquals("Binding \"xyz\": undefined", format.suppressed().getMessage()); + assertEquals("Suppressed: Binding \"xyz\": undefined", format.suppressed().getMessage()); } @Test @@ -109,7 +109,7 @@ public class ExpressionFormatTest { format.format("test"); // check message - assertEquals("Binding \"xyz\": undefined", format.suppressed().getMessage()); + assertEquals("Suppressed: Binding \"xyz\": undefined", format.suppressed().getMessage()); } protected static class TestScriptFormat extends ExpressionFormat { diff --git a/test/net/filebot/similarity/EpisodeMetricsTest.java b/test/net/filebot/similarity/EpisodeMetricsTest.java index b1edb258..450c9121 100644 --- a/test/net/filebot/similarity/EpisodeMetricsTest.java +++ b/test/net/filebot/similarity/EpisodeMetricsTest.java @@ -17,12 +17,12 @@ public class EpisodeMetricsTest { @Test public void substringMetrics() { Episode eY1T1 = new Episode("Doctor Who", 1, 1, "Rose"); - // Episode eY2T2 = new Episode("Doctor Who", new Date(1963, 0, 0), 1, 1, "An Unearthly Child"); + File fY1T1 = new File("Doctor Who (2005)/Doctor Who - 1x01 - Rose"); File fY2T2 = new File("Doctor Who (1963)/Doctor Who - 1x01 - An Unearthly Child"); - assertEquals(3.0 / 3, SubstringFields.getSimilarity(eY1T1, fY1T1), 0.01); - assertEquals(2.0 / 3, SubstringFields.getSimilarity(eY1T1, fY2T2), 0.01); + assertEquals(0.5, SubstringFields.getSimilarity(eY1T1, fY1T1), 0.1); + assertEquals(0.5, SubstringFields.getSimilarity(eY1T1, fY2T2), 0.1); } @Test diff --git a/test/net/filebot/similarity/SeasonEpisodeMatcherTest.java b/test/net/filebot/similarity/SeasonEpisodeMatcherTest.java index ebc541a9..5e960b8e 100644 --- a/test/net/filebot/similarity/SeasonEpisodeMatcherTest.java +++ b/test/net/filebot/similarity/SeasonEpisodeMatcherTest.java @@ -33,6 +33,7 @@ public class SeasonEpisodeMatcherTest { assertEquals("[1x01, 1x02]", matcher.match("1x01-02").toString()); assertEquals("[3x11, 3x12, 3x13, 3x14]", matcher.match("03x11-03x12-03x13-03x14").toString()); assertEquals("[9x09, 9x10]", matcher.match("09x09-09x10").toString()); + assertEquals("[2x17, 2x18]", matcher.match("[Season 2 Episode 17-18]").toString()); } @Test @@ -85,9 +86,6 @@ public class SeasonEpisodeMatcherTest { // test 4-digit assertEquals(asList(new SxE(23, 21)), matcher.match("the.simpsons.2321.hdtv-lol")); - - // test Num101_SUBSTRING - assertEquals(asList(new SxE(4, 07)), matcher.match("TWalkingDead4071080p")); } @Test diff --git a/test/net/filebot/ui/SupportDialogTest.java b/test/net/filebot/ui/SupportDialogTest.java index f53d3640..d788cfce 100644 --- a/test/net/filebot/ui/SupportDialogTest.java +++ b/test/net/filebot/ui/SupportDialogTest.java @@ -10,14 +10,14 @@ public class SupportDialogTest { @Test public void feelingLucky() { - assertTrue(SupportDialog.AppStoreReview.feelingLucky(2000, 2000, 500, 400, 0)); + assertTrue(SupportDialog.AppStoreReview.feelingLucky(2000, 2000, 500, -1, 0)); assertFalse(SupportDialog.AppStoreReview.feelingLucky(2000, 2000, 400, 400, 1)); - assertTrue(SupportDialog.Donation.feelingLucky(2000, 2000, 400, 400, 0)); - assertFalse(SupportDialog.Donation.feelingLucky(100, 100, 400, 400, 0)); + assertTrue(SupportDialog.Donation.feelingLucky(2000, 2000, 400, -1, 0)); + assertFalse(SupportDialog.Donation.feelingLucky(100, 100, 400, -1, 0)); assertFalse(SupportDialog.Donation.feelingLucky(2000, 2000, 400, 400, 1)); - assertTrue(IntStream.range(0, 100).anyMatch(i -> SupportDialog.Donation.feelingLucky(0, 5000, 400, 400, 0))); + assertTrue(IntStream.range(0, 100).anyMatch(i -> SupportDialog.Donation.feelingLucky(0, 5000, 400, -1, 0))); assertFalse(IntStream.range(0, 100).anyMatch(i -> SupportDialog.Donation.feelingLucky(0, 5000, 400, 400, 2))); } diff --git a/test/net/filebot/web/TMDbClientTest.java b/test/net/filebot/web/TMDbClientTest.java index ab7f6e17..8092c8a0 100644 --- a/test/net/filebot/web/TMDbClientTest.java +++ b/test/net/filebot/web/TMDbClientTest.java @@ -128,9 +128,9 @@ public class TMDbClientTest { public void discoverPeriod() throws Exception { Movie m = db.discover(LocalDate.parse("2014-09-15"), LocalDate.parse("2014-10-22"), Locale.ENGLISH).get(0); - assertEquals("Big Hero 6", m.getName()); + assertEquals("John Wick", m.getName()); assertEquals(2014, m.getYear()); - assertEquals(177572, m.getTmdbId()); + assertEquals(245891, m.getTmdbId()); } @Test