use of org.asqatasun.entity.reference.Criterion in project Asqatasun by Asqatasun.
the class AnalyserImpl method computeCriterionStatisticsFromDb.
/**
*
* @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;
}
use of org.asqatasun.entity.reference.Criterion in project Asqatasun by Asqatasun.
the class AnalyserImpl method extractThemeAndCriterionSet.
/**
* This method extracts a collection of themes for a given audit
*
* @return
*/
private void extractThemeAndCriterionSet() {
themeMap = new HashMap();
criterionMap = new HashMap();
for (Test test : testSet) {
//Collect criterions given the set of tests for the audit, and keep
// the number of tests for each criterion (needed to calculate the
// not tested
Criterion criterion = test.getCriterion();
if (criterionMap.containsKey(criterion)) {
Integer testCounter = criterionMap.get(criterion) + 1;
criterionMap.put(criterion, testCounter);
} else {
criterionMap.put(criterion, 1);
}
//Collect themes given the set of tests for the audit, and keep
// the number of tests for each criterion (needed to calculate the
// not tested
Theme theme = criterion.getTheme();
if (themeMap.containsKey(theme)) {
Integer testCounter = themeMap.get(theme) + 1;
themeMap.put(theme, testCounter);
} else {
themeMap.put(theme, 1);
}
}
}
use of org.asqatasun.entity.reference.Criterion in project Asqatasun by Asqatasun.
the class WebResourceStatisticsDataServiceImpl method createWebResourceStatisticsForManualAudit.
@Override
public WebResourceStatistics createWebResourceStatisticsForManualAudit(Audit audit, WebResource webResource, List<ProcessResult> netResultList) {
boolean isNewWebRs = false;
WebResourceStatistics wrStats = ((WebResourceStatisticsDAO) entityDao).findWebResourceStatisticsByWebResource(webResource, true);
if (wrStats == null) {
wrStats = this.create();
isNewWebRs = true;
}
Map<Criterion, CriterionStatistics> csMap = new HashMap<>();
Map<Theme, ThemeStatistics> tsMap = new HashMap<>();
// Map<Theme, List<ProcessResult>> mapProcessResultBytheme = new HashMap<Theme, List<ProcessResult>>();
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) {
// l'audit est manual
if (pr.getManualValue() != null) {
TestSolution prResult = (TestSolution) pr.getManualValue();
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(), wrStats, csMap);
addResultToThemeCounterMap(prResult, pr.getTest().getCriterion().getTheme(), wrStats, tsMap);
} else {
addResultToCriterionCounterMap(TestSolution.NOT_TESTED, pr.getTest().getCriterion(), wrStats, csMap);
addResultToThemeCounterMap(TestSolution.NOT_TESTED, pr.getTest().getCriterion().getTheme(), wrStats, tsMap);
nbOfNt++;
}
}
wrStats.setNbOfFailed(wrStats.getNbOfFailed() + nbOfFailed);
wrStats.setNbOfInvalidTest(wrStats.getNbOfInvalidTest() + nbOfFailed);
wrStats.setNbOfPassed(wrStats.getNbOfPassed() + nbOfPassed);
wrStats.setNbOfNmi(wrStats.getNbOfNmi() + nbOfNmi);
wrStats.setNbOfNa(wrStats.getNbOfNa() + nbOfNa);
wrStats.setNbOfDetected(wrStats.getNbOfDetected() + nbOfDetected);
wrStats.setNbOfSuspected(wrStats.getNbOfSuspected() + nbOfSuspected);
wrStats.setNbOfNotTested(wrStats.getNbOfNotTested() + nbOfNt);
setWeightedResult(wrStats, webResource);
wrStats.setHttpStatusCode(getHttpStatusCodeByWebResource(webResource.getId()));
wrStats = computeMark(wrStats);
wrStats = computeRawMark(wrStats);
wrStats = computeNumberOfFailedOccurrences(wrStats, webResource, true);
wrStats.setAudit(audit);
wrStats.setWebResource(webResource);
wrStats.setIsManualAuditStatistics(1);
// criterionStatistics to the current webResourceStatistics
if (isNewWebRs) {
for (CriterionStatistics cs : csMap.values()) {
computeCriterionResult(cs);
wrStats.addCriterionStatistics(cs);
}
// Link each themeStatistics to the current webResourceStatistics
for (ThemeStatistics ts : tsMap.values()) {
wrStats.addThemeStatistics(ts);
}
} else {
//recuperer les Crtiterion à partir de wrstat et id_criterion pour MAJ
for (CriterionStatistics css : csMap.values()) {
CriterionStatistics criterionStatisticsFromMap = csMap.get(css.getCriterion());
CriterionStatistics criterionStatisticsDb = criterionStatisticsDAO.findCriterionStatisticsByWebResource(css.getCriterion(), wrStats);
if (criterionStatisticsDb == null) {
criterionStatisticsDb = criterionStatisticsDataService.create();
criterionStatisticsDb.setWebResourceStatistics(wrStats);
criterionStatisticsDb.setCriterion(css.getCriterion());
}
populateCriterionStatistics(criterionStatisticsDb, criterionStatisticsFromMap);
computeCriterionResult(criterionStatisticsDb);
criterionStatisticsDAO.saveOrUpdate(criterionStatisticsDb);
}
for (ThemeStatistics ts : tsMap.values()) {
ThemeStatistics themeStatisticsFromMap = tsMap.get(ts.getTheme());
ThemeStatistics themeStatisticsDb = themeStatisticsDAO.findThemeStatisticsByWebResource(ts.getTheme(), wrStats);
if (themeStatisticsDb == null) {
themeStatisticsDb = themeStatisticsDataService.create();
themeStatisticsDb.setWebResourceStatistics(wrStats);
themeStatisticsDb.setTheme(ts.getTheme());
}
populateThemeStatistics(themeStatisticsDb, themeStatisticsFromMap);
themeStatisticsDAO.saveOrUpdate(themeStatisticsDb);
}
}
this.saveOrUpdate(wrStats);
return wrStats;
}
use of org.asqatasun.entity.reference.Criterion in project Asqatasun by Asqatasun.
the class AuditResultController method displayCriterionResult.
/**
*
* @param webresourceId
* @param criterionId
* @param model
* @return the test-result view name
*/
@RequestMapping(value = TgolKeyStore.CRITERION_RESULT_CONTRACT_URL, method = RequestMethod.GET)
public String displayCriterionResult(@RequestParam(TgolKeyStore.WEBRESOURCE_ID_KEY) String webresourceId, @RequestParam(TgolKeyStore.CRITERION_CODE_KEY) String criterionId, Model model) {
Long wrId;
Long critId;
try {
wrId = Long.valueOf(webresourceId);
critId = Long.valueOf(criterionId);
} catch (NumberFormatException nfe) {
throw new ForbiddenUserException(getCurrentUser());
}
WebResource webResource = getWebResourceDataService().ligthRead(wrId);
if (webResource == null || webResource instanceof Site) {
throw new ForbiddenPageException();
}
Audit audit = getAuditFromWebResource(webResource);
if (isUserAllowedToDisplayResult(audit)) {
Contract contract = retrieveContractFromAudit(audit);
// Attributes for breadcrumb
model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
model.addAttribute(TgolKeyStore.URL_KEY, webResource.getURL());
Criterion crit = criterionDataService.read(critId);
model.addAttribute(TgolKeyStore.CRITERION_LABEL_KEY, crit.getLabel());
model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, audit.getId());
// Add a boolean used to display the breadcrumb.
model.addAttribute(TgolKeyStore.AUTHORIZED_SCOPE_FOR_PAGE_LIST, isAuthorizedScopeForPageList(audit));
model.addAttribute(TgolKeyStore.TEST_RESULT_LIST_KEY, TestResultFactory.getInstance().getTestResultListFromCriterion(webResource, crit));
return TgolKeyStore.CRITERION_RESULT_VIEW_NAME;
} else {
throw new ForbiddenPageException();
}
}
use of org.asqatasun.entity.reference.Criterion in project Asqatasun by Asqatasun.
the class PageListControllerTest method setUpThemeDataService.
/**
*
*/
private void setUpThemeDataService() {
mockThemeDataService = createMock(ThemeDataService.class);
mockTheme = createMock(Theme.class);
Collection<Theme> themeCollection = new ArrayList();
themeCollection.add(mockTheme);
Reference mockReference = createMock(Reference.class);
Criterion mockCriterion = createMock(Criterion.class);
Collection<Criterion> criterionCollection = new ArrayList();
criterionCollection.add(mockCriterion);
expect(mockThemeDataService.findAll()).andReturn(themeCollection).anyTimes();
expect(mockTheme.getCriterionList()).andReturn(criterionCollection).anyTimes();
expect(mockCriterion.getReference()).andReturn(mockReference).anyTimes();
expect(mockReference.getCode()).andReturn("AW21").anyTimes();
replay(mockTheme);
replay(mockCriterion);
replay(mockReference);
replay(mockThemeDataService);
}
Aggregations