Search in sources :

Example 1 with Parameter

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

the class AuditServiceImplTest method testAuditGroupOfPages.

/**
     * Test of auditPage method, of class AuditServiceImpl.
     */
public void testAuditGroupOfPages() {
    System.out.println("auditGroupOfPages");
    String siteUrl = "http://My.testUrl.org";
    String pageUrl = "http://My.testUrlPage1.org";
    Set<Parameter> paramSet = null;
    List<String> urlList = new ArrayList<>();
    urlList.add(pageUrl);
    AuditServiceImpl instance = initialiseAuditService();
    Audit auditCreateByAuditCommand = EasyMock.createMock(Audit.class);
    AuditCommand mockAuditCommand = EasyMock.createMock(AuditCommand.class);
    EasyMock.expect(mockAuditCommand.getAudit()).andReturn(auditCreateByAuditCommand).anyTimes();
    EasyMock.replay(mockAuditCommand);
    AuditCommandFactory mockAuditCommandFactory = EasyMock.createMock(AuditCommandFactory.class);
    EasyMock.expect(mockAuditCommandFactory.create(siteUrl, urlList, paramSet)).andReturn(mockAuditCommand).anyTimes();
    EasyMock.replay(mockAuditCommandFactory);
    instance.setAuditCommandFactory(mockAuditCommandFactory);
    // anyTimes the audit is created and set-up, the auditServiceThreadQueue is 
    // called to effectively launch the site audit
    AuditServiceThreadQueue mockAuditServiceThreadQueue = EasyMock.createMock(AuditServiceThreadQueue.class);
    mockAuditServiceThreadQueue.add(instance);
    EasyMock.expectLastCall().anyTimes();
    mockAuditServiceThreadQueue.addPageAudit(mockAuditCommand);
    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(mockAuditServiceThreadQueue);
    instance.setAuditServiceThreadQueue(mockAuditServiceThreadQueue);
    Audit result = instance.auditSite(siteUrl, urlList, paramSet);
    assertEquals(auditCreateByAuditCommand, result);
    EasyMock.verify(mockAuditServiceThreadQueue);
    EasyMock.verify(mockAuditCommand);
    EasyMock.verify(mockAuditCommandFactory);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommandFactory(org.asqatasun.service.command.factory.AuditCommandFactory) Parameter(org.asqatasun.entity.parameterization.Parameter) AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 2 with Parameter

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

the class Asqatasun method runAuditUpload.

public void runAuditUpload(String[] uploadFilePath, String asqatasunHome, String ref, String level) {
    initServices(asqatasunHome);
    Set<Parameter> paramSet = getParameterSetFromAuditLevel(ref, level);
    Map<String, String> fileMap = new HashMap<>();
    for (String file : Arrays.asList(uploadFilePath)) {
        File uploadFile = new File(file);
        try {
            fileMap.put(uploadFile.getName(), readFile(uploadFile));
        } catch (IOException ex) {
            System.out.println("Unreadable upload file");
            System.exit(0);
        }
    }
    auditService.auditPageUpload(fileMap, paramSet);
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) IOException(java.io.IOException) File(java.io.File)

Example 3 with Parameter

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

the class Asqatasun method getAuditPageParameterSet.

/**
     * The default parameter set embeds a depth value that corresponds to the
     * site audit. We need here to replace this parameter by a parameter value
     * equals to 0.
     *
     * @return
     */
private Set<Parameter> getAuditPageParameterSet(Set<Parameter> defaultParameterSet) {
    ParameterElement parameterElement = parameterElementDataService.getParameterElement("DEPTH");
    Parameter depthParameter = parameterDataService.getParameter(parameterElement, "0");
    Set<Parameter> auditPageParamSet = parameterDataService.updateParameter(defaultParameterSet, depthParameter);
    return auditPageParamSet;
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement)

Example 4 with Parameter

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

the class Asqatasun method runAuditScenario.

public void runAuditScenario(String scenarioFilePath, String asqatasunHome, String ref, String level) {
    initServices(asqatasunHome);
    Set<Parameter> paramSet = getParameterSetFromAuditLevel(ref, level);
    System.out.println(scenarioFilePath);
    File scenarioFile = new File(scenarioFilePath);
    try {
        auditService.auditScenario(scenarioFile.getName(), readFile(scenarioFile), paramSet);
    } catch (IOException ex) {
        System.out.println("Unreadable scenario file");
        System.exit(0);
    }
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) IOException(java.io.IOException) File(java.io.File)

Example 5 with Parameter

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

the class Asqatasun method getParameterSetFromAuditLevel.

/**
     * 
     * @param auditLevel
     * @return 
     */
private Set<Parameter> getParameterSetFromAuditLevel(String ref, String level) {
    if (ref.equalsIgnoreCase(RGAA30_REF) || ref.equalsIgnoreCase(RGAA32016_REF)) {
        if (level.equalsIgnoreCase(BRONZE_LEVEL)) {
            level = A_LEVEL;
        } else if (level.equalsIgnoreCase(SILVER_LEVEL)) {
            level = AA_LEVEL;
        } else if (level.equalsIgnoreCase(GOLD_LEVEL)) {
            level = AAA_LEVEL;
        }
    }
    if (level.equalsIgnoreCase(BRONZE_LEVEL) || level.equalsIgnoreCase(A_LEVEL)) {
        level = LEVEL_1;
    } else if (level.equalsIgnoreCase(SILVER_LEVEL) || level.equalsIgnoreCase(AA_LEVEL)) {
        level = LEVEL_2;
    } else if (level.equalsIgnoreCase(GOLD_LEVEL) || level.equalsIgnoreCase(AAA_LEVEL)) {
        level = LEVEL_3;
    }
    ParameterElement levelParameterElement = parameterElementDataService.getParameterElement(LEVEL_PARAMETER_ELEMENT_CODE);
    Parameter levelParameter = parameterDataService.getParameter(levelParameterElement, ref + ";" + level);
    Set<Parameter> paramSet = parameterDataService.getDefaultParameterSet();
    return parameterDataService.updateParameter(paramSet, levelParameter);
}
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