use of com.axway.ats.core.reflect.MethodFinder in project ats-framework by Axway.
the class Test_MethodFinder method findMethodConstructorMethodListCustomRulesPositive.
@Test
public void findMethodConstructorMethodListCustomRulesPositive() throws NoSuchMethodException, AmbiguousMethodException {
List<TypeComparisonRule> typeComparisonRules = new ArrayList<TypeComparisonRule>();
typeComparisonRules.add(new CustomTypeComparisonRule());
MethodFinder methodFinder = new MethodFinder("methods", Arrays.asList(MethodFinderTester.class.getDeclaredMethods()), typeComparisonRules);
//one argument - this argument will be evaulated as String in our custom rule
assertNotNull(methodFinder.findMethod(new Class<?>[] { Test_MethodFinder.class }));
}
use of com.axway.ats.core.reflect.MethodFinder in project ats-framework by Axway.
the class Test_MethodFinder method findConstructorInClassPositive.
@Test
public void findConstructorInClassPositive() throws NoSuchMethodException, AmbiguousMethodException {
MethodFinder methodFinder = new MethodFinder(FileInputStream.class);
//one argument
assertNotNull(methodFinder.findConstructor(new Class<?>[] { File.class }));
//no arguments
methodFinder = new MethodFinder(ArrayList.class);
assertNotNull(methodFinder.findConstructor(null));
}
use of com.axway.ats.core.reflect.MethodFinder in project ats-framework by Axway.
the class Test_MethodFinder method findMethodConstructorMethodListPositive.
@Test
public void findMethodConstructorMethodListPositive() throws NoSuchMethodException, AmbiguousMethodException {
MethodFinder methodFinder = new MethodFinder("methods", Arrays.asList(FileInputStream.class.getDeclaredMethods()));
//one argument
assertNotNull(methodFinder.findMethod(new Class<?>[] { (new byte[] {}).getClass() }));
//several arguments
assertNotNull(methodFinder.findMethod(new Class<?>[] { (new byte[] {}).getClass(), Integer.TYPE, Integer.TYPE }));
//unboxing
assertNotNull(methodFinder.findMethod(new Class<?>[] { (new byte[] {}).getClass(), Integer.class, Integer.class }));
//widening conversion
assertNotNull(methodFinder.findMethod(new Class<?>[] { (new byte[] {}).getClass(), Byte.class, Short.TYPE }));
}
use of com.axway.ats.core.reflect.MethodFinder in project ats-framework by Axway.
the class Test_MethodFinder method findMethodNegative.
@Test(expected = NoSuchMethodException.class)
public void findMethodNegative() throws NoSuchMethodException, AmbiguousMethodException {
MethodFinder methodFinder = new MethodFinder(FileInputStream.class);
//one argument
methodFinder.findMethod(new Class<?>[] { Integer.class, Integer.class, Integer.class });
}
use of com.axway.ats.core.reflect.MethodFinder in project ats-framework by Axway.
the class Test_MethodFinder method findMethodWithNameNegative.
@Test(expected = NoSuchMethodException.class)
public void findMethodWithNameNegative() throws NoSuchMethodException, AmbiguousMethodException {
MethodFinder methodFinder = new MethodFinder(FileInputStream.class);
//one argument
methodFinder.findMethod("read123", new Class<?>[] {});
}
Aggregations