Search in sources :

Example 1 with TypeComparisonRule

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

the class Test_StringToEnumRule method isCompatibleNegativeArgisArrayParamIsNot.

@Test(expected = NoSuchMethodException.class)
public void isCompatibleNegativeArgisArrayParamIsNot() 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<?>[] { (new int[] {}).getClass() }));
}
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 2 with TypeComparisonRule

use of com.axway.ats.core.reflect.TypeComparisonRule 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 3 with TypeComparisonRule

use of com.axway.ats.core.reflect.TypeComparisonRule 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 4 with TypeComparisonRule

use of com.axway.ats.core.reflect.TypeComparisonRule 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)4 TypeComparisonRule (com.axway.ats.core.reflect.TypeComparisonRule)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 BaseTest (com.axway.ats.agent.core.BaseTest)3 BaseTest (com.axway.ats.core.BaseTest)1