21d01f63db36110a87e255044a3b6e341e57c44a
[Sone.git] / src / test / java / net / pterodactylus / sone / core / SoneDownloaderTest.java
1 package net.pterodactylus.sone.core;
2
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;
7
8 import net.pterodactylus.sone.core.SoneDownloader.FetchSone;
9 import net.pterodactylus.sone.core.SoneDownloader.FetchSoneWithUri;
10 import net.pterodactylus.sone.data.Sone;
11
12 import freenet.keys.FreenetURI;
13
14 import org.junit.Test;
15
16 /**
17  * Unit test for {@link SoneDownloader} and its subclasses.
18  *
19  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
20  */
21 public class SoneDownloaderTest {
22
23         @Test
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));
32         }
33
34         @Test
35         public void fetchSoneDownloadsSone() {
36                 SoneDownloader soneDownloader = mock(SoneDownloader.class);
37                 Sone sone = mock(Sone.class);
38                 FetchSone fetchSone = soneDownloader.new FetchSone(sone);
39                 fetchSone.run();
40                 verify(soneDownloader).fetchSone(eq(sone));
41         }
42
43 }