X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FLockSoneCommandTest.java;h=e4bbeec69194836bc3a67d8b21fef4a3062c46c7;hb=2d37242d19f2e726cd402b99f935a0eba282f630;hp=ae1993a900ec291926d5099db75c2beabe33d5d1;hpb=6f019de1d4d9742981d851ac3c9097cca8bff58e;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 ae1993a..e4bbeec 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java @@ -17,10 +17,10 @@ package net.pterodactylus.sone.fcp; +import static com.google.common.base.Optional.of; +import static net.pterodactylus.sone.Verifiers.verifyAnswer; 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.Mockito.mock; import static org.mockito.Mockito.verify; @@ -34,7 +34,6 @@ import net.pterodactylus.sone.freenet.fcp.FcpException; import freenet.support.SimpleFieldSet; -import com.google.common.base.Optional; import org.junit.Test; /** @@ -50,17 +49,15 @@ public class LockSoneCommandTest { 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(of(localSone)); + when(core.getLocalSone(eq("LocalSone"))).thenReturn(of(localSone)); SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "LocalSone").get(); LockSoneCommand lockSoneCommand = new LockSoneCommand(core); Response response = lockSoneCommand.execute(fields, null, null); verify(core).lockSone(eq(localSone)); - assertThat(response, notNullValue()); - assertThat(response.getReplyParameters(), notNullValue()); - assertThat(response.getReplyParameters().get("Message"), is("SoneLocked")); + verifyAnswer(response, "SoneLocked"); assertThat(response.getReplyParameters().get("Sone"), is("LocalSone")); } @@ -68,7 +65,7 @@ public class LockSoneCommandTest { public void testLockingARemoteSone() throws FcpException { Sone removeSone = mock(Sone.class); Core core = mock(Core.class); - when(core.getSone(eq("RemoteSone"))).thenReturn(Optional.of(removeSone)); + when(core.getSone(eq("RemoteSone"))).thenReturn(of(removeSone)); SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "RemoteSone").get(); LockSoneCommand lockSoneCommand = new LockSoneCommand(core);