Search in sources :

Example 1 with Test

use of org.asqatasun.entity.reference.Test in project Asqatasun by Asqatasun.

the class WebResourceStatisticsDAOImpl method findWeightedResultCountByResultType.

@Override
public BigDecimal findWeightedResultCountByResultType(Long webresourceId, Collection<Parameter> paramSet, TestSolution testSolution, boolean isManualAudit) {
    if (webresourceId == null) {
        return null;
    }
    String queryStringForAutomatic = "SELECT t FROM " + getWebResourceEntityClass().getName() + " r" + JOIN_PROCESS_RESULT + JOIN_TEST + " WHERE (r.id=:id OR r.parent.id=:id)" + " AND pr.definiteValue = :value";
    String queryStringForManual = "SELECT t FROM " + getWebResourceEntityClass().getName() + " r" + JOIN_PROCESS_RESULT + JOIN_TEST + " WHERE (r.id=:id OR r.parent.id=:id)" + " AND pr.manualDefiniteValue = :value";
    Query query;
    if (isManualAudit) {
        query = entityManager.createQuery(queryStringForManual);
    } else {
        query = entityManager.createQuery(queryStringForAutomatic);
    }
    query.setParameter("id", webresourceId);
    query.setParameter("value", testSolution);
    try {
        return computeWeightedCountFromTestList((List<Test>) query.getResultList(), paramSet);
    } catch (NoResultException e) {
        return null;
    }
}
Also used : Query(javax.persistence.Query) Test(org.asqatasun.entity.reference.Test) NoResultException(javax.persistence.NoResultException)

Example 2 with Test

use of org.asqatasun.entity.reference.Test in project Asqatasun by Asqatasun.

the class WebResourceStatisticsDAOImpl method computeWeightedCountFromTestList.

/**
	 * 
	 * @param testList
	 * @param paramSet
	 * @return
	 */
private BigDecimal computeWeightedCountFromTestList(List<Test> testList, Collection<Parameter> paramSet) {
    BigDecimal weightedCount = BigDecimal.ZERO;
    for (Test test : testList) {
        BigDecimal weight = getTestWeightFromParameter(test, paramSet);
        if (weight == null) {
            weight = test.getWeight();
        }
        weightedCount = weightedCount.add(weight);
    }
    return weightedCount;
}
Also used : Test(org.asqatasun.entity.reference.Test) BigDecimal(java.math.BigDecimal)

Example 3 with Test

use of org.asqatasun.entity.reference.Test in project Asqatasun by Asqatasun.

the class ChangeTestWeightCommandFactory method getChangeTestWeightCommand.

/**
     * 
     * @param user
     * @param locale
     * @param testList
     * @param referentialKey
     * @return 
     *      an initialised instance of ChangeTestWeightCommand
     */
public ChangeTestWeightCommand getChangeTestWeightCommand(User user, Locale locale, Collection<Test> testList, String referentialKey) {
    Map<String, String> userTestWeight = new HashMap<String, String>();
    NumberFormat nf = NumberFormat.getNumberInstance(locale);
    nf.setMinimumFractionDigits(1);
    nf.setMaximumFractionDigits(1);
    nf.setMaximumIntegerDigits(1);
    nf.setMinimumIntegerDigits(1);
    for (OptionElement oe : optionElementDataService.getOptionElementFromUserAndFamilyCode(user, referentialKey + "_" + optionFamilyCodeStr)) {
        userTestWeight.put(oe.getOption().getCode(), nf.format(Double.valueOf(oe.getValue())));
    }
    for (Test test : testList) {
        if (!userTestWeight.containsKey(test.getCode())) {
            userTestWeight.put(test.getCode(), "");
        }
    }
    ChangeTestWeightCommand changeTestWeightCommand = new ChangeTestWeightCommand();
    changeTestWeightCommand.setTestWeightMap(userTestWeight);
    return changeTestWeightCommand;
}
Also used : Test(org.asqatasun.entity.reference.Test) OptionElement(org.asqatasun.webapp.entity.option.OptionElement) NumberFormat(java.text.NumberFormat) ChangeTestWeightCommand(org.asqatasun.webapp.command.ChangeTestWeightCommand)

Example 4 with Test

use of org.asqatasun.entity.reference.Test in project Asqatasun by Asqatasun.

the class AbstractRuleImplementationTestCase method setUpClass.

/**
     * 
     */
