Example #1
0
  @Override
  public void run() {
    WebResourceStatistics wrStats = webResourceStatisticsDataService.create();

    // Regardind the webResource type the computation of the statitics is
    // done in memory or through the db
    if (webResource instanceof Page) {
      extractTestSet(false);
      netResultList =
          getProcessResultWithNotTested(
              testSet,
              processResultDataService.getNetResultFromAuditAndWebResource(audit, webResource));
      wrStats = computeAuditStatisticsFromPrList(wrStats);
      wrStats = computeHttpStatusCode(wrStats);
    } else if (webResource instanceof Site) {
      extractTestSet(true);
      wrStats = computeAuditStatisticsFromDb(wrStats);
      wrStats = computeCriterionStatisticsFromDb(wrStats);
      wrStats = computeTestStatisticsFromDb(wrStats);
      wrStats = computeThemeStatisticsFromDb(wrStats);
    }
    wrStats = computeMark(wrStats);
    wrStats = computeRawMark(wrStats);
    wrStats = computeNumberOfFailedOccurrences(wrStats);

    wrStats.setAudit(audit);
    wrStats.setWebResource(webResource);

    webResourceStatisticsDataService.saveOrUpdate(wrStats);
  }
Example #2
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 #3
0
  /**
   * * Gather the following statistics informations for each theme: - 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 computeTestStatisticsFromDb(WebResourceStatistics wrStatistics) {
    for (Test test : testSet) {
      TestStatistics testStatistics = testStatisticsDataService.create();
      testStatistics.setTest(test);

      int nbOfFailed =
          testStatisticsDataService
              .getResultCountByResultTypeAndTest(webResource, TestSolution.FAILED, test)
              .intValue();
      testStatistics.setNbOfFailed(nbOfFailed);

      int nbOfPassed =
          testStatisticsDataService
              .getResultCountByResultTypeAndTest(webResource, TestSolution.PASSED, test)
              .intValue();
      testStatistics.setNbOfPassed(nbOfPassed);

      int nbOfNmi =
          testStatisticsDataService
              .getResultCountByResultTypeAndTest(webResource, TestSolution.NEED_MORE_INFO, test)
              .intValue();
      testStatistics.setNbOfNmi(nbOfNmi);

      int nbOfNa =
          testStatisticsDataService
              .getResultCountByResultTypeAndTest(webResource, TestSolution.NOT_APPLICABLE, test)
              .intValue();
      testStatistics.setNbOfNa(nbOfNa);

      testStatistics.setNbOfNotTested(nbOfWr - nbOfFailed - nbOfPassed - nbOfNmi - nbOfNa);

      wrStatistics.addTestStatistics(testStatistics);
    }
    return wrStatistics;
  }
Example #4
0
 /**
  * Gather the number of failed occurrence for a given web resource.
  *
  * @param wrStatistics
  * @return
  */
 private WebResourceStatistics computeNumberOfFailedOccurrences(
     WebResourceStatistics wrStatistics) {
   int nbOfFailedOccurences =
       webResourceStatisticsDataService
           .getNumberOfOccurrencesByWebResourceAndResultType(
               webResource.getId(), TestSolution.FAILED)
           .intValue();
   wrStatistics.setNbOfFailedOccurences(nbOfFailedOccurences);
   return wrStatistics;
 }
Example #5
0
  /** @param wrStatistics */
  private void setWeightedResult(WebResourceStatistics wrStatistics) {
    BigDecimal weightedPassed =
        webResourceStatisticsDataService.getWeightedResultByResultType(
            webResource.getId(), paramSet, TestSolution.PASSED);

    BigDecimal weightedFailed =
        webResourceStatisticsDataService.getWeightedResultByResultType(
            webResource.getId(), paramSet, TestSolution.FAILED);

    BigDecimal weightedNa =
        webResourceStatisticsDataService.getWeightedResultByResultType(
            webResource.getId(), paramSet, TestSolution.NOT_APPLICABLE);

    BigDecimal weightedNmi =
        webResourceStatisticsDataService.getWeightedResultByResultType(
            webResource.getId(), paramSet, TestSolution.NEED_MORE_INFO);
    wrStatistics.setWeightedFailed(weightedFailed);
    wrStatistics.setWeightedPassed(weightedPassed);
    wrStatistics.setWeightedNmi(weightedNmi);
    wrStatistics.setWeightedNa(weightedNa);
  }
