mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-20 19:52:45 +02:00
Fixed possible stub errors when mocking server implementations
This commit is contained in:
parent
e37af2b392
commit
1ef1910abb
|
@ -89,20 +89,21 @@ public class BukkitMockUtil extends MockUtil {
|
|||
|
||||
public BukkitMockUtil withServer() {
|
||||
Server serverMock = Mockito.mock(Server.class);
|
||||
when(serverMock.getIp()).thenReturn("");
|
||||
when(serverMock.getName()).thenReturn("Bukkit");
|
||||
when(serverMock.getServerName()).thenReturn("Bukkit");
|
||||
when(serverMock.getPort()).thenReturn(25565);
|
||||
when(serverMock.getVersion()).thenReturn("1.12.2");
|
||||
when(serverMock.getBukkitVersion()).thenReturn("32423");
|
||||
when(serverMock.getMaxPlayers()).thenReturn(TestConstants.BUKKIT_MAX_PLAYERS);
|
||||
doReturn("").when(serverMock).getIp();
|
||||
doReturn("Bukkit").when(serverMock).getName();
|
||||
doReturn("Bukkit").when(serverMock).getServerName();
|
||||
doReturn(25565).when(serverMock).getPort();
|
||||
doReturn("1.12.2").when(serverMock).getVersion();
|
||||
doReturn("32423").when(serverMock).getBukkitVersion();
|
||||
doReturn(TestConstants.BUKKIT_MAX_PLAYERS).when(serverMock).getMaxPlayers();
|
||||
FakeConsoleCmdSender sender = new FakeConsoleCmdSender();
|
||||
doReturn(sender).when(serverMock).getConsoleSender();
|
||||
when(serverMock.getConsoleSender()).thenReturn(sender);
|
||||
|
||||
BukkitScheduler bukkitScheduler = Mockito.mock(BukkitScheduler.class);
|
||||
doReturn(bukkitScheduler).when(serverMock).getScheduler();
|
||||
|
||||
when(planMock.getServer()).thenReturn(serverMock);
|
||||
doReturn(serverMock).when(planMock).getServer();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,19 +78,19 @@ public class BungeeMockUtil extends MockUtil {
|
|||
|
||||
public BungeeMockUtil withProxy() {
|
||||
ProxyServer proxyMock = Mockito.mock(ProxyServer.class);
|
||||
when(proxyMock.getVersion()).thenReturn("1.12.2");
|
||||
doReturn("1.12.2").when(proxyMock).getVersion();
|
||||
|
||||
CommandSender console = new FakeBungeeConsole();
|
||||
when(proxyMock.getConsole()).thenReturn(console);
|
||||
doReturn(console).when(proxyMock).getConsole();
|
||||
|
||||
ProxyConfig proxyConfig = Mockito.mock(ProxyConfig.class);
|
||||
when(proxyConfig.getPlayerLimit()).thenReturn(TestConstants.BUNGEE_MAX_PLAYERS);
|
||||
when(proxyMock.getConfig()).thenReturn(proxyConfig);
|
||||
doReturn(TestConstants.BUNGEE_MAX_PLAYERS).when(proxyConfig).getPlayerLimit();
|
||||
doReturn(proxyConfig).when(proxyMock).getConfig();
|
||||
|
||||
PluginManager pm = Mockito.mock(PluginManager.class);
|
||||
when(proxyMock.getPluginManager()).thenReturn(pm);
|
||||
doReturn(pm).when(proxyMock).getPluginManager();
|
||||
|
||||
when(planMock.getProxy()).thenReturn(proxyMock);
|
||||
doReturn(proxyMock).when(planMock).getProxy();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user