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