use of org.asqatasun.entity.statistics.WebResourceStatistics in project Asqatasun by Asqatasun.
the class AnalyserImpl method run.
@Override
public void run() {
WebResourceStatistics wrStats = webResourceStatisticsDataService.create();
// 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);
}
use of org.asqatasun.entity.statistics.WebResourceStatistics in project Asqatasun by Asqatasun.
the class AnalyserImplTest method testComputeMark.
public void testComputeMark() {
WebResourceStatisticsFactory webResourceStatisticsFactory = new WebResourceStatisticsFactoryImpl();
WebResourceStatisticsDataService webResourceStatisticsDataService = new WebResourceStatisticsDataServiceImpl();
webResourceStatisticsDataService.setEntityFactory(webResourceStatisticsFactory);
AnalyserImpl analyser = new AnalyserImpl(null, null, null, webResourceStatisticsDataService, null, null, null, new ArrayList<Parameter>(), 1);
WebResourceStatistics wrStats = analyser.getWebResourceStatisticsDataService().create();
wrStats.setNbOfPassed(89330);
wrStats.setNbOfFailed(84541);
wrStats.setNbOfNmi(97541);
assertEquals(Double.valueOf(45.828712).floatValue(), analyser.computeMark(wrStats).getMark());
wrStats.setNbOfPassed(0);
wrStats.setNbOfFailed(0);
wrStats.setNbOfNmi(0);
assertEquals(Double.valueOf(0).floatValue(), analyser.computeMark(wrStats).getMark());
}
use of org.asqatasun.entity.statistics.WebResourceStatistics in project Asqatasun by Asqatasun.
the class WebResourceStatisticsDAOImpl method findWebResourceStatisticsByWebResource.
/**
* {@inheritDoc}
*/
@Override
public WebResourceStatistics findWebResourceStatisticsByWebResource(WebResource webResource, boolean manual) {
if (webResource == null) {
return null;
}
Query query = entityManager.createQuery("SELECT s FROM " + getEntityClass().getName() + " s" + " WHERE s.webResource=:webResource" + " AND s.isManualAuditStatistics=:manual");
query.setParameter("webResource", webResource);
query.setParameter("manual", manual ? 1 : 0);
try {
return (WebResourceStatistics) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of org.asqatasun.entity.statistics.WebResourceStatistics in project Asqatasun by Asqatasun.
the class WebResourceStatisticsDAOImpl method findWebResourceStatisticsByWebResource.
@Override
public WebResourceStatistics findWebResourceStatisticsByWebResource(WebResource webResource) {
// TODO :YNE we can do so by adding a new critorion manualAudit !=1 (That can return the automatic audit stats)
if (webResource == null) {
return null;
}
Query query = entityManager.createQuery("SELECT s FROM " + getEntityClass().getName() + " s" + " WHERE s.webResource=:webResource");
query.setParameter("webResource", webResource);
try {
return (WebResourceStatistics) query.getSingleResult();
} catch (NoResultException e) {
return null;
} catch (NullPointerException e) {
return null;
}
}
use of org.asqatasun.entity.statistics.WebResourceStatistics in project Asqatasun by Asqatasun.
the class AnalyserImplTest method testComputeRawMark.
public void testComputeRawMark() {
WebResourceStatisticsFactory webResourceStatisticsFactory = new WebResourceStatisticsFactoryImpl();
WebResourceStatisticsDataService webResourceStatisticsDataService = new WebResourceStatisticsDataServiceImpl();
webResourceStatisticsDataService.setEntityFactory(webResourceStatisticsFactory);
AnalyserImpl analyser = new AnalyserImpl(null, null, null, webResourceStatisticsDataService, null, null, null, new ArrayList<Parameter>(), 1);
WebResourceStatistics wrStats = analyser.getWebResourceStatisticsDataService().create();
wrStats.setNbOfPassed(0);
wrStats.setNbOfFailed(0);
wrStats.setNbOfNmi(0);
// wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("0.0")));
wrStats.setWeightedFailed(BigDecimal.valueOf(Double.valueOf("0.0")));
wrStats.setWeightedNmi(BigDecimal.valueOf(Double.valueOf("21.1")));
wrStats.setWeightedNa(BigDecimal.valueOf(Double.valueOf("114.2")));
assertEquals(Double.valueOf(0).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
// wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("44.0")));
// assertEquals(Double.valueOf(100).floatValue(), analyser.computeRawMark(wrStats).getRawMark().floatValue());
// wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("0")));
wrStats.setWeightedFailed(BigDecimal.valueOf(Double.valueOf("44.0")));
assertEquals(Double.valueOf(0).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
wrStats.setNbOfPassed(45);
wrStats.setNbOfFailed(84541);
wrStats.setNbOfNmi(97541);
// wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("10.4")));
wrStats.setWeightedFailed(BigDecimal.valueOf(Double.valueOf("44.8")));
wrStats.setWeightedNmi(BigDecimal.valueOf(Double.valueOf("21.1")));
wrStats.setWeightedNa(BigDecimal.valueOf(Double.valueOf("114.2")));
assertEquals(Double.valueOf(50.11).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
// the nmi value is not taken into account
wrStats.setWeightedNmi(BigDecimal.valueOf(Double.valueOf("1.1")));
wrStats.setWeightedNa(BigDecimal.valueOf(Double.valueOf("134.4")));
assertEquals(Double.valueOf(50.11).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("50.4")));
wrStats.setWeightedFailed(BigDecimal.valueOf(Double.valueOf("24.8")));
assertEquals(Double.valueOf(64.47).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
}
Aggregations