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;
}
}
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;
}
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;
}
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))));
}
}
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;
}
Aggregations