Fix SoneInserter test.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 4 Dec 2014 21:39:01 +0000 (22:39 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 4 Dec 2014 21:39:01 +0000 (22:39 +0100)
src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java

index e0ff3a5..8a4bd52 100644 (file)
@@ -20,6 +20,7 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.withSettings;
 
 import java.io.IOException;
 import java.util.HashMap;
@@ -33,6 +34,7 @@ import net.pterodactylus.sone.core.event.SoneInsertAbortedEvent;
 import net.pterodactylus.sone.core.event.SoneInsertedEvent;
 import net.pterodactylus.sone.core.event.SoneInsertingEvent;
 import net.pterodactylus.sone.data.Album;
+import net.pterodactylus.sone.data.LocalSone;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.main.SonePlugin;
 
@@ -65,6 +67,7 @@ public class SoneInserterTest {
                UpdateChecker updateChecker = mock(UpdateChecker.class);
                when(core.getUpdateChecker()).thenReturn(updateChecker);
                when(core.getSone(anyString())).thenReturn(Optional.<Sone>absent());
+               when(core.getLocalSone(anyString())).thenReturn(Optional.<LocalSone>absent());
        }
 
        @Test
@@ -76,11 +79,12 @@ public class SoneInserterTest {
        }
 
        private Sone createSone(FreenetURI insertUri, String fingerprint) {
-               Sone sone = mock(Sone.class);
+               Sone sone = mock(Sone.class, withSettings().extraInterfaces(LocalSone.class));
                when(sone.getInsertUri()).thenReturn(insertUri);
                when(sone.getFingerprint()).thenReturn(fingerprint);
                when(sone.getRootAlbum()).thenReturn(mock(Album.class));
                when(core.getSone(anyString())).thenReturn(of(sone));
+               when(core.getLocalSone(anyString())).thenReturn(of((LocalSone) sone));
                return sone;
        }