Search in sources :

Example 41 with Audit

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

the class AuditServiceThreadImplTest method testAddAndRemove.

/**
     * Test of add/remove AuditServiceListener method of class AuditServiceImpl.
     */
public void testAddAndRemove() {
    Audit audit = createMock(Audit.class);
    AuditServiceThreadImpl instance = initialiseAuditServiceThread(audit);
    AuditServiceThreadListener mockAuditServiceThreadListener = createMock(AuditServiceThreadListener.class);
    // when try to remove a listener not recorded, nothing happened
    instance.remove(mockAuditServiceThreadListener);
    instance.add(mockAuditServiceThreadListener);
    assertTrue(instance.getListeners().contains(mockAuditServiceThreadListener));
    instance.remove(mockAuditServiceThreadListener);
    assertTrue(instance.getListeners().isEmpty());
}
Also used : Audit(org.asqatasun.entity.audit.Audit)

Example 42 with Audit

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

the class CrawlerServiceImplTest method testCrawl_Page.

/**
     * Test the crawl of a page
     */
public void testCrawl_Page() {
    System.out.println("crawl_page");
    crawlerFactory.setCrawlConfigFilePath(PAGE_CRAWL_CONF_FILE_PATH);
    String siteUrl = bundle.getString(FULL_SITE_CRAWL_URL_KEY);
    Audit audit = new AuditImpl();
    audit.setParameterSet(setCrawlParameters("3", "", "", "", ""));
    WebResource page = crawlerService.crawlPage(audit, siteUrl);
    Collection<Long> contentListId = mockContentDataService.getSSPIdsFromWebResource(page.getId(), HttpStatus.SC_OK, 0, 10);
    List<Content> contentList = new ArrayList<>();
    for (Long id : contentListId) {
        contentList.add(mockContentDataService.readWithRelatedContent(id, false));
    }
    assertEquals(1, contentList.size());
    Set<String> urlSet = getUrlSet(contentList);
    assertTrue(urlSet.contains(siteUrl));
    assertFalse(urlSet.contains(siteUrl + PAGE_NAME_LEVEL1));
    assertFalse(urlSet.contains(siteUrl + PAGE_NAME_LEVEL2));
    assertFalse(urlSet.contains(siteUrl + FORBIDDEN_PAGE_NAME));
}
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 43 with Audit

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

the class ParameterDAOImplTest method testFindParameterSetFromAudit.

public void testFindParameterSetFromAudit() {
    Audit audit = auditDAO.read(Long.valueOf(1));
    Set<Parameter> paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(2), Integer.valueOf(paramSet.size()));
    audit = auditDAO.read(Long.valueOf(2));
    paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(2), Integer.valueOf(paramSet.size()));
    audit = auditDAO.read(Long.valueOf(3));
    paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(2), Integer.valueOf(paramSet.size()));
    audit = auditDAO.read(Long.valueOf(4));
    paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(2), Integer.valueOf(paramSet.size()));
    audit = auditDAO.read(Long.valueOf(5));
    paramSet = parameterDAO.findParameterSetFromAudit(audit);
    assertEquals(Integer.valueOf(0), Integer.valueOf(paramSet.size()));
}
Also used : Audit(org.asqatasun.entity.audit.Audit) Parameter(org.asqatasun.entity.parameterization.Parameter)

Example 44 with Audit

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

the class TestDAOImplTest method testRetrieveTestFromAuditAndLabel.

public void testRetrieveTestFromAuditAndLabel() {
    Audit audit = new AuditImpl();
    audit.setId(1L);
    audit.setStatus(AuditStatus.COMPLETED);
    Test test = testDAO.retrieveTestFromAuditAndLabel(audit, "1.1.2");
    assertEquals(test.getLabel(), "1.1.2");
    audit.setId(2L);
    test = testDAO.retrieveTestFromAuditAndLabel(audit, "1.1.15");
    assertEquals(test.getLabel(), "1.1.15");
    test = testDAO.retrieveTestFromAuditAndLabel(audit, "2.1.5");
    assertNull(test);
}
Also used : AuditImpl(org.asqatasun.entity.audit.AuditImpl) Audit(org.asqatasun.entity.audit.Audit) Test(org.asqatasun.entity.reference.Test)

Example 45 with Audit

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

the class ContentDAOImplTest method testFind.

public void testFind() {
    Audit audit = auditDAO.read(Long.valueOf(1));
    assertNull(contentDAO.find(audit, "http://www.mock-url.org/2.html"));
    assertNull(contentDAO.find(audit, "http://www.mock-url.org/3.html"));
    audit = auditDAO.read(Long.valueOf(3));
    assertEquals(Long.valueOf(10), contentDAO.find(audit, "http://www.mock-url.org/2.html").getId());
    assertNull(contentDAO.find(audit, "http://www.mock-url.org/3.html"));
    WebResource wr = webresourceDAO.read(Long.valueOf(6));
    assertEquals(Long.valueOf(2), contentDAO.find(wr, "http://www.mock-url.org/2.html").getId());
    wr = webresourceDAO.read(Long.valueOf(5));
    assertNull(contentDAO.find(wr, "http://www.mock-url.org/2.html"));
}
Also used : Audit(org.asqatasun.entity.audit.Audit) WebResource(org.asqatasun.entity.subject.WebResource)

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