Search in sources :

Example 1 with WebResourceStatistics

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);
}
Also used : Site(org.asqatasun.entity.subject.Site) Page(org.asqatasun.entity.subject.Page) WebResourceStatistics(org.asqatasun.entity.statistics.WebResourceStatistics)

Example 2 with WebResourceStatistics

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());
}
Also used : WebResourceStatisticsFactory(org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactory) WebResourceStatisticsDataServiceImpl(org.asqatasun.entity.service.statistics.WebResourceStatisticsDataServiceImpl) Parameter(org.asqatasun.entity.parameterization.Parameter) WebResourceStatisticsDataService(org.asqatasun.entity.service.statistics.WebResourceStatisticsDataService) WebResourceStatistics(org.asqatasun.entity.statistics.WebResourceStatistics) WebResourceStatisticsFactoryImpl(org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactoryImpl)

Example 3 with WebResourceStatistics

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;
    }
}
Also used : Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) WebResourceStatistics(org.asqatasun.entity.statistics.WebResourceStatistics)

Example 4 with WebResourceStatistics

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;
    }
}
Also used : Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) WebResourceStatistics(org.asqatasun.entity.statistics.WebResourceStatistics)

Example 5 with WebResourceStatistics

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());
}
Also used : WebResourceStatisticsFactory(org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactory) WebResourceStatisticsDataServiceImpl(org.asqatasun.entity.service.statistics.WebResourceStatisticsDataServiceImpl) Parameter(org.asqatasun.entity.parameterization.Parameter) WebResourceStatisticsDataService(org.asqatasun.entity.service.statistics.WebResourceStatisticsDataService) WebResourceStatistics(org.asqatasun.entity.statistics.WebResourceStatistics) WebResourceStatisticsFactoryImpl(org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactoryImpl)

Aggregations

WebResourceStatistics (org.asqatasun.entity.statistics.WebResourceStatistics)6 NoResultException (javax.persistence.NoResultException)2 Query (javax.persistence.Query)2 Parameter (org.asqatasun.entity.parameterization.Parameter)2 WebResourceStatisticsDataService (org.asqatasun.entity.service.statistics.WebResourceStatisticsDataService)2 WebResourceStatisticsDataServiceImpl (org.asqatasun.entity.service.statistics.WebResourceStatisticsDataServiceImpl)2 WebResourceStatisticsFactory (org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactory)2 WebResourceStatisticsFactoryImpl (org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactoryImpl)2 HashMap (java.util.HashMap)1 ProcessResult (org.asqatasun.entity.audit.ProcessResult)1 TestSolution (org.asqatasun.entity.audit.TestSolution)1 WebResourceStatisticsDAO (org.asqatasun.entity.dao.statistics.WebResourceStatisticsDAO)1 Criterion (org.asqatasun.entity.reference.Criterion)1 Theme (org.asqatasun.entity.reference.Theme)1 CriterionStatistics (org.asqatasun.entity.statistics.CriterionStatistics)1 ThemeStatistics (org.asqatasun.entity.statistics.ThemeStatistics)1 Page (org.asqatasun.entity.subject.Page)1 Site (org.asqatasun.entity.subject.Site)1