int l = entry.getValue().size();
Collections.sort(entry.getValue(), new ResultFullTestIdComparator());
for (int i = 0; i < l; ++i) {
Result result = entry.getValue().get(i);
double testId = TestUtils.getTestId(result.getDeclaringClass(), result.getDeclaredMethod());
String description = ReflectionUtils.getAnnotation(Test.class, result.getDeclaredMethod()).description();
double time = result.getDuration();
Row resultRow = sheet.createRow(i + 1);
resultRow.createCell(0).setCellValue(testId);
resultRow.createCell(1).setCellValue(result.getDeclaringClass().getSimpleName());
resultRow.createCell(2).setCellValue(description);
resultRow.createCell(3).setCellValue(time);
}
sheet.autoSizeColumn(0);
sheet.autoSizeColumn(1);
sheet.autoSizeColumn(2);
sheet.autoSizeColumn(3);
}
//Comparable export
for (Map.Entry<String, List<Result>> entry : results.entrySet()) {
Sheet sheet = getOrCreateSheet(entry.getKey() + "(group)", wb);
log.info("Creating sheet " + sheet.getSheetName());
int l = entry.getValue().size();
Collections.sort(entry.getValue(), new ResultFullTestIdComparator());
//Find all test descriptions and class names
Set<String> testDescriptions = new TreeSet<String>();
Set<String> classNames = new TreeSet<String>();
Map<String, Double> minVal = new HashMap<String, Double>();
for (int i = 0; i < l; ++i) {
String desc = ReflectionUtils.getAnnotation(Test.class, entry.getValue().get(i).getDeclaredMethod()).description();
testDescriptions.add(desc);
classNames.add(entry.getValue().get(i).getDeclaringClass().getSimpleName());
if (minVal.containsKey(desc) && (minVal.get(desc) > entry.getValue().get(i).getDuration())) {
minVal.put(desc, entry.getValue().get(i).getDuration());
} else if (!minVal.containsKey(desc)) {
minVal.put(desc, entry.getValue().get(i).getDuration());
}
}
//Generate a row/col mapping
Map<String, Integer> rowMapping = new TreeMap<String, Integer>();
Map<String, Integer> colMapping = new TreeMap<String, Integer>();
int z = 1;
for (String s : testDescriptions) {
rowMapping.put(s, z++);
}
z = 1;
for (String s : classNames) {
colMapping.put(s, z++);
}
//Init cells and stuff
for (Integer i : rowMapping.values()) {
Row row = sheet.createRow(i);
for (int j : colMapping.values()) {
row.createCell(j);
}
}
//Create headers
Row header = sheet.createRow(0);
for (String s : colMapping.keySet()) {
header.createCell(colMapping.get(s)).setCellValue(s);
}
for (String s : rowMapping.keySet()) {
Row row = sheet.getRow(rowMapping.get(s));
row.createCell(0).setCellValue(s);
}
//CellStyle style = wb.createCellStyle();
//DataFormat format = wb.createDataFormat();
//style.setDataFormat(format.getFormat("0.00%"));
//Write results
for (int i = 0; i < l; ++i) {
Result result = entry.getValue().get(i);
String desc = ReflectionUtils.getAnnotation(Test.class, entry.getValue().get(i).getDeclaredMethod()).description();
Row row = sheet.getRow(rowMapping.get(desc));
Cell cell = row.getCell(colMapping.get(result.getDeclaringClass().getSimpleName()));
cell.setCellValue(result.getDuration());
//cell.setCellStyle(style);
}
sheet.autoSizeColumn(0);
for (Integer i : colMapping.values()) {