use of org.asqatasun.entity.subject.Site in project Asqatasun by Asqatasun.
the class AbstractGroupRuleImplementation method consolidateImpl.
/**
* This is the implementation of the method declared in
* {@link AbstractRuleImplementation}. It encapsulates the main algorithm of
* the consolidation operation of concrete {@link RuleImplementation}
* classes for tests with group scope. It calls the method
* {@link #consolidateGroup(org.asqatasun.entity.subject.Site, java.util.Set)}
* which should consolidate gross results by group. In common cases, this
* method should not be overriden.
*
* @param grossResultMap
* the gross result map to consolidate.
* @return the list of net results from the gross result list.
*/
@Override
protected List<ProcessResult> consolidateImpl(Map<WebResource, List<ProcessResult>> grossResultMap, ProcessRemarkService processRemarkService) {
List<ProcessResult> netResultList = new ArrayList<>();
for (Map.Entry<WebResource, List<ProcessResult>> entry : grossResultMap.entrySet()) {
WebResource key = entry.getKey();
List<ProcessResult> grossResultList = entry.getValue();
if (entry.getKey() instanceof Page) {
DefiniteResult netResult = processResultDataService.getDefiniteResult(test, key);
netResult.setDefiniteValue(TestSolution.NOT_APPLICABLE);
for (ProcessResult grossResult : grossResultList) {
// netResult.addChildResult(grossResult);
netResult.setNetResultAudit(grossResult.getGrossResultAudit());
}
netResultList.add(netResult);
continue;
} else {
netResultList.add(consolidateGroup((Site) key, grossResultList, processRemarkService));
}
}
return consolidateSite(netResultList, processRemarkService);
}
use of org.asqatasun.entity.subject.Site in project Asqatasun by Asqatasun.
the class AuditCommandImpl method createEmptySiteResource.
/**
* Create a webResource of site type and associate it with the current audit
* @param url
*/
protected void createEmptySiteResource(String url) {
Site site = getWebResourceDataService().createSite(url);
getAudit().setSubject(site);
getWebResourceDataService().saveOrUpdate(site);
}
use of org.asqatasun.entity.subject.Site in project Asqatasun by Asqatasun.
the class UploadAuditCommandImplTest method testLoadContent2.
/**
* Test of loadContent method, of class UploadAuditCommandImpl.
*/
public void testLoadContent2() {
System.out.println("LoadContent with several file");
mockInitialisationCalls(false, AuditStatus.CONTENT_LOADING);
fileMap.put("file:///My_File_Name1", "MyFileContent1");
fileMap.put("file:///My_File_Name2", "MyFileContent2");
EasyMock.expect(mockAudit.getStatus()).andReturn(AuditStatus.CONTENT_LOADING).once();
Site mockSite = EasyMock.createMock(Site.class);
Page mockPage1 = EasyMock.createMock(Page.class);
Page mockPage2 = EasyMock.createMock(Page.class);
EasyMock.expect(mockWebResourceDataService.createSite("file:///My_File_Name1")).andReturn(mockSite).once();
EasyMock.expect(mockWebResourceDataService.createPage("file:///My_File_Name1")).andReturn(mockPage1).once();
EasyMock.expect(mockWebResourceDataService.createPage("file:///My_File_Name2")).andReturn(mockPage2).once();
mockSite.addChild(mockPage1);
EasyMock.expectLastCall().once();
mockSite.addChild(mockPage2);
EasyMock.expectLastCall().once();
mockSite.setAudit(mockAudit);
EasyMock.expectLastCall().once();
EasyMock.expect(mockWebResourceDataService.saveOrUpdate(mockSite)).andReturn(mockSite).times(2);
EasyMock.expect(mockWebResourceDataService.saveOrUpdate(mockPage1)).andReturn(mockSite).once();
EasyMock.expect(mockWebResourceDataService.saveOrUpdate(mockPage2)).andReturn(mockSite).once();
mockAudit.setSubject(mockSite);
EasyMock.expectLastCall().once();
EasyMock.expect(mockAudit.getSubject()).andReturn(mockSite).once();
EasyMock.expect(mockContentLoaderService.loadContent(mockSite, fileMap)).andReturn(new ArrayList<Content>()).once();
mockAudit.setStatus(AuditStatus.CONTENT_ADAPTING);
EasyMock.expectLastCall().once();
EasyMock.expect(mockAuditDataService.saveOrUpdate(mockAudit)).andReturn(mockAudit).once();
EasyMock.replay(mockSite);
EasyMock.replay(mockPage1);
EasyMock.replay(mockPage2);
setReplayMode();
UploadAuditCommandImpl instance = getInstance();
instance.loadContent();
EasyMock.verify(mockSite);
EasyMock.verify(mockPage1);
EasyMock.verify(mockPage2);
setVerifyMode();
}
use of org.asqatasun.entity.subject.Site in project Asqatasun by Asqatasun.
the class AbstractScenarioAuditCommandImplTest method testLoadContent2.
/**
* Test of loadContent method, of class AbstractScenarioAuditCommandImpl.
*/
public void testLoadContent2() {
System.out.println("loadContent with site as main resource");
String myScenario = "My Scenario";
String myUrl = "My Scenario";
Site mockSite = createMock(Site.class);
mockSite.setAudit(mockAudit);
expectLastCall().once();
mockAudit.setStatus(AuditStatus.SCENARIO_LOADING);
expectLastCall().once();
expect(mockAuditDataService.saveOrUpdate(mockAudit)).andReturn(mockAudit).once();
expect(mockAudit.getStatus()).andReturn(AuditStatus.SCENARIO_LOADING).once();
mockAudit.setSubject(mockSite);
expectLastCall().once();
expect(mockScenarioLoaderService.loadScenario(mockSite, myScenario)).andReturn(null).once();
mockAudit.setStatus(AuditStatus.CONTENT_ADAPTING);
expectLastCall().once();
expect(mockAuditDataService.saveOrUpdate(mockAudit)).andReturn(mockAudit).once();
expect(mockWebResourceDataService.createSite(myUrl)).andReturn(mockSite).once();
expect(mockWebResourceDataService.saveOrUpdate(mockSite)).andReturn(mockSite).once();
replay(mockSite);
setReplayMode();
AbstractScenarioAuditCommandImpl instance = new TestAbstractScenarioAuditCommandImpl();
instance.setScenarioName(myUrl);
instance.setScenario(myScenario);
instance.setIsPage(false);
instance.init();
instance.loadContent();
verify(mockSite);
setVerifyMode();
}
use of org.asqatasun.entity.subject.Site in project Asqatasun by Asqatasun.
the class ContentDAOImpl method findNumberOfOrphanContentFromWebResource.
@Override
public Long findNumberOfOrphanContentFromWebResource(WebResource webResource) {
if (webResource instanceof Page) {
Query query = entityManager.createQuery(SELECT_DISTINCT_SSP + SSPImpl.class.getName() + " s" + JOIN_WR + WEB_RESOURCE_CONDITION + HTTP_STATUS_CONDITION);
query.setParameter(WEB_RESOURCE_KEY, webResource);
query.setParameter(HTTP_STATUS_CODE_KEY, DEFAULT_HTTP_STATUS_VALUE);
return (Long) query.getSingleResult();
} else if (webResource instanceof Site) {
Query query = entityManager.createQuery(SELECT_DISTINCT_SSP + SSPImpl.class.getName() + " s" + JOIN_WR + " JOIN w.parent p" + " WHERE p=:webResource" + HTTP_STATUS_CONDITION);
query.setParameter(WEB_RESOURCE_KEY, webResource);
query.setParameter(HTTP_STATUS_CODE_KEY, DEFAULT_HTTP_STATUS_VALUE);
return (Long) query.getSingleResult();
}
return (long) 0;
}
Aggregations