episode cleanup 12 hour option: add unit test to prepare for using hours
rather than days as data structure
This commit is contained in:
parent
1bb0694403
commit
4ff5690341
@ -80,12 +80,17 @@ public class APCleanupAlgorithm extends EpisodeCleanupAlgorithm {
|
|||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
Date calcMostRecentDateForDeletion(@NonNull Date currentDate) {
|
||||||
|
return minusDays(currentDate, numberOfDaysAfterPlayback);
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private List<FeedItem> getCandidates() {
|
private List<FeedItem> getCandidates() {
|
||||||
List<FeedItem> candidates = new ArrayList<>();
|
List<FeedItem> candidates = new ArrayList<>();
|
||||||
List<FeedItem> downloadedItems = DBReader.getDownloadedItems();
|
List<FeedItem> downloadedItems = DBReader.getDownloadedItems();
|
||||||
|
|
||||||
Date mostRecentDateForDeletion = minusDays(new Date(), numberOfDaysAfterPlayback);
|
Date mostRecentDateForDeletion = calcMostRecentDateForDeletion(new Date());
|
||||||
for (FeedItem item : downloadedItems) {
|
for (FeedItem item : downloadedItems) {
|
||||||
if (item.hasMedia()
|
if (item.hasMedia()
|
||||||
&& item.getMedia().isDownloaded()
|
&& item.getMedia().isDownloaded()
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package de.danoeh.antennapod.core.storage;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class APCleanupAlgorithmTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalcMostRecentDateForDeletion() throws Exception {
|
||||||
|
APCleanupAlgorithm algo = new APCleanupAlgorithm(1.0f);
|
||||||
|
Date curDateForTest = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse("2018-11-13T14:08:56-0800");
|
||||||
|
Date resExpected = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse("2018-11-12T14:08:56-0800");
|
||||||
|
Date resActual = algo.calcMostRecentDateForDeletion(curDateForTest);
|
||||||
|
assertEquals("cutoff for retaining most recent 1 day", resExpected, resActual);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user