Search in sources :

Example 16 with MethodFinder

use of com.axway.ats.core.reflect.MethodFinder in project ats-framework by Axway.

the class Test_StringToEnumRule method isCompatibleNegativeWrongArgType.

@Test(expected = NoSuchMethodException.class)
public void isCompatibleNegativeWrongArgType() throws NoSuchMethodException, AmbiguousMethodException {
    List<TypeComparisonRule> typeComparisonRules = new ArrayList<TypeComparisonRule>();
    typeComparisonRules.add(new StringToEnumRule());
    MethodFinder methodFinder = new MethodFinder("methods", Arrays.asList(ActionClassEnumArguments.class.getDeclaredMethods()), typeComparisonRules);
    //String argument
    assertNotNull(methodFinder.findMethod(new Class<?>[] { Integer.class }));
}
Also used : TypeComparisonRule(com.axway.ats.core.reflect.TypeComparisonRule) ArrayList(java.util.ArrayList) MethodFinder(com.axway.ats.core.reflect.MethodFinder) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 17 with MethodFinder

use of com.axway.ats.core.reflect.MethodFinder in project ats-framework by Axway.

the class Test_StringToEnumRule method isCompatiblePositive.

@Test
public void isCompatiblePositive() throws NoSuchMethodException, AmbiguousMethodException {
    List<TypeComparisonRule> typeComparisonRules = new ArrayList<TypeComparisonRule>();
    typeComparisonRules.add(new StringToEnumRule());
    MethodFinder methodFinder = new MethodFinder("methods", Arrays.asList(ActionClassEnumArguments.class.getDeclaredMethods()), typeComparisonRules);
    //String argument
    assertNotNull(methodFinder.findMethod(new Class<?>[] { String.class }));
    //array of Strings argument
    assertNotNull(methodFinder.findMethod(new Class<?>[] { (new String[] {}).getClass(), Integer.TYPE }));
}
Also used : TypeComparisonRule(com.axway.ats.core.reflect.TypeComparisonRule) ArrayList(java.util.ArrayList) MethodFinder(com.axway.ats.core.reflect.MethodFinder) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

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