private void setUpClass() {
    Test test = TEST_FACTORY.create();
    test.setCode(this.getName());
    test.setRuleClassName(ruleImplementationClassName);
    test.setRuleArchiveName("MockArchiveName");
    testList.add(test);
    URL src = null;
    LOGGER.info("setUpClass()");
    for (WebResource webResource : webResourceMap.values()) {
        LOGGER.info("webResource.getURL() " + webResource.getURL());
        contentMap.put(webResource, CONTENT_LOADER_SERVICE.loadContent(webResource));
        if (relatedContentMap.get(webResource) != null) {
            for (String contentUrl : relatedContentMap.get(webResource)) {
                if (contentMap.get(webResource).get(0) instanceof SSP) {
                    SSP ssp = (SSP) contentMap.get(webResource).get(0);
                    try {
                        src = new URL(ssp.getURI());
                        URL_IDENTIFIER.setUrl(src);
                    } catch (MalformedURLException ex) {
                        LOGGER.error(ex);
                    }
                    URL_IDENTIFIER.setUrl(src);
                    String relatedContentUrl = URL_IDENTIFIER.resolve(contentUrl).toExternalForm();
                    if (isContentCss(relatedContentUrl)) {
                        ssp.addRelatedContent(CONTENT_FACTORY.createStylesheetContent(new Date(), relatedContentUrl, ssp, getTextContent(relatedContentUrl), 200));
                    } else {
                        ssp.addRelatedContent(CONTENT_FACTORY.createImageContent(new Date(), relatedContentUrl, ssp, getBinaryImage(relatedContentUrl), 200));
                    }
                }
            }
        }
        contentMap.put(webResource, (List<Content>) CONTENT_ADAPTER_SERVICE.adaptContent((contentMap.get(webResource))));
    }
}
Also used : SSP(org.asqatasun.entity.audit.SSP) MalformedURLException(java.net.MalformedURLException) Test(org.asqatasun.entity.reference.Test) Content(org.asqatasun.entity.audit.Content) WebResource(org.asqatasun.entity.subject.WebResource) URL(java.net.URL)

Example 5 with Test

use of org.asqatasun.entity.reference.Test in project Asqatasun by Asqatasun.

the class TestResultFactory method getProcessResultListFromTestsResult.

// TO DO : determine the difference between this method and the next one
// The code seems to be a duplication
public List<ProcessResult> getProcessResultListFromTestsResult(Map<String, ManualResult> overriddenResultMap, WebResource webResource) {
    List<ProcessResult> processResultList = new LinkedList();
    Audit audit = webResource.getAudit();
    for (Map.Entry<String, ManualResult> entry : overriddenResultMap.entrySet()) {
        if (StringUtils.isNotBlank(entry.getValue().getResult())) {
            Test test = testDataService.getTestFromAuditAndLabel(audit, entry.getKey());
            List<ProcessResult> prList = ((List<ProcessResult>) processResultDataService.getProcessResultListByWebResourceAndTest(webResource, test));
            /**
                 * If returned process result list doesn't contains elements
                 * that means the test is NOT_TESTED and has to be created to
                 * persist the manual audit value
                 */
            ProcessResult processResult;
            if (prList.isEmpty()) {
                processResult = createNotTestedProcessResult(test, webResource);
            } else {
                processResult = prList.get(0);
            }
            processResult.setManualValue(entry.getValue().getResult().equals(TestResult.FAILED_LOWER) ? TestSolution.FAILED : (entry.getValue().getResult().equals(TestResult.PASSED_LOWER) ? TestSolution.PASSED : TestSolution.NOT_APPLICABLE));
            if (StringUtils.isNotBlank(entry.getValue().getComment())) {
                ((DefiniteResult) processResult).setManualAuditComment(entry.getValue().getComment());
            }
            processResultList.add(processResult);
        }
    }
    return processResultList;
}
Also used : ManualResult(org.asqatasun.webapp.presentation.data.ManualResult) Test(org.asqatasun.entity.reference.Test)

Aggregations

Test (org.asqatasun.entity.reference.Test)17 ProcessResult (org.asqatasun.entity.audit.ProcessResult)3 ArrayList (java.util.ArrayList)2 Audit (org.asqatasun.entity.audit.Audit)2 Content (org.asqatasun.entity.audit.Content)2 SSP (org.asqatasun.entity.audit.SSP)2 Reference (org.asqatasun.entity.reference.Reference)2 Theme (org.asqatasun.entity.reference.Theme)2 WebResource (org.asqatasun.entity.subject.WebResource)2 RuleImplementation (org.asqatasun.ruleimplementation.RuleImplementation)2 ManualResult (org.asqatasun.webapp.presentation.data.ManualResult)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 BigDecimal (java.math.BigDecimal)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 NumberFormat (java.text.NumberFormat)1 NoResultException (javax.persistence.NoResultException)1 Query (javax.persistence.Query)1 Consolidator (org.asqatasun.consolidator.Consolidator)1 AuditImpl (org.asqatasun.entity.audit.AuditImpl)1