use of net.md_5.bungee.api.plugin.PluginDescription in project Bukkit_Bungee_PluginLib by GeorgH93.
the class TestObjects method initMockedPlugin.
public static void initMockedPlugin() {
File mockedFile = mock(File.class);
when(mockedFile.getParentFile()).thenReturn(new File(""));
when(mockedFile.getName()).thenReturn("FileName");
TaskScheduler mockedTaskScheduler = mock(TaskScheduler.class);
when(mockedTaskScheduler.runAsync(any(Plugin.class), any(Runnable.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
((Runnable) invocationOnMock.getArguments()[1]).run();
return null;
}
});
ProxyServer mockedProxyServer = mock(ProxyServer.class);
when(mockedProxyServer.getPluginsFolder()).thenReturn(new File(""));
when(mockedProxyServer.getScheduler()).thenReturn(mockedTaskScheduler);
PluginDescription mockedPluginDescription = mock(PluginDescription.class);
when(mockedPluginDescription.getName()).thenReturn("TestPlugin");
when(mockedPluginDescription.getVersion()).thenReturn("1.0");
when(mockedPluginDescription.getFile()).thenReturn(mockedFile);
mockedPlugin = mock(Plugin.class);
when(mockedPlugin.getProxy()).thenReturn(mockedProxyServer);
when(mockedPlugin.getDescription()).thenReturn(mockedPluginDescription);
when(mockedPlugin.getLogger()).thenReturn(Logger.getLogger("TestLogger"));
}
Aggregations