public class ProviderOfTestSuiteListener extends ServicesAware implements Provider<TestSuiteListener> {
private static final Logger log = LoggerFactory.getLogger(ProviderOfTestSuiteListener.class);
@Override
protected void init() {
String POM_JAGGER_VERSION = "jagger.version";
String pomfile = "../../pom.xml";
MavenXpp3Reader mavenXpp3Reader = new MavenXpp3Reader();
try {
FileReader reader = new FileReader(pomfile);
Model model = mavenXpp3Reader.read(reader);
getSessionInfoService().appendToComment("jagger.version: " + model.getProperties().get(POM_JAGGER_VERSION));
}
catch(Exception e){
log.warn("Cant get pom info {}", e);
}
}
@Override
public TestSuiteListener provide() {
return new TestSuiteListener() {
@Override
public void onStart(TestSuiteInfo testSuiteInfo) {
String comment = "";
for (Map.Entry<NodeId,GeneralNodeInfo> entry : testSuiteInfo.getGeneralNodeInfo().entrySet()) {
comment += "\nNode: " + entry.getKey() + " (OS: " + entry.getValue().getOsName() + ", " + entry.getValue().getCpuModel() + ")";
}
getSessionInfoService().appendToComment(comment);
}
@Override
public void onStop(TestSuiteInfo testSuiteInfo) {
getSessionInfoService().saveOrUpdateTag("SERVICE_NAME", "Tag to mark sessions, testing some particular service");
getSessionInfoService().saveOrUpdateTag("PASS", "Tag to mark sessions with pass results");
getSessionInfoService().saveOrUpdateTag("FAIL", "Tag to mark sessions with fail results");
getSessionInfoService().markSessionWithTag("SERVICE_NAME");
Set<TestEntity> testEntities = getDataService().getTests(testSuiteInfo.getSessionId());
Map<TestEntity,Set<MetricEntity>> metricsPerTest = getDataService().getMetricsByTests(testEntities);
for (Map.Entry<TestEntity,Set<MetricEntity>> entry : metricsPerTest.entrySet()) {
Map<MetricEntity,MetricSummaryValueEntity> metricValues = getDataService().getMetricSummary(entry.getValue());
for (Map.Entry<MetricEntity,MetricSummaryValueEntity> valueEntry : metricValues.entrySet()) {
}
}
}
};
}
}