Search in sources :

Example 11 with MethodFinder

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 }));
}
Also used : TypeComparisonRule(com.axway.ats.core.reflect.TypeComparisonRule) ArrayList(java.util.ArrayList) MethodFinder(com.axway.ats.core.reflect.MethodFinder) BaseTest(com.axway.ats.core.BaseTest) Test(org.junit.Test)

Example 12 with MethodFinder

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));
}
Also used : ArrayList(java.util.ArrayList) MethodFinder(com.axway.ats.core.reflect.MethodFinder) File(java.io.File) BaseTest(com.axway.ats.core.BaseTest) Test(org.junit.Test)

Example 13 with MethodFinder

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 }));
}
Also used : MethodFinder(com.axway.ats.core.reflect.MethodFinder) BaseTest(com.axway.ats.core.BaseTest) Test(org.junit.Test)

Example 14 with MethodFinder

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 });
}
Also used : MethodFinder(com.axway.ats.core.reflect.MethodFinder) BaseTest(com.axway.ats.core.BaseTest) Test(org.junit.Test)

Example 15 with MethodFinder

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<?>[] {});
}
Also used : MethodFinder(com.axway.ats.core.reflect.MethodFinder) BaseTest(com.axway.ats.core.BaseTest) Test(org.junit.Test)

Aggregations

MethodFinder (com.axway.ats.core.reflect.MethodFinder)17 Test (org.junit.Test)13 BaseTest (com.axway.ats.core.BaseTest)10 ArrayList (java.util.ArrayList)5 TypeComparisonRule (com.axway.ats.core.reflect.TypeComparisonRule)4 BaseTest (com.axway.ats.agent.core.BaseTest)3 AmbiguousMethodException (com.axway.ats.core.reflect.AmbiguousMethodException)3 DbException (com.axway.ats.core.dbaccess.exceptions.DbException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ActionAlreadyDefinedException (com.axway.ats.agent.core.exceptions.ActionAlreadyDefinedException)1 PublicAtsApi (com.axway.ats.common.PublicAtsApi)1 CassandraDbProvider (com.axway.ats.core.dbaccess.cassandra.CassandraDbProvider)1 MssqlDbProvider (com.axway.ats.core.dbaccess.mssql.MssqlDbProvider)1 MysqlDbProvider (com.axway.ats.core.dbaccess.mysql.MysqlDbProvider)1 OracleDbProvider (com.axway.ats.core.dbaccess.oracle.OracleDbProvider)1 File (java.io.File)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1