use of org.testng.IMethodInstance in project cloudstack by apache.
the class TestNGAop method intercept.
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
for (IMethodInstance methodIns : methods) {
ITestNGMethod method = methodIns.getMethod();
ConstructorOrMethod meth = method.getConstructorOrMethod();
Method m = meth.getMethod();
if (m != null) {
DB db = m.getAnnotation(DB.class);
if (db != null) {
TransactionLegacy txn = TransactionLegacy.open(m.getName());
}
}
}
// TODO Auto-generated method stub
return methods;
}
use of org.testng.IMethodInstance in project midpoint by Evolveum.
the class AlphabeticalMethodInterceptor method intercept.
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
List<Object> instanceList = Lists.newArrayList();
Map<Object, List<IMethodInstance>> map = Maps.newHashMap();
for (IMethodInstance mi : methods) {
Object instance = mi.getInstance();
if (!instanceList.contains(instance)) {
instanceList.add(instance);
}
List<IMethodInstance> l = map.get(instance);
if (l == null) {
l = Lists.newArrayList();
map.put(instance, l);
}
l.add(mi);
}
Comparator<IMethodInstance> comparator = new Comparator<IMethodInstance>() {
@Override
public int compare(IMethodInstance o1, IMethodInstance o2) {
return o1.getMethod().getMethodName().compareTo(o2.getMethod().getMethodName());
}
};
List<IMethodInstance> result = Lists.newArrayList();
for (Object instance : instanceList) {
List<IMethodInstance> methodlist = map.get(instance);
IMethodInstance[] array = methodlist.toArray(new IMethodInstance[methodlist.size()]);
Arrays.sort(array, comparator);
result.addAll(Arrays.asList(array));
}
System.out.println("AlphabeticalMethodInterceptor: " + result);
return result;
}
Aggregations