Example #6
0
  /**
   * @param wrStatistics
   * @return
   */
  private WebResourceStatistics computeCriterionStatisticsFromDb(
      WebResourceStatistics wrStatistics) {
    for (Criterion cr : criterionMap.keySet()) {
      CriterionStatistics criterionStatistics = criterionStatisticsDataService.create();
      criterionStatistics.setCriterion(cr);
      int nbOfFailed =
          criterionStatisticsDataService
              .getResultCountByResultTypeAndCriterion(webResource, TestSolution.FAILED, cr)
              .intValue();
      criterionStatistics.setNbOfFailed(nbOfFailed);

      int nbOfNa =
          criterionStatisticsDataService
              .getResultCountByResultTypeAndCriterion(webResource, TestSolution.NOT_APPLICABLE, cr)
              .intValue();
      criterionStatistics.setNbOfNa(nbOfNa);

      int nbOfPassed =
          criterionStatisticsDataService
              .getResultCountByResultTypeAndCriterion(webResource, TestSolution.PASSED, cr)
              .intValue();
      criterionStatistics.setNbOfPassed(nbOfPassed);

      int nbOfNmi =
          criterionStatisticsDataService
              .getResultCountByResultTypeAndCriterion(webResource, TestSolution.NEED_MORE_INFO, cr)
              .intValue();
      nbOfNmi +=
          criterionStatisticsDataService
              .getResultCountByResultTypeAndCriterion(
                  webResource, TestSolution.SUSPECTED_FAILED, cr)
              .intValue();
      nbOfNmi +=
          criterionStatisticsDataService
              .getResultCountByResultTypeAndCriterion(
                  webResource, TestSolution.SUSPECTED_PASSED, cr)
              .intValue();
      nbOfNmi +=
          criterionStatisticsDataService
              .getResultCountByResultTypeAndCriterion(webResource, TestSolution.DETECTED, cr)
              .intValue();
      criterionStatistics.setNbOfNmi(nbOfNmi);

      int criterionTestListSize = criterionMap.get(cr);
      criterionStatistics.setNbOfNotTested(
          criterionTestListSize * nbOfWr - nbOfFailed - nbOfNa - nbOfNmi - nbOfPassed);
      computeCriterionResult(criterionStatistics);
      wrStatistics.addCriterionStatistics(criterionStatistics);
    }
    return wrStatistics;
  }
Example #7
0
  /**
   * @param wrStatistics
   * @return
   */
  private WebResourceStatistics computeThemeStatisticsFromDb(WebResourceStatistics wrStatistics) {
    for (Theme theme : themeMap.keySet()) {
      ThemeStatistics themeStatistics = themeStatisticsDataService.create();
      themeStatistics.setTheme(theme);

      int nbOfFailed =
          themeStatisticsDataService
              .getResultCountByResultTypeAndTheme(webResource, TestSolution.FAILED, theme)
              .intValue();
      themeStatistics.setNbOfFailed(nbOfFailed);

      int nbOfPassed =
          themeStatisticsDataService
              .getResultCountByResultTypeAndTheme(webResource, TestSolution.PASSED, theme)
              .intValue();
      themeStatistics.setNbOfPassed(nbOfPassed);

      int nbOfNa =
          themeStatisticsDataService
              .getResultCountByResultTypeAndTheme(webResource, TestSolution.NOT_APPLICABLE, theme)
              .intValue();
      themeStatistics.setNbOfNa(nbOfNa);

      int nbOfNmi =
          themeStatisticsDataService
              .getResultCountByResultTypeAndTheme(webResource, TestSolution.NEED_MORE_INFO, theme)
              .intValue();
      nbOfNmi +=
          themeStatisticsDataService
              .getResultCountByResultTypeAndTheme(webResource, TestSolution.SUSPECTED_FAILED, theme)
              .intValue();
      nbOfNmi +=
          themeStatisticsDataService
              .getResultCountByResultTypeAndTheme(webResource, TestSolution.SUSPECTED_PASSED, theme)
              .intValue();
      themeStatistics.setNbOfNmi(nbOfNmi);

      int themeTestListSize = themeMap.get(theme);

      themeStatistics.setNbOfNotTested(
          themeTestListSize * nbOfWr - nbOfFailed - nbOfNa - nbOfNmi - nbOfPassed);

      wrStatistics.addThemeStatistics(themeStatistics);
    }
    return wrStatistics;
  }
