1 package net.pterodactylus.rhynodge.filters
3 import net.pterodactylus.rhynodge.states.FailedState
4 import net.pterodactylus.rhynodge.states.TorrentState
5 import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile
6 import org.hamcrest.MatcherAssert
7 import org.hamcrest.MatcherAssert.assertThat
8 import org.hamcrest.Matchers
9 import org.hamcrest.Matchers.equalTo
13 * Unit test for [SizeBlacklistFilter].
15 class SizeBlacklistFilterTest {
17 private val filter = SizeBlacklistFilter(listOf("123 MiB", "234 GiB"))
18 private val notMatchingTorrentFile1 = TorrentFile("The Vampire Diaries S05E05 2013 HDRip 720p-3LT0N", "123 GiB", "magnet:?xt=a", "http://", 1, 2, 3)
19 private val notMatchingTorrentFile2 = TorrentFile("The Vampire Diaries S05E05 2013 HDRip 720p-HELLRAZ0R", "123 MB", "magnet:?xt=b", "http://", 1, 2, 3)
20 private val matchingTorrentFile1 = TorrentFile("The Vampire Diaries S05E05 2013 HDRip 720p-Haggebulle", "123 MiB", "magnet:?xt=c", "http://", 1, 2, 3)
21 private val matchingTorrentFile2 = TorrentFile("The Vampire Diaries S05E05 2013 HDRip 720p-FooKaS", "234 GiB", "magnet:?xt=d", "http://", 1, 2, 3)
24 fun `filter removes the correct torrents`() {
25 val filteredState = filter.filter(TorrentState(listOf(
26 notMatchingTorrentFile1,
27 notMatchingTorrentFile2,
31 assertThat(filteredState.torrentFiles(), Matchers.containsInAnyOrder(
32 notMatchingTorrentFile1,
33 notMatchingTorrentFile2
38 fun `filter returns failed state for a failed state`() {
39 assertThat(filter.filter(FailedState()).success(), equalTo(false))