Esempio n. 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;
  }