use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditSynthesisController method displayAuditSynthesisFromContract.
/**
*
* @param auditId
* @param request
* @param response
* @param model
* @return
*/
@RequestMapping(value = TgolKeyStore.AUDIT_SYNTHESIS_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String displayAuditSynthesisFromContract(@RequestParam(TgolKeyStore.AUDIT_ID_KEY) String auditId, HttpServletRequest request, HttpServletResponse response, Model model) {
Long aId;
try {
aId = Long.valueOf(auditId);
} catch (NumberFormatException nfe) {
throw new ForbiddenPageException();
}
Audit audit = getAuditDataService().read(aId);
if (isUserAllowedToDisplayResult(audit)) {
if (isAuthorizedScopeForSynthesis(audit)) {
Contract contract = retrieveContractFromAudit(audit);
model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, auditId);
model.addAttribute(TgolKeyStore.WEBRESOURCE_ID_KEY, audit.getSubject().getId());
return prepareSynthesisSiteData(audit, model);
} else {
throw new ForbiddenPageException();
}
} else {
throw new ForbiddenUserException();
}
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AsqatasunOrchestratorImpl method auditPageUpload.
@Override
public Audit auditPageUpload(Contract contract, Map<String, String> fileMap, String clientIp, Set<Parameter> parameterSet, Locale locale) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("auditPage Upload on " + fileMap.size() + " files");
for (Parameter param : parameterSet) {
LOGGER.debug("param " + param.getValue() + " " + param.getParameterElement().getParameterElementCode());
}
}
Act act;
if (fileMap.size() > 1) {
act = createAct(contract, ScopeEnum.GROUPOFFILES, clientIp);
} else {
act = createAct(contract, ScopeEnum.FILE, clientIp);
}
AuditTimeoutThread auditPageUploadThread = new AuditPageUploadThread(fileMap, auditService, act, parameterSet, locale, delay);
Audit audit = submitAuditAndLaunch(auditPageUploadThread, act);
return audit;
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class ActInfoFactory method getActInfo.
/**
*
* @param act
* @return an ActInfo instance that handles displayable act data
*
*/
public ActInfo getActInfo(Act act) {
ActInfoImpl actInfo = new ActInfoImpl();
actInfo.setDate(act.getEndDate());
if (act.getAudit() != null) {
Audit audit = act.getAudit();
actInfo.setAuditId(audit.getId().intValue());
actInfo.setScope(act.getScope().getCode().name());
WebResource wr = audit.getSubject();
if (wr != null) {
actInfo.setUrl(wr.getURL());
}
//cas automatique
if (audit.getStatus().equals(AuditStatus.COMPLETED) || audit.getStatus().equals(AuditStatus.MANUAL_INITIALIZING) || audit.getStatus().equals(AuditStatus.MANUAL_ANALYSE_IN_PROGRESS) || audit.getStatus().equals(AuditStatus.MANUAL_COMPLETED)) {
actInfo.setWeightedMark(statisticsDataService.getMarkByWebResourceAndAudit(wr, false, false).intValue());
actInfo.setRawMark(statisticsDataService.getMarkByWebResourceAndAudit(wr, true, false).intValue());
if (actInfo.getRawMark() == -1) {
actInfo.setRawMark(0);
}
actInfo.setStatus(TgolKeyStore.COMPLETED_KEY);
} else if (!contentDataService.hasContent(audit)) {
actInfo.setStatus(TgolKeyStore.ERROR_LOADING_KEY);
} else if (!contentDataService.hasAdaptedSSP(audit)) {
actInfo.setStatus(TgolKeyStore.ERROR_ADAPTING_KEY);
} else {
actInfo.setStatus(TgolKeyStore.ERROR_UNKNOWN_KEY);
}
//cas manual
actInfo.setManual(audit.getStatus().equals(AuditStatus.MANUAL_INITIALIZING) || audit.getStatus().equals(AuditStatus.MANUAL_ANALYSE_IN_PROGRESS) || audit.getStatus().equals(AuditStatus.MANUAL_COMPLETED));
if (actInfo.isManual()) {
actInfo.setDateManual(audit.getManualAuditDateOfCreation());
actInfo.setWeightedMarkManual(statisticsDataService.getMarkByWebResourceAndAudit(wr, false, true).intValue());
actInfo.setRawMarkManual(statisticsDataService.getMarkByWebResourceAndAudit(wr, true, true).intValue());
if (audit.getStatus().equals(AuditStatus.MANUAL_COMPLETED)) {
actInfo.setStatusManual(TgolKeyStore.COMPLETED_KEY);
} else if (audit.getStatus().equals(AuditStatus.MANUAL_ANALYSE_IN_PROGRESS) || audit.getStatus().equals(AuditStatus.MANUAL_INITIALIZING)) {
actInfo.setStatusManual(TgolKeyStore.ONGOING_KEY);
} else {
actInfo.setStatusManual(TgolKeyStore.ERROR_UNKNOWN_KEY);
}
}
setActInfoReferential(actInfo, audit);
}
return actInfo;
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceImplTest method testAuditCompleted.
// /**
// * Test of init method, of class AuditServiceImpl.
// */
// public void testInit() {
// AuditServiceImpl instance = initialiseAuditService();
//
// Audit audit = EasyMock.createMock(Audit.class);
// Audit auditReturnedByInitMethodOfAuditServiceThread =
// EasyMock.createMock(Audit.class);
//
// AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
//
// mockAuditServiceThread.init();
// EasyMock.expectLastCall();
// EasyMock.expect(mockAuditServiceThread.getAudit()).
// andReturn(auditReturnedByInitMethodOfAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThread);
//
// EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).
// andReturn(mockAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThreadFactory);
//
// assertEquals(auditReturnedByInitMethodOfAuditServiceThread,
// instance.init(audit));
//
// EasyMock.verify(mockAuditServiceThread);
// EasyMock.verify(mockAuditServiceThreadFactory);
// }
// /**
// * Test of crawl method, of class AuditServiceImpl.
// */
// public void testCrawl() {
// AuditServiceImpl instance = initialiseAuditService();
//
// Audit audit = EasyMock.createMock(Audit.class);
// Audit auditReturnedByCrawlMethodOfAuditServiceThread =
// EasyMock.createMock(Audit.class);
//
// AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
//
// mockAuditServiceThread.loadContent();
// EasyMock.expectLastCall();
// EasyMock.expect(mockAuditServiceThread.getAudit()).
// andReturn(auditReturnedByCrawlMethodOfAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThread);
//
// EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).
// andReturn(mockAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThreadFactory);
//
// assertEquals(auditReturnedByCrawlMethodOfAuditServiceThread,
// instance.crawl(audit));
//
// EasyMock.verify(mockAuditServiceThread);
// EasyMock.verify(mockAuditServiceThreadFactory);
// }
// /**
// * Test of loadContent method, of class AuditServiceImpl.
// */
// public void testLoadContent() {
// AuditServiceImpl instance = initialiseAuditService();
//
// Audit audit = EasyMock.createMock(Audit.class);
// Audit auditReturnedByLoadContentMethodOfAuditServiceThread =
// EasyMock.createMock(Audit.class);
//
// AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
//
// mockAuditServiceThread.loadContent();
// EasyMock.expectLastCall();
// EasyMock.expect(mockAuditServiceThread.getAudit()).
// andReturn(auditReturnedByLoadContentMethodOfAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThread);
//
// EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).
// andReturn(mockAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThreadFactory);
//
// assertEquals(auditReturnedByLoadContentMethodOfAuditServiceThread,
// instance.loadContent(audit));
//
// EasyMock.verify(mockAuditServiceThread);
// EasyMock.verify(mockAuditServiceThreadFactory);
// }
// /**
// * Test of loadScenario method, of class AuditServiceImpl.
// */
// public void testLoadScenario() {
// AuditServiceImpl instance = initialiseAuditService();
//
// Audit audit = EasyMock.createMock(Audit.class);
// Audit auditReturnedByLoadScenarioMethodOfAuditServiceThread =
// EasyMock.createMock(Audit.class);
//
// AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
//
// mockAuditServiceThread.loadContent();
// EasyMock.expectLastCall();
// EasyMock.expect(mockAuditServiceThread.getAudit()).
// andReturn(auditReturnedByLoadScenarioMethodOfAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThread);
//
// EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).
// andReturn(mockAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThreadFactory);
//
// assertEquals(auditReturnedByLoadScenarioMethodOfAuditServiceThread,
// instance.loadScenario(audit));
//
// EasyMock.verify(mockAuditServiceThread);
// EasyMock.verify(mockAuditServiceThreadFactory);
// }
// /**
// * Test of adaptContent method, of class AuditServiceImpl.
// */
// public void testAdaptContent() {
// AuditServiceImpl instance = initialiseAuditService();
//
// Audit audit = EasyMock.createMock(Audit.class);
// Audit auditReturnedByAdaptContentMethodOfAuditServiceThread =
// EasyMock.createMock(Audit.class);
//
// AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
//
// mockAuditServiceThread.adaptContent();
// EasyMock.expectLastCall();
// EasyMock.expect(mockAuditServiceThread.getAudit()).
// andReturn(auditReturnedByAdaptContentMethodOfAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThread);
//
// EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).
// andReturn(mockAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThreadFactory);
//
// assertEquals(auditReturnedByAdaptContentMethodOfAuditServiceThread,
// instance.adaptContent(audit));
//
// EasyMock.verify(mockAuditServiceThread);
// EasyMock.verify(mockAuditServiceThreadFactory);
// }
// /**
// * Test of process method, of class AuditServiceImpl.
// */
// public void testProcess() {
// AuditServiceImpl instance = initialiseAuditService();
//
// Audit audit = EasyMock.createMock(Audit.class);
// Audit auditReturnedByProcessMethodOfAuditServiceThread =
// EasyMock.createMock(Audit.class);
//
// AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
//
// mockAuditServiceThread.process();
// EasyMock.expectLastCall();
// EasyMock.expect(mockAuditServiceThread.getAudit()).
// andReturn(auditReturnedByProcessMethodOfAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThread);
//
// EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).
// andReturn(mockAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThreadFactory);
//
// assertEquals(auditReturnedByProcessMethodOfAuditServiceThread,
// instance.process(audit));
//
// EasyMock.verify(mockAuditServiceThread);
// EasyMock.verify(mockAuditServiceThreadFactory);
// }
// /**
// * Test of consolidate method, of class AuditServiceImpl.
// */
// public void testConsolidate() {
// AuditServiceImpl instance = initialiseAuditService();
//
// Audit audit = EasyMock.createMock(Audit.class);
// Audit auditReturnedByConsolidateMethodOfAuditServiceThread =
// EasyMock.createMock(Audit.class);
//
// AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
//
// mockAuditServiceThread.consolidate();
// EasyMock.expectLastCall();
// EasyMock.expect(mockAuditServiceThread.getAudit()).
// andReturn(auditReturnedByConsolidateMethodOfAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThread);
//
// EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).
// andReturn(mockAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThreadFactory);
//
// assertEquals(auditReturnedByConsolidateMethodOfAuditServiceThread,
// instance.consolidate(audit));
//
// EasyMock.verify(mockAuditServiceThread);
// EasyMock.verify(mockAuditServiceThreadFactory);
// }
// /**
// * Test of analyse method, of class AuditServiceImpl.
// */
// public void testAnalyse() {
// AuditServiceImpl instance = initialiseAuditService();
//
// Audit audit = EasyMock.createMock(Audit.class);
// Audit auditReturnedByAnalyseMethodOfAuditServiceThread =
// EasyMock.createMock(Audit.class);
//
// AuditServiceThread mockAuditServiceThread = EasyMock.createMock(AuditServiceThread.class);
//
// mockAuditServiceThread.analyse();
// EasyMock.expectLastCall();
// EasyMock.expect(mockAuditServiceThread.getAudit()).
// andReturn(auditReturnedByAnalyseMethodOfAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThread);
//
// EasyMock.expect(mockAuditServiceThreadFactory.create(audit)).
// andReturn(mockAuditServiceThread).anyTimes();
// EasyMock.replay(mockAuditServiceThreadFactory);
//
// assertEquals(auditReturnedByAnalyseMethodOfAuditServiceThread,
// instance.analyse(audit));
//
// EasyMock.verify(mockAuditServiceThread);
// EasyMock.verify(mockAuditServiceThreadFactory);
// }
/**
* Test of auditCompleted method, of class AuditServiceImpl.
*/
public void testAuditCompleted() {
AuditServiceImpl instance = initialiseAuditService();
Audit mockAudit = EasyMock.createMock(Audit.class);
AuditServiceListener mockAuditServiceListener = EasyMock.createMock(AuditServiceListener.class);
mockAuditServiceListener.auditCompleted(mockAudit);
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(mockAuditServiceListener);
EasyMock.replay(mockAudit);
instance.add(mockAuditServiceListener);
instance.auditCompleted(mockAudit);
EasyMock.verify(mockAudit);
EasyMock.verify(mockAuditServiceListener);
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditServiceImplTest method testAuditSite.
/**
* Test of auditPage method, of class AuditServiceImpl.
*/
public void testAuditSite() {
System.out.println("auditSite");
String siteUrl = "http://My.testUrl.org";
Set<Parameter> paramSet = null;
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, paramSet, true)).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.addSiteAudit(mockAuditCommand);
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(mockAuditServiceThreadQueue);
instance.setAuditServiceThreadQueue(mockAuditServiceThreadQueue);
Audit result = instance.auditSite(siteUrl, paramSet);
assertEquals(auditCreateByAuditCommand, result);
EasyMock.verify(mockAuditServiceThreadQueue);
EasyMock.verify(mockAuditCommand);
EasyMock.verify(mockAuditCommandFactory);
}
Aggregations