Distinguish between local and “normal” Sones in FCP handler.
[Sone.git] / src / test / java / net / pterodactylus / sone / fcp / UnlockSoneCommandTest.java
index b966b19..f825dbe 100644 (file)
@@ -20,13 +20,14 @@ package net.pterodactylus.sone.fcp;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.data.LocalSone;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder;
 import net.pterodactylus.sone.freenet.fcp.Command.Response;
@@ -46,12 +47,12 @@ public class UnlockSoneCommandTest {
 
        @Test
        public void testUnlockingALocalSone() throws FcpException {
-               Sone localSone = mock(Sone.class);
+               LocalSone localSone = mock(LocalSone.class);
                when(localSone.getId()).thenReturn("LocalSone");
                when(localSone.isLocal()).thenReturn(true);
                Core core = mock(Core.class);
-               when(core.getSone(eq("LocalSone"))).thenReturn(Optional.of(localSone));
-               when(core.getLocalSone(eq("LocalSone"), anyBoolean())).thenReturn(localSone);
+               when(core.getSone(eq("LocalSone"))).thenReturn(Optional.<Sone>of(localSone));
+               when(core.getLocalSone(eq("LocalSone"))).thenReturn(Optional.of(localSone));
                SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "LocalSone").get();
 
                UnlockSoneCommand unlockSoneCommand = new UnlockSoneCommand(core);
@@ -68,6 +69,7 @@ public class UnlockSoneCommandTest {
        public void testUnlockingARemoteSone() throws FcpException {
                Sone removeSone = mock(Sone.class);
                Core core = mock(Core.class);
+               when(core.getLocalSone(anyString())).thenReturn(Optional.<LocalSone>absent());
                when(core.getSone(eq("RemoteSone"))).thenReturn(Optional.of(removeSone));
                SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "RemoteSone").get();