Exemplo n.º 1
0
 /**
  * @param testSolution
  * @param criterion
  * @param wrs
  */
 private void addResultToCriterionCounterMap(
     TestSolution testSolution, Criterion criterion, WebResourceStatistics wrs) {
   if (csMap == null) {
     csMap = new HashMap<Criterion, CriterionStatistics>();
   }
   if (csMap.containsKey(criterion)) {
     CriterionStatistics cs = csMap.get(criterion);
     incrementCriterionCounterFromTestSolution(cs, testSolution);
   } else {
     CriterionStatistics cs = criterionStatisticsDataService.create();
     cs.setCriterion(criterion);
     incrementCriterionCounterFromTestSolution(cs, testSolution);
     csMap.put(criterion, cs);
   }
 }
Exemplo n.º 2
0
 /**
  * @param cs
  * @param testSolution
  */
 private void incrementCriterionCounterFromTestSolution(
     CriterionStatistics cs, TestSolution testSolution) {
   switch (testSolution) {
     case PASSED:
       cs.setNbOfPassed(cs.getNbOfPassed() + 1);
       break;
     case FAILED:
       cs.setNbOfFailed(cs.getNbOfFailed() + 1);
       break;
     case NOT_APPLICABLE:
       cs.setNbOfNa(cs.getNbOfNa() + 1);
       break;
     case NEED_MORE_INFO:
     case DETECTED:
     case SUSPECTED_FAILED:
     case SUSPECTED_PASSED:
       cs.setNbOfNmi(cs.getNbOfNmi() + 1);
       break;
     case NOT_TESTED:
       cs.setNbOfNotTested(cs.getNbOfNotTested() + 1);
       break;
   }
 }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
 /**
  * This computation is based on the priority of the results : - priority 1 : Failed - priority 2 :
  * NMI - priority 3 : Not Tested - priority 4 : Passed - priority 5 : NA
  *
  * <p>If at least one of the result type is found regarding the priority definition, the criterion
  * result is the result type
  *
  * @param crs
  * @param criterionTestListSize
  */
 private void computeCriterionResult(CriterionStatistics crs) {
   if (crs.getNbOfFailed() > 0) { // at least one test is failed, the criterion is failed
     crs.setCriterionResult(TestSolution.FAILED);
   } else if (crs.getNbOfNmi()
       > 0) { // at least one test is nmi and no failed test encountered, the criterion is nmi
     crs.setCriterionResult(TestSolution.NEED_MORE_INFO);
   } else if (crs.getNbOfNotTested() > 0) {
     crs.setCriterionResult(TestSolution.NOT_TESTED);
   } else if (crs.getNbOfPassed() > 0) {
     crs.setCriterionResult(TestSolution.PASSED);
   } else if (crs.getNbOfNa() > 0) {
     crs.setCriterionResult(TestSolution.NOT_APPLICABLE);
   } else {
     crs.setCriterionResult(TestSolution.NEED_MORE_INFO);
   }
 }