use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class ManualAuditController method displayManualAuditResultFromContract.
/**
* General router when receive audit-result request. Regarding the scope of
* the audit, the returned page may differ.
*
* @param auditId
* @param request
* @param model
* @return
*/
@RequestMapping(value = TgolKeyStore.MANUAL_AUDIT_RESULT_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String displayManualAuditResultFromContract(@RequestParam(TgolKeyStore.AUDIT_ID_KEY) String auditId, HttpServletRequest request, Model model) {
try {
Audit audit = getAuditDataService().read(Long.valueOf(auditId));
Act act = getActDataService().getActFromAudit(audit);
switch(act.getScope().getCode()) {
case FILE:
case PAGE:
if (!getContractDataService().doesContractHaveFunctionality(act.getContract(), manualAuditFunctionalityKey)) {
return TgolKeyStore.ACCESS_DENIED_VIEW_NAME;
}
model.addAttribute(TgolKeyStore.WEBRESOURCE_ID_KEY, audit.getSubject().getId());
return TgolKeyStore.MANUAL_AUDIT_RESULT_VIEW_REDIRECT_NAME;
case DOMAIN:
case SCENARIO:
case GROUPOFFILES:
case GROUPOFPAGES:
default:
throw new ForbiddenPageException();
}
} catch (NumberFormatException nfe) {
throw new ForbiddenPageException();
}
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class CrawlerServiceImplTest method initialiseAndLaunchCrawl.
/**
*
* @param siteUrl
* @param depth
* @param regexp
* @param maxDuration
* @param maxDocuments
* @param proxyHost
* @param proxyPort
* @return
*/
private List<Content> initialiseAndLaunchCrawl(String siteUrl, String depth, String exlusionRegexp, String inlusionRegexp, String maxDuration, String maxDocuments) {
Audit audit = new AuditImpl();
audit.setParameterSet(setCrawlParameters(depth, exlusionRegexp, inlusionRegexp, maxDuration, maxDocuments));
WebResource site = crawlerService.crawlSite(audit, siteUrl);
Collection<Long> contentListId = mockContentDataService.getSSPIdsFromWebResource(site.getId(), HttpStatus.SC_OK, 0, 10);
List<Content> contentList = new ArrayList();
for (Long id : contentListId) {
Content content = mockContentDataService.readWithRelatedContent(id, false);
if (content != null) {
System.out.println(content.getURI() + " " + content.getClass());
contentList.add(content);
}
}
return contentList;
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class AuditDAOImpl method findAuditWithTest.
@Override
public Audit findAuditWithTest(Long id) {
Query query = entityManager.createQuery("SELECT a FROM " + getEntityClass().getName() + " a" + " LEFT JOIN FETCH a.testList" + " WHERE a.id = :id");
query.setParameter("id", id);
try {
return (Audit) query.getSingleResult();
} catch (NoResultException nre) {
return null;
}
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class ScenarioLoaderServiceImplTest method testLoadScenario.
/**
* Test of loadScenario method, of class ScenarioLoaderServiceImpl.
*/
public void testLoadScenario() {
System.out.println("loadScenario");
String scenarioFile = "My Scenario";
WebResource mockWebResource = createMock(WebResource.class);
Audit mockAudit = createMock(Audit.class);
expect(mockWebResource.getAudit()).andReturn(mockAudit).once();
ScenarioLoaderFactory mockScenarioLoaderFactory = createMock(ScenarioLoaderFactory.class);
ScenarioLoader mockScenarioLoader = createMock(ScenarioLoader.class);
expect(mockScenarioLoaderFactory.create(mockWebResource, scenarioFile)).andReturn(mockScenarioLoader).once();
mockScenarioLoader.run();
expectLastCall().once();
List<Content> contentList = new ArrayList<Content>();
expect(mockScenarioLoader.getResult()).andReturn(contentList).once();
ContentDataService mockContentDataService = createMock(ContentDataService.class);
WebResourceDataService mockWebResourceDataService = createMock(WebResourceDataService.class);
expect(mockWebResourceDataService.saveOrUpdate(mockWebResource)).andReturn(mockWebResource).once();
replay(mockAudit);
replay(mockWebResource);
replay(mockWebResourceDataService);
replay(mockContentDataService);
replay(mockScenarioLoader);
replay(mockScenarioLoaderFactory);
ScenarioLoaderServiceImpl instance = new ScenarioLoaderServiceImpl();
instance.setContentDataService(mockContentDataService);
instance.setScenarioLoaderFactory(mockScenarioLoaderFactory);
instance.setWebResourceDataService(mockWebResourceDataService);
instance.loadScenario(mockWebResource, scenarioFile);
verify(mockAudit);
verify(mockWebResource);
verify(mockWebResourceDataService);
verify(mockContentDataService);
verify(mockScenarioLoader);
verify(mockScenarioLoaderFactory);
}
use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.
the class ScenarioLoaderServiceImpl method loadScenario.
@Override
public List<Content> loadScenario(WebResource webResource, String scenarioFile) {
Audit audit = webResource.getAudit();
ScenarioLoader scenarioLoader = scenarioLoaderFactory.create(webResource, scenarioFile);
scenarioLoader.run();
List<Content> contentList = scenarioLoader.getResult();
for (Content content : contentList) {
// content.setAudit(audit);
contentDataService.saveAuditToContent(content.getId(), audit.getId());
}
// Before returning the list of content we save the webResource
webResourceDataService.saveOrUpdate(webResource);
return contentList;
}
Aggregations