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());
}
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));
}
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()));
}
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);
}
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"));
}
Aggregations