convert API/server tests to mockito (#8848)

* convert API tests to mockito

* convert server tests to mockito

* add co-author
This commit is contained in:
Jake Potrebic
2023-02-15 13:27:40 -08:00
parent afeeaca6dd
commit bd166747a6
9 changed files with 771 additions and 182 deletions

View File

@@ -170,38 +170,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ }
+}
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/support/DummyServer.java
+++ b/src/test/java/org/bukkit/support/DummyServer.java
@@ -0,0 +0,0 @@ public final class DummyServer implements InvocationHandler {
}
}
);
- Bukkit.setServer(Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(new DummyServer()));
+ // Paper start - modeled off of TestServer in the API tests module
+ methods.put(
+ Server.class.getMethod("getPluginManager"),
+ new MethodHandler() {
+ @Override
+ public Object handle(DummyServer server, Object[] args) {
+ return server.pluginManager;
+ }
+ }
+ );
+ DummyServer server = new DummyServer();
+ Server instance = Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(server);
+ Bukkit.setServer(instance);
+ server.pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance));
+ // Paper end
} catch (Throwable t) {
throw new Error(t);
}
@@ -0,0 +0,0 @@ public final class DummyServer implements InvocationHandler {
private DummyServer() {};
+ private org.bukkit.plugin.PluginManager pluginManager; // Paper
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
MethodHandler handler = DummyServer.methods.get(method);