use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.
the class ContentDAOImplTest method testFindNumberOfSSPFromWebResource.
public void testFindNumberOfSSPFromWebResource() {
WebResource wr = webresourceDAO.read(Long.valueOf(1));
assertEquals(Long.valueOf(0), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_OK));
wr = webresourceDAO.read(Long.valueOf(2));
assertEquals(Long.valueOf(0), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_OK));
wr = webresourceDAO.read(Long.valueOf(8));
assertEquals(Long.valueOf(1), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_OK));
assertEquals(Long.valueOf(0), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_BAD_GATEWAY));
assertEquals(Long.valueOf(2), contentDAO.findNumberOfSSPFromWebResource(wr, -1));
wr = webresourceDAO.read(Long.valueOf(12));
assertEquals(Long.valueOf(0), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_OK));
}
use of org.asqatasun.entity.subject.WebResource 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"));
}
use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.
the class WebResourceDAOImpl method ligthRead.
@Override
public WebResource ligthRead(Long webResourceId) {
try {
Query query = entityManager.createQuery("SELECT wr FROM " + getEntityClass().getName() + " wr" + " WHERE wr.id = :id");
query.setParameter("id", webResourceId);
query.setHint(CACHEABLE_OPTION, TRUE);
return (WebResource) query.getSingleResult();
} catch (NoResultException nre) {
return null;
}
}
use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.
the class WebResourceDAOImpl method findByUrlAndParentWebResource.
@Override
public WebResource findByUrlAndParentWebResource(String url, WebResource webResource) {
Query query = entityManager.createQuery("SELECT wr FROM " + PageImpl.class.getName() + " wr" + " WHERE wr.url = :url" + " AND wr.parent =:webResource");
query.setParameter("url", url);
query.setParameter("webResource", webResource);
try {
return (WebResource) query.getSingleResult();
} catch (NoResultException nre) {
return null;
} catch (NonUniqueResultException nure) {
List<WebResource> queryResult = query.getResultList();
for (WebResource wr : queryResult) {
if (StringUtils.equals(wr.getURL(), url)) {
return wr;
}
}
return null;
}
}
use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.
the class ProcessResultDAOImplTest method testGetResultByThemeCount.
public void testGetResultByThemeCount() {
Theme theme1 = themeDAO.read(Long.valueOf(1));
Theme theme2 = themeDAO.read(Long.valueOf(2));
WebResource wa = webresourceDAO.read(Long.valueOf(1));
assertEquals(1, processResultDAO.getResultByThemeCount(wa, TestSolution.PASSED, theme1));
assertEquals(0, processResultDAO.getResultByThemeCount(wa, TestSolution.FAILED, theme1));
assertEquals(1, processResultDAO.getResultByThemeCount(wa, TestSolution.NEED_MORE_INFO, theme1));
assertEquals(0, processResultDAO.getResultByThemeCount(wa, TestSolution.NOT_APPLICABLE, theme1));
assertEquals(1, processResultDAO.getResultByThemeCount(wa, TestSolution.PASSED, theme2));
assertEquals(2, processResultDAO.getResultByThemeCount(wa, TestSolution.FAILED, theme2));
assertEquals(1, processResultDAO.getResultByThemeCount(wa, TestSolution.NEED_MORE_INFO, theme2));
assertEquals(0, processResultDAO.getResultByThemeCount(wa, TestSolution.NOT_APPLICABLE, theme2));
assertEquals(2, processResultDAO.getResultByThemeCount(wa, TestSolution.PASSED, null));
assertEquals(2, processResultDAO.getResultByThemeCount(wa, TestSolution.FAILED, null));
assertEquals(2, processResultDAO.getResultByThemeCount(wa, TestSolution.NEED_MORE_INFO, null));
assertEquals(0, processResultDAO.getResultByThemeCount(wa, TestSolution.NOT_APPLICABLE, null));
}
Aggregations