Example #1
0
  /**
   * Gather the audit statistics informations : - Number of passed results - Number of failed
   * results - Number of need_more_information results - Number of not applicable results - Number
   * of failed tests
   *
   * @param wrStatistics
   * @return
   */
  private WebResourceStatistics computeAuditStatisticsFromDb(WebResourceStatistics wrStatistics) {
    int nbOfPassed =
        webResourceStatisticsDataService
            .getResultCountByResultType(webResource.getId(), TestSolution.PASSED)
            .intValue();

    int nbOfFailed =
        webResourceStatisticsDataService
            .getResultCountByResultType(webResource.getId(), TestSolution.FAILED)
            .intValue();

    int nbOfNmi =
        webResourceStatisticsDataService
            .getResultCountByResultType(webResource.getId(), TestSolution.NEED_MORE_INFO)
            .intValue();

    int nbOfNa =
        webResourceStatisticsDataService
            .getResultCountByResultType(webResource.getId(), TestSolution.NOT_APPLICABLE)
            .intValue();

    int nbOfDetected =
        webResourceStatisticsDataService
            .getResultCountByResultType(webResource.getId(), TestSolution.DETECTED)
            .intValue();

    int nbOfSuspected =
        webResourceStatisticsDataService
                .getResultCountByResultType(webResource.getId(), TestSolution.SUSPECTED_FAILED)
                .intValue()
            + webResourceStatisticsDataService
                .getResultCountByResultType(webResource.getId(), TestSolution.SUSPECTED_PASSED)
                .intValue();

    // if no test have been processed for any reason, mostly cause the source
    // code couldn't have been adapted, all theses values are set to -1
    if (nbOfFailed + nbOfNa + nbOfNmi + nbOfPassed + nbOfDetected + nbOfSuspected == 0) {
      nbOfFailed = nbOfNa = nbOfNmi = nbOfPassed = nbOfSuspected = nbOfDetected = -1;
    }

    wrStatistics.setNbOfFailed(nbOfFailed);
    wrStatistics.setNbOfInvalidTest(nbOfFailed);
    wrStatistics.setNbOfPassed(nbOfPassed);
    wrStatistics.setNbOfNmi(nbOfNmi);
    wrStatistics.setNbOfNa(nbOfNa);
    wrStatistics.setNbOfDetected(nbOfDetected);
    wrStatistics.setNbOfSuspected(nbOfSuspected);
    wrStatistics.setNbOfNotTested(
        testSet.size() * nbOfWr
            - nbOfDetected
            - nbOfSuspected
            - nbOfFailed
            - nbOfNa
            - nbOfNmi
            - nbOfPassed);

    setWeightedResult(wrStatistics);
    wrStatistics.setAudit(audit);
    return wrStatistics;
  }
Example #2
0
  /**
   * To avoid multiple count requests to the db, the audits statistics are computing by iterating
   * through the ProcessResult list. The criterion statistics and the theme statistics are collected
   * on the fly while parsing the collection of ProcessResult
   *
   * @param wrStatistics
   * @return
   */
  private WebResourceStatistics computeAuditStatisticsFromPrList(
      WebResourceStatistics wrStatistics) {

    int nbOfPassed = 0;
    int nbOfFailed = 0;
    int nbOfNmi = 0;
    int nbOfNa = 0;
    int nbOfDetected = 0;
    int nbOfSuspected = 0;
    int nbOfNt = 0;

    for (ProcessResult pr : netResultList) {
      TestSolution prResult = (TestSolution) pr.getValue();
      switch (prResult) {
        case PASSED:
          nbOfPassed++;
          break;
        case FAILED:
          nbOfFailed++;
          break;
        case NOT_APPLICABLE:
          nbOfNa++;
          break;
        case NEED_MORE_INFO:
        case DETECTED:
        case SUSPECTED_FAILED:
        case SUSPECTED_PASSED:
          nbOfNmi++;
          break;
        case NOT_TESTED:
          nbOfNt++;
          break;
      }
      addResultToCriterionCounterMap(prResult, pr.getTest().getCriterion(), wrStatistics);
      addResultToThemeCounterMap(prResult, pr.getTest().getCriterion().getTheme(), wrStatistics);
    }
    // if no test have been processed for any reason, mostly cause the source
    // code couldn't have been adapted, all theses values are set to -1
    if (nbOfFailed + nbOfNa + nbOfNmi + nbOfPassed + nbOfDetected + nbOfSuspected == 0) {
      nbOfFailed = nbOfNa = nbOfNmi = nbOfPassed = nbOfSuspected = nbOfDetected = -1;
    }
    wrStatistics.setNbOfFailed(nbOfFailed);
    wrStatistics.setNbOfInvalidTest(nbOfFailed);
    wrStatistics.setNbOfPassed(nbOfPassed);
    wrStatistics.setNbOfNmi(nbOfNmi);
    wrStatistics.setNbOfNa(nbOfNa);
    wrStatistics.setNbOfDetected(nbOfDetected);
    wrStatistics.setNbOfSuspected(nbOfSuspected);
    wrStatistics.setNbOfNotTested(nbOfNt);

    setWeightedResult(wrStatistics);

    // Compute criterion Result for each criterion and link each
    // criterionStatistics to the current webResourceStatistics
    for (CriterionStatistics cs : csMap.values()) {
      computeCriterionResult(cs);
      wrStatistics.addCriterionStatistics(cs);
    }
    // Link each themeStatistics to the current webResourceStatistics
    for (ThemeStatistics ts : tsMap.values()) {
      wrStatistics.addThemeStatistics(ts);
    }

    wrStatistics.setAudit(audit);
    return wrStatistics;
  }