use of org.asqatasun.entity.subject.Page in project Asqatasun by Asqatasun.
the class AuditExportResultController method prepareSuccessfullAuditDataToExport.
/**
*
* @param page
* @param model
* @param locale
* @param exportFormat
* @param request
* @param response
* @return
* @throws IOException
*/
private void prepareSuccessfullAuditDataToExport(WebResource webResource, Model model, Locale locale, String exportFormat, HttpServletRequest request, HttpServletResponse response) throws NotSupportedExportFormatException {
model.addAttribute(TgolKeyStore.LOCALE_KEY, locale);
Scope scope = getSiteScope();
if (webResource instanceof Page) {
scope = getPageScope();
}
List<TestResult> testResultList = TestResultFactory.getInstance().getTestResultList(webResource, scope, getLocaleResolver().resolveLocale(request));
AuditStatistics auditStatistics = getAuditStatistics(webResource, model, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE, //TODO a revoir dans le cas manuel
false);
model.addAttribute(TgolKeyStore.STATISTICS_KEY, auditStatistics);
try {
exportService.export(response, webResource.getId(), auditStatistics, testResultList, locale, exportFormat);
} catch (ColumnBuilderException | ClassNotFoundException | JRException ex) {
LOGGER.error(ex);
}
}
use of org.asqatasun.entity.subject.Page 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.Page in project Asqatasun by Asqatasun.
the class UploadAuditCommandImplTest method testLoadContent1.
/**
* Test of loadContent method, of class UploadAuditCommandImpl.
*/
public void testLoadContent1() {
System.out.println("LoadContent with 1 file");
mockInitialisationCalls(false, AuditStatus.CONTENT_LOADING);
fileMap.put("My File Name", "MyFileContent");
EasyMock.expect(mockAudit.getStatus()).andReturn(AuditStatus.CONTENT_LOADING).once();
Page mockPage = EasyMock.createMock(Page.class);
EasyMock.expect(mockWebResourceDataService.createPage("My File Name")).andReturn(mockPage).once();
mockPage.setAudit(mockAudit);
EasyMock.expectLastCall().once();
EasyMock.expect(mockWebResourceDataService.saveOrUpdate(mockPage)).andReturn(mockPage).once();
mockAudit.setSubject(mockPage);
EasyMock.expectLastCall().once();
EasyMock.expect(mockAudit.getSubject()).andReturn(mockPage).once();
EasyMock.expect(mockContentLoaderService.loadContent(mockPage, fileMap)).andReturn(new ArrayList<Content>()).once();
mockAudit.setStatus(AuditStatus.CONTENT_ADAPTING);
EasyMock.expectLastCall().once();
EasyMock.expect(mockAuditDataService.saveOrUpdate(mockAudit)).andReturn(mockAudit).once();
EasyMock.replay(mockPage);
setReplayMode();
UploadAuditCommandImpl instance = getInstance();
instance.loadContent();
EasyMock.verify(mockPage);
setVerifyMode();
}
use of org.asqatasun.entity.subject.Page 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.Page in project Asqatasun by Asqatasun.
the class AuditCommandImpl method createEmptyPageResource.
/**
* Create a webResource of page type and associate it with the current audit
* @param url
*/
protected void createEmptyPageResource(String url) {
Page page = getWebResourceDataService().createPage(url);
getAudit().setSubject(page);
getWebResourceDataService().saveOrUpdate(page);
}
Aggregations