@Override
  public void save(Report report) {
    List<GenericReportEntry> entries = report.getEntriesForLevel(ReportConstants.level_all);

    // retrieve all thresholds and compare for each entry
    for (GenericReportEntry e : entries) {
      Iterator<Threshold> thresholds = report.getThresholds(e).iterator();
      while (thresholds.hasNext()) {
        Threshold t = thresholds.next();
        // if does not pass, add to result
        if (t.isBelowThreshold(e.getPayload().getMetric(t.getMetricName()).getValue())) {
          reportEntries.add(
              new ThresholdReportEntry(
                  e.getName(),
                  e.getType(),
                  t.getThreshold(),
                  e.getPayload().getMetric(t.getMetricName()).getValue()));
        }
      }
    }

    // produce an xml
    Serializer serializer = new Persister();
    try {
      serializer.write(report, new File("coberturaThresholdsReport.xml"));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
 @Test
 public void testGetEntriesForLevel() {
   assertFalse(report.getEntriesForLevel(ReportConstants.level_project).isEmpty());
 }