use of org.asqatasun.entity.reference.Theme in project Asqatasun by Asqatasun.
the class ProcessResultDAOImplTest method testGetResultByThemeCount.
public void testGetResultByThemeCount() {
Theme theme1 = themeDAO.read(Long.valueOf(1));
Theme theme2 = themeDAO.read(Long.valueOf(2));
WebResource wa = webresourceDAO.read(Long.valueOf(1));
assertEquals(1, processResultDAO.getResultByThemeCount(wa, TestSolution.PASSED, theme1));
assertEquals(0, processResultDAO.getResultByThemeCount(wa, TestSolution.FAILED, theme1));
assertEquals(1, processResultDAO.getResultByThemeCount(wa, TestSolution.NEED_MORE_INFO, theme1));
assertEquals(0, processResultDAO.getResultByThemeCount(wa, TestSolution.NOT_APPLICABLE, theme1));
assertEquals(1, processResultDAO.getResultByThemeCount(wa, TestSolution.PASSED, theme2));
assertEquals(2, processResultDAO.getResultByThemeCount(wa, TestSolution.FAILED, theme2));
assertEquals(1, processResultDAO.getResultByThemeCount(wa, TestSolution.NEED_MORE_INFO, theme2));
assertEquals(0, processResultDAO.getResultByThemeCount(wa, TestSolution.NOT_APPLICABLE, theme2));
assertEquals(2, processResultDAO.getResultByThemeCount(wa, TestSolution.PASSED, null));
assertEquals(2, processResultDAO.getResultByThemeCount(wa, TestSolution.FAILED, null));
assertEquals(2, processResultDAO.getResultByThemeCount(wa, TestSolution.NEED_MORE_INFO, null));
assertEquals(0, processResultDAO.getResultByThemeCount(wa, TestSolution.NOT_APPLICABLE, null));
}
use of org.asqatasun.entity.reference.Theme 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.Theme 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);
}
use of org.asqatasun.entity.reference.Theme in project Asqatasun by Asqatasun.
the class CriterionResultFactory method prepareThemeResultMap.
/**
*
* @param netResultList
* @return
*/
private Map<Theme, List<CriterionResult>> prepareThemeResultMap(List<CriterionStatistics> criterionStatList) {
// Map that associates a list of results with a theme
Map<Theme, List<CriterionResult>> criterionResultMap = new LinkedHashMap<Theme, List<CriterionResult>>();
sortCollection(criterionStatList);
for (CriterionStatistics crs : criterionStatList) {
CriterionResult testResult = getCriterionResult(crs);
Theme theme = crs.getCriterion().getTheme();
if (criterionResultMap.containsKey(theme)) {
criterionResultMap.get(theme).add(testResult);
} else {
List<CriterionResult> criterionResultList = new ArrayList<CriterionResult>();
criterionResultList.add(testResult);
criterionResultMap.put(theme, criterionResultList);
}
}
return criterionResultMap;
}
use of org.asqatasun.entity.reference.Theme in project Asqatasun by Asqatasun.
the class TestResultFactory method getTestResultListFromCriterion.
/**
*
* @param webresource
* @param crit
* @return the test result list without user filter (used for the export
* function)
*/
public Map<Theme, List<TestResult>> getTestResultListFromCriterion(WebResource webresource, Criterion crit) {
// Map that associates a list of results with a theme
List<TestResult> testResultList = new LinkedList();
List<ProcessResult> netResultList = (List<ProcessResult>) processResultDataService.getProcessResultListByWebResourceAndCriterion(webresource, crit);
netResultList.addAll(addNotTestedProcessResult(testDataService.findAllByCriterion(crit), crit.getTheme().getCode(), netResultList));
sortCollection(netResultList);
for (ProcessResult processResult : netResultList) {
if (processResult instanceof DefiniteResult) {
TestResult testResult = getTestResult(processResult, true, false);
testResultList.add(testResult);
}
}
Map<Theme, List<TestResult>> testResultMap = new HashMap();
testResultMap.put(crit.getTheme(), testResultList);
return testResultMap;
}
Aggregations