}
@Override
public void endGroup() throws AnalysisListenerException {
// TestSuite
Testsuite testsuite = new Testsuite();
int tests = 0;
int failures = 0;
int errors = 0;
for (Map.Entry<Result<? extends Rule>, Long> entry : results.entrySet()) {
// TestCase
Result<? extends Rule> result = entry.getKey();
long time = entry.getValue().longValue();
Testcase testcase = new Testcase();
Rule rule = result.getRule();
testcase.setName(rule.getId());
testcase.setClassname(group.getId());
testcase.setTime(Long.toString(time));
List<Map<String, Object>> rows = result.getRows();
if (rule instanceof Concept && rows.isEmpty()) {
Failure failure = new Failure();
failure.setMessage(rule.getDescription());
failure.setContent("The concept returned an empty result.");
testcase.getFailure().add(failure);
failures++;
} else if (rule instanceof Constraint && !rows.isEmpty()) {
Error error = new Error();
error.setMessage(rule.getDescription());
StringBuilder sb = new StringBuilder();
for (Map<String, Object> row : rows) {
for (Map.Entry<String, Object> rowEntry : row.entrySet()) {
sb.append(rowEntry.getKey());
sb.append("=");
sb.append(rowEntry.getValue());
}
}
error.setContent(sb.toString());
testcase.getError().add(error);
errors++;
}
tests++;
testsuite.getTestcase().add(testcase);
}
testsuite.setTests(Integer.toString(tests));
testsuite.setFailures(Integer.toString(failures));
testsuite.setErrors(Integer.toString(errors));
testsuite.setName(group.getId());
long groupTime = System.currentTimeMillis() - groupBeginTimestamp;
testsuite.setTime(Long.toString(groupTime));
// TestSuite
File file = new File(directory, "TEST-" + group.getId() + ".xml");
try {
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);