Source:
<code>public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) { Comparator<IMethodInstance> comparator = new Comparator<IMethodInstance>() { private int getMethodPriority(IMethodInstance mi) { int result = 0; Method method = mi.getMethod().getMethod(); Priority a1 = method.getAnnotation(Priority.class); if (a1 != null) { result = a1.value(); } return result; } @SuppressWarnings({ "rawtypes", "unchecked" }) private int getClassPriority(IMethodInstance mi) { int result = 0; Method method = mi.getMethod().getMethod(); Class cls = method.getDeclaringClass(); Priority classPriority = (Priority) cls .getAnnotation(Priority.class); if (classPriority != null) { result = classPriority.value(); } return result; } private String getPackageName(IMethodInstance mi) { return mi.getMethod().getMethod().getDeclaringClass().getPackage().getName(); } private String getClassName(IMethodInstance mi) { return mi.getMethod().getMethod().getDeclaringClass().getName(); } private int packagePriorityOffset(String packageName) { if (packageName.contains("storage")) { return 1000000; } if (packageName.contains("teammates.test.cases.ui")) { return -1000000; } int index = packageOrder.indexOf(packageName); if (index == -1) { return 0; <START> } else { <END> return -index; } } public int compare(IMethodInstance m1, IMethodInstance m2) { int val = 0; String p1 = getPackageName(m1); String p2 = getPackageName(m2); val = p1.compareTo(p2); val -= packagePriorityOffset(p1); val += packagePriorityOffset(p2); if (val != 0) { return val; } val = getClassPriority(m1) - getClassPriority(m2); if (val != 0) { return val; } val = getClassName(m1).compareTo(getClassName(m2)); if (val != 0) { return val; } val = getMethodPriority(m1) - getMethodPriority(m2); if (val != 0) { return val; } return 0; } }; IMethodInstance[] array = methods.toArray(new IMethodInstance[methods .size()]); Arrays.sort(array, comparator); return Arrays.asList(array); }</code><technical_language>possibly remove else</technical_language>

Target:
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) { Comparator<IMethodInstance> comparator = new Comparator<IMethodInstance>() { private int getMethodPriority(IMethodInstance mi) { int result = 0; Method method = mi.getMethod().getMethod(); Priority a1 = method.getAnnotation(Priority.class); if (a1 != null) { result = a1.value(); } return result; } @SuppressWarnings({ "rawtypes", "unchecked" }) private int getClassPriority(IMethodInstance mi) { int result = 0; Method method = mi.getMethod().getMethod(); Class cls = method.getDeclaringClass(); Priority classPriority = (Priority) cls .getAnnotation(Priority.class); if (classPriority != null) { result = classPriority.value(); } return result; } private String getPackageName(IMethodInstance mi) { return mi.getMethod().getMethod().getDeclaringClass().getPackage().getName(); } private String getClassName(IMethodInstance mi) { return mi.getMethod().getMethod().getDeclaringClass().getName(); } private int packagePriorityOffset(String packageName) { if (packageName.contains("storage")) { return 1000000; } if (packageName.contains("teammates.test.cases.ui")) { return -1000000; } int index = packageOrder.indexOf(packageName); if (index == -1) { return 0; } return -index; } public int compare(IMethodInstance m1, IMethodInstance m2) { int val = 0; String p1 = getPackageName(m1); String p2 = getPackageName(m2); val = p1.compareTo(p2); val -= packagePriorityOffset(p1); val += packagePriorityOffset(p2); if (val != 0) { return val; } val = getClassPriority(m1) - getClassPriority(m2); if (val != 0) { return val; } val = getClassName(m1).compareTo(getClassName(m2)); if (val != 0) { return val; } val = getMethodPriority(m1) - getMethodPriority(m2); if (val != 0) { return val; } return 0; } }; IMethodInstance[] array = methods.toArray(new IMethodInstance[methods .size()]); Arrays.sort(array, comparator); return Arrays.asList(array); }