X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftest%2FTestUtil.java;fp=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftest%2FTestUtil.java;h=35e8202b37905d21c59f41833fad15f7c3a1b250;hp=22c2057ebd69763732843489d9c468a75a5f0123;hb=b9d12d4a287728f062c541d02887c39c24117217;hpb=60b35d5e7c1f5ec9af98304b89c706f0affad13d diff --git a/src/test/java/net/pterodactylus/sone/test/TestUtil.java b/src/test/java/net/pterodactylus/sone/test/TestUtil.java index 22c2057..35e8202 100644 --- a/src/test/java/net/pterodactylus/sone/test/TestUtil.java +++ b/src/test/java/net/pterodactylus/sone/test/TestUtil.java @@ -1,5 +1,6 @@ package net.pterodactylus.sone.test; +import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -43,4 +44,14 @@ public class TestUtil { } } + public static T createObject(Class clazz, Class[] parameterTypes, Object... arguments) { + try { + Constructor constructor = clazz.getDeclaredConstructor(parameterTypes); + constructor.setAccessible(true); + return constructor.newInstance(arguments); + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + }