use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AsqatasunOrchestratorImpl method auditPage.
@Override
public Audit auditPage(Contract contract, String pageUrl, String clientIp, Set<Parameter> parameterSet, Locale locale) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Page audit on " + pageUrl);
for (Parameter param : parameterSet) {
LOGGER.debug("param " + param.getValue() + " " + param.getParameterElement().getParameterElementCode());
}
}
Act act = createAct(contract, ScopeEnum.PAGE, clientIp);
AuditTimeoutThread auditPageThread = new AuditPageThread(pageUrl, auditService, act, parameterSet, locale, delay);
Audit audit = submitAuditAndLaunch(auditPageThread, act);
return audit;
}
use of org.asqatasun.entity.audit.Audit 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.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceImplTest method testAuditScenario.
/**
* Test of auditPage method, of class AuditServiceImpl.
*/
public void testAuditScenario() {
System.out.println("auditScenario");
String scenarioName = "MyScenario";
String scenario = "";
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(scenarioName, scenario, null)).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 pageUpload audit
AuditServiceThreadQueue mockAuditServiceThreadQueue = EasyMock.createMock(AuditServiceThreadQueue.class);
mockAuditServiceThreadQueue.add(instance);
EasyMock.expectLastCall().anyTimes();
mockAuditServiceThreadQueue.addScenarioAudit(mockAuditCommand);
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(mockAuditServiceThreadQueue);
instance.setAuditServiceThreadQueue(mockAuditServiceThreadQueue);
Audit result = instance.auditScenario(scenarioName, scenario, null);
assertEquals(auditCreateByAuditCommand, result);
EasyMock.verify(mockAuditServiceThreadQueue);
EasyMock.verify(mockAuditCommand);
EasyMock.verify(mockAuditCommandFactory);
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceThreadImplTest method testGetAudit.
/**
* Test of getAudit method, of class AuditServiceThreadImpl.
*/
public void testGetAudit() {
System.out.println("getAudit");
Audit audit = createMock(Audit.class);
Audit auditReturnedByAuditCommand = createMock(Audit.class);
AuditCommand mockAuditCommand = createMock(AuditCommand.class);
expect(mockAuditCommand.getAudit()).andReturn(auditReturnedByAuditCommand);
replay(mockAuditCommand);
AuditServiceThreadImpl instance = initialiseAuditServiceThread(audit);
assertEquals(audit, instance.getAudit());
instance = initialiseAuditServiceThread(mockAuditCommand);
assertEquals(auditReturnedByAuditCommand, instance.getAudit());
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceThreadImplTest method testRun.
/**
* Test of run method, of class AuditServiceThreadImpl.
*/
public void testRun() {
System.out.println("run");
Audit mockAudit = createMock(Audit.class);
expect(mockAudit.getId()).andReturn(1l).anyTimes();
AuditCommand mockAuditCommand = createMock(AuditCommand.class);
mockAuditCommand.init();
expectLastCall().once();
mockAuditCommand.loadContent();
expectLastCall().once();
mockAuditCommand.adaptContent();
expectLastCall().once();
mockAuditCommand.process();
expectLastCall().once();
mockAuditCommand.consolidate();
expectLastCall().once();
mockAuditCommand.analyse();
expectLastCall().once();
expect(mockAuditCommand.getAudit()).andReturn(mockAudit).anyTimes();
replay(mockAudit);
replay(mockAuditCommand);
AuditServiceThreadImpl instance = initialiseAuditServiceThread(mockAuditCommand);
AuditServiceThreadListener auditServiceThreadListener = createMock(AuditServiceThreadListener.class);
auditServiceThreadListener.auditCompleted(instance);
expectLastCall().once();
replay(auditServiceThreadListener);
instance.add(auditServiceThreadListener);
instance.run();
verify(mockAudit);
verify(mockAuditCommand);
verify(auditServiceThreadListener);
}
Aggregations