1 package org.testng.reporters.jq; 2 3 import org.testng.ITestResult; 4 import org.testng.collections.ListMultiMap; 5 import org.testng.collections.Maps; 6 7 import java.util.Collections; 8 import java.util.Comparator; 9 import java.util.List; 10 11 public class ResultsByClass { 12 public static final Comparator<ITestResult> METHOD_NAME_COMPARATOR = 13 new Comparator<ITestResult>() { 14 15 @Override 16 public int compare(ITestResult arg0, ITestResult arg1) { 17 return arg0.getMethod().getMethodName().compareTo( 18 arg1.getMethod().getMethodName()); 19 } 20 21 }; 22 23 private ListMultiMap<Class<?>, ITestResult> m_results = Maps.newListMultiMap(); 24 addResult(Class<?> c, ITestResult tr)25 public void addResult(Class<?> c, ITestResult tr) { 26 m_results.put(c, tr); 27 } 28 getResults(Class<?> c)29 public List<ITestResult> getResults(Class<?> c) { 30 List<ITestResult> result = m_results.get(c); 31 Collections.sort(result, METHOD_NAME_COMPARATOR); 32 return result; 33 } 34 getClasses()35 public List<Class<?>> getClasses() { 36 // TODO do not use deprecated method 37 return m_results.getKeys(); 38 } 39 } 40