X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FLockSoneCommandTest.java;h=d2adbd7117b6440ca4ac3e8e4bc5c358e6113fa0;hb=914d5522692e7714ba5bdefb002fedc8e293f5fc;hp=3789d08b7a0f7076ae38fc4b68246c5e520351b1;hpb=e351d4aca7c80b6a9e7ddc9775995ce829e51031;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..d2adbd7 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java @@ -1,5 +1,5 @@ /* - * Sone - LockSoneCommandTest.java - Copyright © 2013 David Roden + * Sone - LockSoneCommandTest.java - Copyright © 2013–2016 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,8 +20,7 @@ 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.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -34,6 +33,7 @@ import net.pterodactylus.sone.freenet.fcp.FcpException; import freenet.support.SimpleFieldSet; +import com.google.common.base.Optional; import org.junit.Test; /** @@ -47,13 +47,14 @@ public class LockSoneCommandTest { public void testLockingALocalSone() throws FcpException { Sone localSone = mock(Sone.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(localSone); SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "LocalSone").get(); LockSoneCommand lockSoneCommand = new LockSoneCommand(core); - Response response = lockSoneCommand.execute(fields, null, null); + Response response = lockSoneCommand.execute(fields); verify(core).lockSone(eq(localSone)); assertThat(response, notNullValue()); @@ -66,11 +67,11 @@ public class LockSoneCommandTest { public void testLockingARemoteSone() throws FcpException { Sone removeSone = mock(Sone.class); Core core = mock(Core.class); - when(core.getSone(eq("RemoteSone"), anyBoolean())).thenReturn(removeSone); + when(core.getSone(eq("RemoteSone"))).thenReturn(Optional.of(removeSone)); SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "RemoteSone").get(); LockSoneCommand lockSoneCommand = new LockSoneCommand(core); - lockSoneCommand.execute(fields, null, null); + lockSoneCommand.execute(fields); } @Test(expected = FcpException.class) @@ -79,7 +80,7 @@ public class LockSoneCommandTest { SimpleFieldSet fields = new SimpleFieldSetBuilder().get(); LockSoneCommand lockSoneCommand = new LockSoneCommand(core); - lockSoneCommand.execute(fields, null, null); + lockSoneCommand.execute(fields); } }