X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FLockSoneCommandTest.java;h=71326378feeac219e3b304feb85a15ca4f6482d3;hb=30ef483c663ded175b66b50b652a0497e04bd493;hp=3789d08b7a0f7076ae38fc4b68246c5e520351b1;hpb=f65328fb92d16e568b869bf5f2771dd4114d8abc;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java index 3789d08..7132637 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java @@ -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; @@ -34,6 +35,7 @@ import net.pterodactylus.sone.freenet.fcp.FcpException; import freenet.support.SimpleFieldSet; +import com.google.common.base.Optional; import org.junit.Test; /** @@ -45,11 +47,12 @@ public class LockSoneCommandTest { @Test public void testLockingALocalSone() 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"), anyBoolean())).thenReturn(localSone); - when(core.getLocalSone(eq("LocalSone"), anyBoolean())).thenReturn(localSone); + when(core.getSone(eq("LocalSone"))).thenReturn(Optional.of(localSone)); + when(core.getLocalSone(eq("LocalSone"))).thenReturn(Optional.of(localSone)); SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "LocalSone").get(); LockSoneCommand lockSoneCommand = new LockSoneCommand(core); @@ -64,9 +67,10 @@ public class LockSoneCommandTest { @Test(expected = FcpException.class) public void testLockingARemoteSone() throws FcpException { - Sone removeSone = mock(Sone.class); + Sone remoteSone = mock(Sone.class); Core core = mock(Core.class); - when(core.getSone(eq("RemoteSone"), anyBoolean())).thenReturn(removeSone); + when(core.getLocalSone(anyString())).thenReturn(Optional.absent()); + when(core.getSone(eq("RemoteSone"))).thenReturn(Optional.of(remoteSone)); SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "RemoteSone").get(); LockSoneCommand lockSoneCommand = new LockSoneCommand(core);