diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-04-05 19:20:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 19:20:27 +0200 |
commit | 92ab575b150ab49ca85e0ac994558142e49c9e68 (patch) | |
tree | 422dcd76895a4ba06ed02723ff61351435c0fe49 /core/src/test/java | |
parent | 2143ab135182434911d4554a8ef08115eaa0d2d0 (diff) | |
download | AntennaPod-92ab575b150ab49ca85e0ac994558142e49c9e68.zip |
Delete core module (#7060)
Diffstat (limited to 'core/src/test/java')
4 files changed, 0 insertions, 648 deletions
diff --git a/core/src/test/java/android/util/Log.java b/core/src/test/java/android/util/Log.java deleted file mode 100644 index a65bc80fa..000000000 --- a/core/src/test/java/android/util/Log.java +++ /dev/null @@ -1,246 +0,0 @@ -package android.util; - -import java.io.PrintWriter; -import java.io.StringWriter; - -/** - * A stub for {@link android.util.Log} to be used in unit tests. - * - * It outputs the log statements to standard error. - */ -public final class Log { - - /** - * Priority constant for the println method; use Log.v. - */ - public static final int VERBOSE = 2; - - /** - * Priority constant for the println method; use Log.d. - */ - public static final int DEBUG = 3; - - /** - * Priority constant for the println method; use Log.i. - */ - public static final int INFO = 4; - - /** - * Priority constant for the println method; use Log.w. - */ - public static final int WARN = 5; - - /** - * Priority constant for the println method; use Log.e. - */ - public static final int ERROR = 6; - - /** - * Priority constant for the println method. - */ - public static final int ASSERT = 7; - - private Log() { - } - - /** - * Send a {@link #VERBOSE} log message. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - */ - public static int v(String tag, String msg) { - return println_native(LOG_ID_MAIN, VERBOSE, tag, msg); - } - - /** - * Send a {@link #VERBOSE} log message and log the exception. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - * @param tr An exception to log - */ - public static int v(String tag, String msg, Throwable tr) { - return printlns(LOG_ID_MAIN, VERBOSE, tag, msg, tr); - } - - /** - * Send a {@link #DEBUG} log message. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - */ - public static int d(String tag, String msg) { - return println_native(LOG_ID_MAIN, DEBUG, tag, msg); - } - - /** - * Send a {@link #DEBUG} log message and log the exception. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - * @param tr An exception to log - */ - public static int d(String tag, String msg, Throwable tr) { - return printlns(LOG_ID_MAIN, DEBUG, tag, msg, tr); - } - - /** - * Send an {@link #INFO} log message. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - */ - public static int i(String tag, String msg) { - return println_native(LOG_ID_MAIN, INFO, tag, msg); - } - - /** - * Send a {@link #INFO} log message and log the exception. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - * @param tr An exception to log - */ - public static int i(String tag, String msg, Throwable tr) { - return printlns(LOG_ID_MAIN, INFO, tag, msg, tr); - } - - /** - * Send a {@link #WARN} log message. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - */ - public static int w(String tag, String msg) { - return println_native(LOG_ID_MAIN, WARN, tag, msg); - } - - /** - * Send a {@link #WARN} log message and log the exception. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - * @param tr An exception to log - */ - public static int w(String tag, String msg, Throwable tr) { - return printlns(LOG_ID_MAIN, WARN, tag, msg, tr); - } - - /** - * Checks to see whether or not a log for the specified tag is loggable at the specified level. - * - * @return true in all cases (for unit test environment) - */ - public static boolean isLoggable(String tag, int level) { - return true; - } - - /* - * Send a {@link #WARN} log message and log the exception. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param tr An exception to log - */ - public static int w(String tag, Throwable tr) { - return printlns(LOG_ID_MAIN, WARN, tag, "", tr); - } - - /** - * Send an {@link #ERROR} log message. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - */ - public static int e(String tag, String msg) { - return println_native(LOG_ID_MAIN, ERROR, tag, msg); - } - - /** - * Send a {@link #ERROR} log message and log the exception. - * @param tag Used to identify the source of a log message. It usually identifies - * the class or activity where the log call occurs. - * @param msg The message you would like logged. - * @param tr An exception to log - */ - public static int e(String tag, String msg, Throwable tr) { - return printlns(LOG_ID_MAIN, ERROR, tag, msg, tr); - } - - /** - * What a Terrible Failure: Report a condition that should never happen. - * The error will always be logged at level ASSERT with the call stack. - * Depending on system configuration, a report may be added to the - * {@link android.os.DropBoxManager} and/or the process may be terminated - * immediately with an error dialog. - * @param tag Used to identify the source of a log message. - * @param msg The message you would like logged. - */ - public static int wtf(String tag, String msg) { - return wtf(LOG_ID_MAIN, tag, msg, null, false, false); - } - - /** - * Like {@link #wtf(String, String)}, but also writes to the log the full - * call stack. - * @hide - */ - public static int wtfStack(String tag, String msg) { - return wtf(LOG_ID_MAIN, tag, msg, null, true, false); - } - - /** - * What a Terrible Failure: Report an exception that should never happen. - * Similar to {@link #wtf(String, String)}, with an exception to log. - * @param tag Used to identify the source of a log message. - * @param tr An exception to log. - */ - public static int wtf(String tag, Throwable tr) { - return wtf(LOG_ID_MAIN, tag, tr.getMessage(), tr, false, false); - } - - /** - * What a Terrible Failure: Report an exception that should never happen. - * Similar to {@link #wtf(String, Throwable)}, with a message as well. - * @param tag Used to identify the source of a log message. - * @param msg The message you would like logged. - * @param tr An exception to log. May be null. - */ - public static int wtf(String tag, String msg, Throwable tr) { - return wtf(LOG_ID_MAIN, tag, msg, tr, false, false); - } - - /** - * Priority Constant for wtf. - * Added for this custom Log implementation, not in android sources. - */ - private static final int WTF = 8; - - static int wtf(int logId, String tag, String msg, Throwable tr, boolean localStack, - boolean system) { - return printlns(LOG_ID_MAIN, WTF, tag, msg, tr); - } - - private static final int LOG_ID_MAIN = 0; - - private static final String[] PRIORITY_ABBREV = { "0", "1", "V", "D", "I", "W", "E", "A", "WTF" }; - - private static int println_native(int bufID, int priority, String tag, String msg) { - String res = PRIORITY_ABBREV[priority] + "/" + tag + " " + msg + System.lineSeparator(); - System.err.print(res); - return res.length(); - } - - private static int printlns(int bufID, int priority, String tag, String msg, - Throwable tr) { - StringWriter trSW = new StringWriter(); - if (tr != null) { - trSW.append(" , Exception: "); - PrintWriter trPW = new PrintWriter(trSW); - tr.printStackTrace(trPW); - trPW.flush(); - } - return println_native(bufID, priority, tag, msg + trSW.toString()); - } - -} diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java deleted file mode 100644 index df9617ab4..000000000 --- a/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java +++ /dev/null @@ -1,105 +0,0 @@ -package de.danoeh.antennapod.core.util; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.model.feed.FeedItem; - -import static org.junit.Assert.assertEquals; - -@RunWith(Parameterized.class) -public class FeedItemUtilTest { - private static final String FEED_LINK = "http://example.com"; - private static final String ITEM_LINK = "http://example.com/feedItem1"; - - private final String msg; - private final String feedLink; - private final String itemLink; - private final String expected; - - @Parameters - public static Collection<Object[]> data() { - return Arrays.asList(new Object[][]{ - {"average", FEED_LINK, ITEM_LINK, ITEM_LINK}, - {"null item link - fallback to feed", FEED_LINK, null, FEED_LINK}, - {"empty item link - same as null", FEED_LINK, "", FEED_LINK}, - {"blank item link - same as null", FEED_LINK, " ", FEED_LINK}, - {"fallback, but feed link is null too", null, null, null}, - {"fallback - but empty feed link - same as null", "", null, null}, - {"fallback - but blank feed link - same as null", " ", null, null} - }); - } - - public FeedItemUtilTest(String msg, String feedLink, String itemLink, String expected) { - this.msg = msg; - this.feedLink = feedLink; - this.itemLink = itemLink; - this.expected = expected; - } - - - // Test the getIds() method - @Test - public void testGetIds() { - List<FeedItem> feedItemsList = new ArrayList<FeedItem>(5); - List<Integer> idList = new ArrayList<Integer>(); - - idList.add(980); - idList.add(324); - idList.add(226); - idList.add(164); - idList.add(854); - - for (int i = 0; i < 5; i++) { - FeedItem item = createFeedItem(feedLink, itemLink); - item.setId(idList.get(i)); - feedItemsList.add(item); - } - - long[] actual = FeedItemUtil.getIds(feedItemsList); - - // covers edge case for getIds() method - List<FeedItem> emptyList = new ArrayList<FeedItem>(); - long[] testEmptyList = FeedItemUtil.getIds(emptyList); - assertEquals(msg, 0, testEmptyList.length); - assertEquals(msg, 980, actual[0]); - assertEquals(msg, 324, actual[1]); - assertEquals(msg, 226, actual[2]); - assertEquals(msg, 164, actual[3]); - assertEquals(msg, 854, actual[4]); - - } - - // Tests the Null value for getLinkWithFallback() method - @Test - public void testLinkWithFallbackNullValue() { - String actual = FeedItemUtil.getLinkWithFallback(null); - assertEquals(msg, null, actual); - } - - - @Test - public void testLinkWithFallback() { - String actual = FeedItemUtil.getLinkWithFallback(createFeedItem(feedLink, itemLink)); - assertEquals(msg, expected, actual); - } - - private static FeedItem createFeedItem(String feedLink, String itemLink) { - Feed feed = new Feed("http://example.com/feed", null); - feed.setLink(feedLink); - FeedItem feedItem = new FeedItem(); - feedItem.setLink(itemLink); - feedItem.setFeed(feed); - feed.setItems(Collections.singletonList(feedItem)); - return feedItem; - } -} diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/ReleaseScheduleGuesserRealWorldTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/ReleaseScheduleGuesserRealWorldTest.java deleted file mode 100644 index dd3cd763b..000000000 --- a/core/src/test/java/de/danoeh/antennapod/core/util/ReleaseScheduleGuesserRealWorldTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package de.danoeh.antennapod.core.util; - -import de.danoeh.antennapod.parser.feed.util.DateUtils; -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -import java.io.InputStream; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.Locale; - -import static org.junit.Assert.assertTrue; - -public class ReleaseScheduleGuesserRealWorldTest { - private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ROOT); - - private void printHistogram(int[] histogram) { - int max = 0; - for (int x : histogram) { - max = Math.max(x, max); - } - for (int row = 8; row >= 0; row--) { - for (int x : histogram) { - System.out.print((x > (double) row * (max / 9.0)) ? "#" : " "); - } - System.out.println(); - } - for (int col = 0; col < histogram.length; col++) { - System.out.print(((col % 5) == 0) ? "|" : " "); - } - System.out.println(); - } - - @Test - public void testRealWorld() throws Exception { - InputStream inputStream = getClass().getClassLoader().getResource("release_dates.csv").openStream(); - int numCorrectDay = 0; - int numFoundSchedule = 0; - int numFoundScheduleAndCorrectDay = 0; - int num3hoursCorrect = 0; - int numOffByMoreThan2days = 0; - int[] histogram = new int[101]; - - String csv = IOUtils.toString(inputStream, "UTF-8"); - String[] lines = csv.split("\n"); - int totalPodcasts = 0; - int lineNr = 0; - for (String line : lines) { - lineNr++; - String[] dates = line.split(";"); - List<Date> releaseDates = new ArrayList<>(); - for (String date : dates) { - releaseDates.add(DateUtils.parse(date)); - } - if (releaseDates.size() <= 3) { - continue; - } - totalPodcasts++; - Collections.sort(releaseDates, Comparator.comparingLong(Date::getTime)); - Date dateActual = releaseDates.get(releaseDates.size() - 1); - // Remove most recent one and possible duplicates of episodes on the same day - do { - releaseDates = releaseDates.subList(0, releaseDates.size() - 1); - } while (releaseDates.get(releaseDates.size() - 1).getTime() - > dateActual.getTime() - 30 * ReleaseScheduleGuesser.ONE_MINUTE); - ReleaseScheduleGuesser.Guess guess = ReleaseScheduleGuesser.performGuess(releaseDates); - - final boolean is3hoursClose = Math.abs(dateActual.getTime() - guess.nextExpectedDate.getTime()) - < 3 * ReleaseScheduleGuesser.ONE_HOUR; - System.out.println(lineNr + " guessed: " + DATE_FORMAT.format(guess.nextExpectedDate) - + ", actual: " + DATE_FORMAT.format(dateActual) - + " " + guess.schedule.name() + (is3hoursClose ? " ✔" : "")); - long deltaTime = dateActual.getTime() - guess.nextExpectedDate.getTime(); - int histogramClass = (int) Math.max(0, Math.min(100, deltaTime / ReleaseScheduleGuesser.ONE_HOUR + 50)); - histogram[histogramClass]++; - boolean foundSchedule = guess.schedule != ReleaseScheduleGuesser.Schedule.UNKNOWN; - if (foundSchedule) { - numFoundSchedule++; - } - Calendar calendarExpected = new GregorianCalendar(); - calendarExpected.setTime(dateActual); - Calendar calendarGuessed = new GregorianCalendar(); - calendarGuessed.setTime(guess.nextExpectedDate); - if (calendarExpected.get(Calendar.DAY_OF_YEAR) == calendarGuessed.get(Calendar.DAY_OF_YEAR)) { - numCorrectDay++; - if (foundSchedule) { - numFoundScheduleAndCorrectDay++; - } - } - if (Math.abs(deltaTime) > 2 * ReleaseScheduleGuesser.ONE_DAY) { - numOffByMoreThan2days++; - } - if (is3hoursClose) { - num3hoursCorrect++; - } - } - - System.out.println("Podcasts tested: " + totalPodcasts); - - double schedulePercentage = 100.0 * numFoundSchedule / totalPodcasts; - System.out.println("Found schedule: " + schedulePercentage); - double offByLessThan3HoursPercentage = 100.0 * num3hoursCorrect / totalPodcasts; - System.out.println("Off by less than 3 hours: " + offByLessThan3HoursPercentage); - double scheduleAndCorrectDayPercentage = 100.0 * numFoundScheduleAndCorrectDay / numFoundSchedule; - System.out.println("Correct day when schedule found: " + scheduleAndCorrectDayPercentage); - double correctDayPercentage = 100.0 * numCorrectDay / totalPodcasts; - System.out.println("Correct day: " + correctDayPercentage); - double offByLessThan2daysPercentage = 100.0 * (totalPodcasts - numOffByMoreThan2days) / totalPodcasts; - System.out.println("Off by less than 2 days: " + offByLessThan2daysPercentage); - - assertTrue(schedulePercentage > 80); - assertTrue(offByLessThan3HoursPercentage > 55); - assertTrue(scheduleAndCorrectDayPercentage > 75); - assertTrue(correctDayPercentage > 60); - assertTrue(offByLessThan2daysPercentage > 75); - - printHistogram(histogram); - } -}
\ No newline at end of file diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/ReleaseScheduleGuesserTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/ReleaseScheduleGuesserTest.java deleted file mode 100644 index aaad125c9..000000000 --- a/core/src/test/java/de/danoeh/antennapod/core/util/ReleaseScheduleGuesserTest.java +++ /dev/null @@ -1,172 +0,0 @@ -package de.danoeh.antennapod.core.util; - -import org.junit.Test; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.Locale; - -import static de.danoeh.antennapod.core.util.ReleaseScheduleGuesser.ONE_DAY; -import static de.danoeh.antennapod.core.util.ReleaseScheduleGuesser.ONE_HOUR; -import static de.danoeh.antennapod.core.util.ReleaseScheduleGuesser.ONE_MINUTE; -import static de.danoeh.antennapod.core.util.ReleaseScheduleGuesser.performGuess; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class ReleaseScheduleGuesserTest { - private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ROOT); - - private Date makeDate(String dateStr) { - try { - return DATE_FORMAT.parse(dateStr); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - private void assertClose(Date expected, Date actual, long tolerance) { - assertTrue("Date should differ at most " + tolerance / 60000 + " minutes from " - + DATE_FORMAT.format(expected) + ", but is " + DATE_FORMAT.format(actual), - Math.abs(expected.getTime() - actual.getTime()) < tolerance); - } - - @Test - public void testEdgeCases() { - ArrayList<Date> releaseDates = new ArrayList<>(); - assertEquals(ReleaseScheduleGuesser.Schedule.UNKNOWN, performGuess(releaseDates).schedule); - releaseDates.add(makeDate("2024-01-01 16:30")); - assertEquals(ReleaseScheduleGuesser.Schedule.UNKNOWN, performGuess(releaseDates).schedule); - } - - @Test - public void testDaily() { - ArrayList<Date> releaseDates = new ArrayList<>(); - releaseDates.add(makeDate("2024-01-01 16:30")); // Monday - releaseDates.add(makeDate("2024-01-02 16:25")); - releaseDates.add(makeDate("2024-01-03 16:35")); - releaseDates.add(makeDate("2024-01-04 16:40")); - releaseDates.add(makeDate("2024-01-05 16:20")); - releaseDates.add(makeDate("2024-01-06 16:10")); - releaseDates.add(makeDate("2024-01-07 16:32")); // Sunday - - // Next day - ReleaseScheduleGuesser.Guess guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.DAILY, guess.schedule); - assertClose(makeDate("2024-01-08 16:30"), guess.nextExpectedDate, 10 * ONE_MINUTE); - - // One-off early release - releaseDates.add(makeDate("2024-01-08 10:00")); - guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.DAILY, guess.schedule); - assertClose(makeDate("2024-01-09 16:30"), guess.nextExpectedDate, 10 * ONE_MINUTE); - } - - @Test - public void testWeekdays() { - ArrayList<Date> releaseDates = new ArrayList<>(); - releaseDates.add(makeDate("2024-01-01 16:30")); // Monday - releaseDates.add(makeDate("2024-01-02 16:25")); - releaseDates.add(makeDate("2024-01-03 16:35")); - releaseDates.add(makeDate("2024-01-04 16:40")); - releaseDates.add(makeDate("2024-01-05 16:20")); // Friday - releaseDates.add(makeDate("2024-01-08 16:20")); // Monday - releaseDates.add(makeDate("2024-01-09 16:30")); - releaseDates.add(makeDate("2024-01-10 16:40")); - releaseDates.add(makeDate("2024-01-11 16:45")); // Thursday - - // Next day - ReleaseScheduleGuesser.Guess guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.WEEKDAYS, guess.schedule); - assertClose(makeDate("2024-01-12 16:30"), guess.nextExpectedDate, ONE_HOUR); - - // After weekend - releaseDates.add(makeDate("2024-01-12 16:30")); // Friday - guess = performGuess(releaseDates); - assertClose(makeDate("2024-01-15 16:30"), guess.nextExpectedDate, ONE_HOUR); - } - - @Test - public void testWeekly() { - ArrayList<Date> releaseDates = new ArrayList<>(); - releaseDates.add(makeDate("2024-01-07 16:30")); // Sunday - releaseDates.add(makeDate("2024-01-14 16:25")); - releaseDates.add(makeDate("2024-01-21 14:25")); - releaseDates.add(makeDate("2024-01-28 16:15")); - - // Next week - ReleaseScheduleGuesser.Guess guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.WEEKLY, guess.schedule); - assertClose(makeDate("2024-02-04 16:30"), guess.nextExpectedDate, 2 * ONE_HOUR); - - // One-off early release - releaseDates.add(makeDate("2024-02-02 16:35")); - guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.WEEKLY, guess.schedule); - assertClose(makeDate("2024-02-11 16:30"), guess.nextExpectedDate, 2 * ONE_HOUR); - - // One-off late release - releaseDates.add(makeDate("2024-02-13 16:35")); - guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.WEEKLY, guess.schedule); - assertClose(makeDate("2024-02-18 16:30"), guess.nextExpectedDate, 2 * ONE_HOUR); - } - - @Test - public void testMonthly() { - ArrayList<Date> releaseDates = new ArrayList<>(); - releaseDates.add(makeDate("2024-01-01 16:30")); - releaseDates.add(makeDate("2024-02-01 16:30")); - releaseDates.add(makeDate("2024-03-01 16:30")); - releaseDates.add(makeDate("2024-04-01 16:30")); - - // Next month - ReleaseScheduleGuesser.Guess guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.MONTHLY, guess.schedule); - assertClose(makeDate("2024-05-01 16:30"), guess.nextExpectedDate, 10 * ONE_HOUR); - - // One-off early release - releaseDates.add(makeDate("2024-04-30 16:30")); - guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.MONTHLY, guess.schedule); - assertClose(makeDate("2024-06-01 16:30"), guess.nextExpectedDate, 10 * ONE_HOUR); - - // One-off late release - releaseDates.remove(releaseDates.size() - 1); - releaseDates.add(makeDate("2024-05-13 16:30")); - guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.MONTHLY, guess.schedule); - assertClose(makeDate("2024-06-01 16:30"), guess.nextExpectedDate, 10 * ONE_HOUR); - } - - @Test - public void testFourweekly() { - ArrayList<Date> releaseDates = new ArrayList<>(); - releaseDates.add(makeDate("2024-01-01 16:30")); - releaseDates.add(makeDate("2024-01-29 16:30")); - releaseDates.add(makeDate("2024-02-26 16:30")); - releaseDates.add(makeDate("2024-03-25 16:30")); - - // 4 weeks later - ReleaseScheduleGuesser.Guess guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.FOURWEEKLY, guess.schedule); - assertClose(makeDate("2024-04-22 16:30"), guess.nextExpectedDate, 10 * ONE_HOUR); - } - - @Test - public void testUnknown() { - ArrayList<Date> releaseDates = new ArrayList<>(); - releaseDates.add(makeDate("2024-01-01 16:30")); - releaseDates.add(makeDate("2024-01-03 16:30")); - releaseDates.add(makeDate("2024-01-03 16:31")); - releaseDates.add(makeDate("2024-01-04 16:30")); - releaseDates.add(makeDate("2024-01-04 16:31")); - releaseDates.add(makeDate("2024-01-07 16:30")); - releaseDates.add(makeDate("2024-01-07 16:31")); - releaseDates.add(makeDate("2024-01-10 16:30")); - ReleaseScheduleGuesser.Guess guess = performGuess(releaseDates); - assertEquals(ReleaseScheduleGuesser.Schedule.UNKNOWN, guess.schedule); - assertClose(makeDate("2024-01-12 16:30"), guess.nextExpectedDate, 2 * ONE_DAY); - } -}
\ No newline at end of file |