Search in sources :

Example 36 with WebResource

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

Example 37 with WebResource

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

Example 38 with WebResource

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

Example 39 with WebResource

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;
    }
}
Also used : PageImpl(org.asqatasun.entity.subject.PageImpl) NonUniqueResultException(javax.persistence.NonUniqueResultException) Query(javax.persistence.Query) WebResource(org.asqatasun.entity.subject.WebResource) List(java.util.List) NoResultException(javax.persistence.NoResultException)

Example 40 with WebResource

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));
}
Also used : Theme(org.asqatasun.entity.reference.Theme) WebResource(org.asqatasun.entity.subject.WebResource)

Aggregations

WebResource (org.asqatasun.entity.subject.WebResource)43 Audit (org.asqatasun.entity.audit.Audit)11 Content (org.asqatasun.entity.audit.Content)11 Site (org.asqatasun.entity.subject.Site)9 ArrayList (java.util.ArrayList)8 ProcessResult (org.asqatasun.entity.audit.ProcessResult)8 Page (org.asqatasun.entity.subject.Page)7 NoResultException (javax.persistence.NoResultException)6 Query (javax.persistence.Query)6 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)6 List (java.util.List)5 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 NonUniqueResultException (javax.persistence.NonUniqueResultException)3 SSP (org.asqatasun.entity.audit.SSP)3 ContentDataService (org.asqatasun.entity.service.audit.ContentDataService)3 Contract (org.asqatasun.webapp.entity.contract.Contract)3 Map (java.util.Map)2 ContentLoader (org.asqatasun.contentloader.ContentLoader)2 ContentLoaderFactory (org.asqatasun.contentloader.ContentLoaderFactory)2