Search in sources :

Example 21 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDataServiceImplTest method testUpdateParameterSet.

public void testUpdateParameterSet() {
    ParameterDataService pds = new ParameterDataServiceImpl();
    Set<Parameter> paramSet = new LinkedHashSet<Parameter>();
    for (int i = 0; i < 5; i++) {
        paramSet.add(getParameter(PARAM_FAMILY, PARAM_ELEMENT + String.valueOf(i), String.valueOf(i)));
    }
    assertEquals(5, paramSet.size());
    Iterator<Parameter> iter = paramSet.iterator();
    int val = 0;
    while (iter.hasNext()) {
        assertEquals(val, Integer.valueOf(iter.next().getValue()).intValue());
        val++;
    }
    Set<Parameter> paramToUpdate = new HashSet<Parameter>();
    for (int i = 2; i < 5; i++) {
        paramToUpdate.add(getParameter(PARAM_FAMILY, PARAM_ELEMENT + String.valueOf(i), String.valueOf(i + 10)));
    }
    assertEquals(3, paramToUpdate.size());
    paramSet = pds.updateParameterSet(paramSet, paramToUpdate);
    for (Parameter param : paramSet) {
        int length = param.getParameterElement().getParameterElementCode().length();
        int index = Integer.valueOf(param.getParameterElement().getParameterElementCode().substring(length - 1, length)).intValue();
        if (index < 2) {
            assertEquals(index, Integer.valueOf(param.getValue()).intValue());
        } else {
            assertEquals(index + 10, Integer.valueOf(param.getValue()).intValue());
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Parameter(org.asqatasun.entity.parameterization.Parameter) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 22 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDataServiceImplTest method testUpdateParameter.

public void testUpdateParameter() {
    ParameterDataService pds = new ParameterDataServiceImpl();
    Set<Parameter> paramSet = new LinkedHashSet<Parameter>();
    for (int i = 0; i < 5; i++) {
        paramSet.add(getParameter(PARAM_FAMILY, PARAM_ELEMENT + String.valueOf(i), String.valueOf(i)));
    }
    assertEquals(5, paramSet.size());
    paramSet = pds.updateParameter(paramSet, getParameter(PARAM_FAMILY, PARAM_ELEMENT + String.valueOf(3), String.valueOf(13)));
    for (Parameter param : paramSet) {
        if (param.getParameterElement().getParameterElementCode().equalsIgnoreCase(PARAM_ELEMENT + String.valueOf(3))) {
            assertEquals(13, Integer.valueOf(param.getValue()).intValue());
        } else {
            int length = param.getParameterElement().getParameterElementCode().length();
            assertEquals(Integer.valueOf(param.getParameterElement().getParameterElementCode().substring(length - 1, length)).intValue(), Integer.valueOf(param.getValue()).intValue());
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Parameter(org.asqatasun.entity.parameterization.Parameter)

Example 23 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class WebResourceStatisticsDataServiceImpl method setWeightedResult.

/**
 * @param wrStatistics
 */
private void setWeightedResult(WebResourceStatistics wrStatistics, WebResource webResource) {
    // TODO: Collection à initialiser
    Collection<Parameter> paramSet = new ArrayList<>();
    BigDecimal weightedPassed = this.getWeightedResultByResultType(webResource.getId(), paramSet, TestSolution.PASSED, true);
    BigDecimal weightedFailed = this.getWeightedResultByResultType(webResource.getId(), paramSet, TestSolution.FAILED, true);
    BigDecimal weightedNa = this.getWeightedResultByResultType(webResource.getId(), paramSet, TestSolution.NOT_APPLICABLE, true);
    BigDecimal weightedNmi = this.getWeightedResultByResultType(webResource.getId(), paramSet, TestSolution.NEED_MORE_INFO, true);
    wrStatistics.setWeightedFailed(weightedFailed);
    wrStatistics.setWeightedPassed(weightedPassed);
    wrStatistics.setWeightedNmi(weightedNmi);
    wrStatistics.setWeightedNa(weightedNa);
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.asqatasun.entity.parameterization.Parameter) BigDecimal(java.math.BigDecimal)

Example 24 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDAOImplTest method testFindDefaultParameterSet.

@Test
public void testFindDefaultParameterSet() {
    Set<Parameter> paramSet = parameterDAO.findDefaultParameterSet();
    assertEquals(2, paramSet.size());
    // and "Value5"
    for (Parameter param : paramSet) {
        if (param.getValue().equals("Value1") || param.getValue().equals("Value5")) {
            assertTrue(true);
        } else {
            assertTrue(false);
        }
    }
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) Test(org.junit.Test)

Example 25 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDataServiceImpl method getAuditPageParameterSet.

@Override
public Set<Parameter> getAuditPageParameterSet(Set<Parameter> defaultParameterSet) {
    ParameterElement parameterElement = parameterElementDataService.getDepthParameterElement();
    Parameter depthParameter = getParameter(parameterElement, "0");
    Set<Parameter> auditPageParamSet = updateParameter(defaultParameterSet, depthParameter);
    return auditPageParamSet;
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement)

Aggregations

Parameter (org.asqatasun.entity.parameterization.Parameter)59 ParameterElement (org.asqatasun.entity.parameterization.ParameterElement)13 Audit (org.asqatasun.entity.audit.Audit)8 ParameterImpl (org.asqatasun.entity.parameterization.ParameterImpl)6 NoResultException (javax.persistence.NoResultException)5 Query (javax.persistence.Query)5 HashSet (java.util.HashSet)4 AuditCommand (org.asqatasun.service.command.AuditCommand)4 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)4 Test (org.junit.Test)4 File (java.io.File)3 IOException (java.io.IOException)3 Crawler (org.asqatasun.crawler.Crawler)3 ParameterElementImpl (org.asqatasun.entity.parameterization.ParameterElementImpl)3 LinkedHashSet (java.util.LinkedHashSet)2 ParameterFamily (org.asqatasun.entity.parameterization.ParameterFamily)2 WebResourceStatisticsDataService (org.asqatasun.entity.service.statistics.WebResourceStatisticsDataService)2 WebResourceStatisticsDataServiceImpl (org.asqatasun.entity.service.statistics.WebResourceStatisticsDataServiceImpl)2 WebResourceStatistics (org.asqatasun.entity.statistics.WebResourceStatistics)2 WebResourceStatisticsFactory (org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactory)2