0

добавлен тест на generic method

This commit is contained in:
2021-01-08 16:27:20 +03:00
parent aab3b43e57
commit cc1592f8e3
2 changed files with 30 additions and 0 deletions

View File

@@ -139,6 +139,23 @@ public class ReflectionObjectTest {
assertNotNull(refMethod);
}
@Test
public void method_generic() {
SomeGenericObject<String, Integer> someGenericObject = new SomeGenericObject<>();
String key = "KEY!";
int value = 3306;
ReflectionObject refObj = new ReflectionObject(someGenericObject);
ReflectionMethod refMethod = refObj.method("genericMethod", Object.class, Object.class);
assertNotNull(refMethod);
refMethod.invoke(key, value);
assertFalse(someGenericObject.map.isEmpty());
assertTrue(someGenericObject.map.containsKey(key));
assertEquals(value, (int) someGenericObject.map.get(key));
}
@Test(expected = ReflectionException.class)
public void method_notExists() {
ReflectionObject refObj = new ReflectionObject(new SomeObject());