🚧 Add interactions helper for page maker
[Sone.git] / src / test / java / net / pterodactylus / sone / test / TestUtil.java
index 22c2057..35e8202 100644 (file)
@@ -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> T createObject(Class<T> clazz, Class[] parameterTypes, Object... arguments) {
+               try {
+                       Constructor<T> constructor = clazz.getDeclaredConstructor(parameterTypes);
+                       constructor.setAccessible(true);
+                       return constructor.newInstance(arguments);
+               } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
+                       throw new RuntimeException(e);
+               }
+       }
+
 }