use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.
the class WebResourceDAOImplTest method testFindByUrlAndParentWebResource.
public void testFindByUrlAndParentWebResource() {
WebResource parentWr = webresourceDAO.read(Long.valueOf(1));
WebResource wr = webresourceDAO.findByUrlAndParentWebResource(URL2, parentWr);
assertEquals(Long.valueOf(2), wr.getId());
wr = webresourceDAO.findByUrlAndParentWebResource(URL1, parentWr);
assertNull(wr);
}
use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.
the class WebResourceDAOImplTest method testRetrieveWebResourceFromItsParent.
public void testRetrieveWebResourceFromItsParent() {
WebResource parentWr = webresourceDAO.read(Long.valueOf(1));
assertEquals(Long.valueOf(3), webresourceDAO.findNumberOfChildWebResource(parentWr));
List<WebResource> wrList = webresourceDAO.findWebResourceFromItsParent(parentWr, 0, 1);
assertEquals(1, wrList.size());
assertEquals(Long.valueOf(2), ((WebResource) wrList.iterator().next()).getId());
wrList = webresourceDAO.findWebResourceFromItsParent(parentWr, 1, 10);
assertEquals(2, wrList.size());
Iterator iter = wrList.iterator();
assertEquals(Long.valueOf(3), ((WebResource) iter.next()).getId());
assertEquals(Long.valueOf(4), ((WebResource) iter.next()).getId());
}
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;
}
}
Aggregations