X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FUnlockSoneCommandTest.java;h=e33e1bc361170fb9e8c2790dd1be0203dde7329a;hb=8e757d5c4e370192094ad844d88935c3c714c34b;hp=05fc73c5f36381e52896f822998f697f46d227b2;hpb=f65328fb92d16e568b869bf5f2771dd4114d8abc;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/fcp/UnlockSoneCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/UnlockSoneCommandTest.java index 05fc73c..e33e1bc 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/UnlockSoneCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/UnlockSoneCommandTest.java @@ -1,5 +1,5 @@ /* - * Sone - LockSoneCommandTest.java - Copyright © 2013 David Roden + * Sone - UnlockSoneCommandTest.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 UnlockSoneCommandTest { public void testUnlockingALocalSone() 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(); UnlockSoneCommand unlockSoneCommand = new UnlockSoneCommand(core); - Response response = unlockSoneCommand.execute(fields, null, null); + Response response = unlockSoneCommand.execute(fields); verify(core).unlockSone(eq(localSone)); assertThat(response, notNullValue()); @@ -66,11 +67,11 @@ public class UnlockSoneCommandTest { public void testUnlockingARemoteSone() 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(); UnlockSoneCommand unlockSoneCommand = new UnlockSoneCommand(core); - unlockSoneCommand.execute(fields, null, null); + unlockSoneCommand.execute(fields); } @Test(expected = FcpException.class) @@ -79,7 +80,7 @@ public class UnlockSoneCommandTest { SimpleFieldSet fields = new SimpleFieldSetBuilder().get(); UnlockSoneCommand unlockSoneCommand = new UnlockSoneCommand(core); - unlockSoneCommand.execute(fields, null, null); + unlockSoneCommand.execute(fields); } }