#306 Adjust ExecutableCommand implementations to interface
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.util.WrapperMock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
@@ -13,6 +14,7 @@ import org.mockito.Mockito;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -40,7 +42,7 @@ public class AddEmailCommandTest {
|
||||
AddEmailCommand command = new AddEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(authMeMock, never()).getManagement();
|
||||
@@ -53,7 +55,7 @@ public class AddEmailCommandTest {
|
||||
AddEmailCommand command = new AddEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("mail@example", "other_example"));
|
||||
command.executeCommand(sender, Arrays.asList("mail@example", "other_example"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(authMeMock).getManagement();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.util.WrapperMock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
@@ -13,6 +14,7 @@ import org.mockito.Mockito;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -29,18 +31,18 @@ public class ChangeEmailCommandTest {
|
||||
public void setUpMocks() {
|
||||
WrapperMock wrapper = WrapperMock.createInstance();
|
||||
authMeMock = wrapper.getAuthMe();
|
||||
managementMock = Mockito.mock(Management.class);
|
||||
managementMock = mock(Management.class);
|
||||
when(authMeMock.getManagement()).thenReturn(managementMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRejectNonPlayerSender() {
|
||||
// given
|
||||
CommandSender sender = Mockito.mock(BlockCommandSender.class);
|
||||
CommandSender sender = mock(BlockCommandSender.class);
|
||||
ChangeEmailCommand command = new ChangeEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(authMeMock, never()).getManagement();
|
||||
@@ -49,11 +51,12 @@ public class ChangeEmailCommandTest {
|
||||
@Test
|
||||
public void shouldForwardData() {
|
||||
// given
|
||||
Player sender = Mockito.mock(Player.class);
|
||||
Player sender = mock(Player.class);
|
||||
ChangeEmailCommand command = new ChangeEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("new.mail@example.org", "old_mail@example.org"));
|
||||
command.executeCommand(sender, Arrays.asList("new.mail@example.org", "old_mail@example.org"),
|
||||
mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(authMeMock).getManagement();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.util.WrapperMock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -10,6 +11,8 @@ import org.mockito.Mockito;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Test for {@link RecoverEmailCommand}.
|
||||
*/
|
||||
@@ -28,7 +31,7 @@ public class RecoverEmailCommandTest {
|
||||
RecoverEmailCommand command = new RecoverEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user