Search in sources :

Example 16 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class ProcessResultDAOImplTest method testRetrieveNetResultFromAudit.

public void testRetrieveNetResultFromAudit() {
    Audit audit = auditDAO.read(Long.valueOf(1));
    Collection<ProcessResult> processResultList = processResultDAO.retrieveNetResultFromAudit(audit);
    assertEquals(10, processResultList.size());
    assertEquals(Long.valueOf(1), ((ProcessResult) processResultList.iterator().next()).getSubject().getId());
    audit = auditDAO.read(Long.valueOf(2));
    processResultList = processResultDAO.retrieveNetResultFromAudit(audit);
    assertEquals(2, processResultList.size());
    assertEquals(Long.valueOf(2), ((ProcessResult) processResultList.iterator().next()).getSubject().getId());
}
Also used : Audit(org.asqatasun.entity.audit.Audit) ProcessResult(org.asqatasun.entity.audit.ProcessResult)

Example 17 with Audit

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();
    }
}
Also used : Audit(org.asqatasun.entity.audit.Audit) Act(org.asqatasun.webapp.entity.contract.Act) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with Audit

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;
}
Also used : AuditImpl(org.asqatasun.entity.audit.AuditImpl) Audit(org.asqatasun.entity.audit.Audit) Content(org.asqatasun.entity.audit.Content) WebResource(org.asqatasun.entity.subject.WebResource)

Example 19 with Audit

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;
    }
}
Also used : Audit(org.asqatasun.entity.audit.Audit) Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException)

Example 20 with Audit

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);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) ScenarioLoader(org.asqatasun.scenarioloader.ScenarioLoader) Content(org.asqatasun.entity.audit.Content) WebResourceDataService(org.asqatasun.entity.service.subject.WebResourceDataService) ArrayList(java.util.ArrayList) WebResource(org.asqatasun.entity.subject.WebResource) ScenarioLoaderFactory(org.asqatasun.scenarioloader.ScenarioLoaderFactory) ContentDataService(org.asqatasun.entity.service.audit.ContentDataService)

Aggregations

Audit (org.asqatasun.entity.audit.Audit)47 WebResource (org.asqatasun.entity.subject.WebResource)11 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)10 Parameter (org.asqatasun.entity.parameterization.Parameter)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Site (org.asqatasun.entity.subject.Site)7 AuditCommand (org.asqatasun.service.command.AuditCommand)7 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)6 Secured (org.springframework.security.access.annotation.Secured)6 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)5 Contract (org.asqatasun.webapp.entity.contract.Contract)5 Content (org.asqatasun.entity.audit.Content)4 ProcessResult (org.asqatasun.entity.audit.ProcessResult)4 Page (org.asqatasun.entity.subject.Page)4 AuditImpl (org.asqatasun.entity.audit.AuditImpl)3 SSP (org.asqatasun.entity.audit.SSP)2 Test (org.asqatasun.entity.reference.Test)2 ScenarioLoader (org.asqatasun.scenarioloader.ScenarioLoader)2 Act (org.asqatasun.webapp.entity.contract.Act)2 IOException (java.io.IOException)1