Example #8
0
 /**
  * This method compute the mark of the audit. Here is the algorithm formula : ((1-ratioNMI) *
  * passed/(passed+failed) + ratioNMI * needMoreInfo/(passed+failed+needMoreInfo)) *100f where
  * ratioNMI = needMoreInfo / (passed+failed+needMoreInfo)
  *
  * @param wrStatistics
  * @return
  */
 public WebResourceStatistics computeMark(WebResourceStatistics wrStatistics) {
   float passed = wrStatistics.getNbOfPassed();
   // page on error, mark set to -1
   if (passed == -1) {
     wrStatistics.setRawMark(Float.valueOf(-1));
     return wrStatistics;
   }
   float failed = wrStatistics.getNbOfFailed();
   float needMoreInfo = wrStatistics.getNbOfNmi();
   if (failed == 0 && passed == 0) {
     wrStatistics.setMark(Float.valueOf(0));
     return wrStatistics;
   }
   float ratioNMI = needMoreInfo / (passed + failed + needMoreInfo);
   float result =
       ((1 - ratioNMI) * passed / (passed + failed)
               + ratioNMI * needMoreInfo / (passed + failed + needMoreInfo))
           * 100f;
   wrStatistics.setMark(result);
   return wrStatistics;
 }
Example #9
0
  /**
   * This method compute the raw mark of the audit. Here is the algorithm formula :
   * passed/(passed+failed)
   *
   * @param wrStatistics
   * @return
   */
  public WebResourceStatistics computeRawMark(WebResourceStatistics wrStatistics) {
    float passed = wrStatistics.getNbOfPassed();
    // page on error, mark set to -1
    if (passed == -1) {
      wrStatistics.setRawMark(Float.valueOf(-1));
      return wrStatistics;
    }
    BigDecimal weightedPassed = wrStatistics.getWeightedPassed();
    BigDecimal weightedFailed = wrStatistics.getWeightedFailed();
    if ((weightedFailed.equals(BigDecimal.ZERO) || weightedFailed.equals(ZERO))
        && (weightedPassed.equals(BigDecimal.ZERO) || weightedPassed.equals(ZERO))) {
      wrStatistics.setRawMark(Float.valueOf(0));
      return wrStatistics;
    }

    float result =
        weightedPassed
                .divide(weightedPassed.add(weightedFailed), 4, RoundingMode.HALF_UP)
                .floatValue()
            * 100f;
    wrStatistics.setRawMark(result);
    return wrStatistics;
  }
Example #10
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;
  }
Example #11
0
 /**
  * Gather the Http status code for a given web resource.
  *
  * @param wrStatistics
  * @return
  */
 private WebResourceStatistics computeHttpStatusCode(WebResourceStatistics wrStatistics) {
   wrStatistics.setHttpStatusCode(
       webResourceStatisticsDataService.getHttpStatusCodeByWebResource(webResource.getId()));
   return wrStatistics;
 }