1 package net.pterodactylus.sone.core;
3 import static org.mockito.Matchers.eq;
4 import static org.mockito.Mockito.mock;
5 import static org.mockito.Mockito.verify;
6 import static org.mockito.Mockito.when;
8 import net.pterodactylus.sone.core.SoneDownloader.FetchSone;
9 import net.pterodactylus.sone.core.SoneDownloader.FetchSoneWithUri;
10 import net.pterodactylus.sone.data.Sone;
12 import freenet.keys.FreenetURI;
14 import org.junit.Test;
17 * Unit test for {@link SoneDownloader} and its subclasses.
19 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
21 public class SoneDownloaderTest {
24 public void fetchSoneWithUriDownloadsSoneWithUri() {
25 SoneDownloader soneDownloader = mock(SoneDownloader.class);
26 Sone sone = mock(Sone.class);
27 FreenetURI soneUri = mock(FreenetURI.class);
28 when(sone.getRequestUri()).thenReturn(soneUri);
29 FetchSoneWithUri fetchSoneWithUri = soneDownloader.new FetchSoneWithUri(sone);
30 fetchSoneWithUri.run();
31 verify(soneDownloader).fetchSone(eq(sone), eq(soneUri));
35 public void fetchSoneDownloadsSone() {
36 SoneDownloader soneDownloader = mock(SoneDownloader.class);
37 Sone sone = mock(Sone.class);
38 FetchSone fetchSone = soneDownloader.new FetchSone(sone);
40 verify(soneDownloader).fetchSone(eq(sone));