use of org.asqatasun.entity.service.audit.ContentDataService in project Asqatasun by Asqatasun.
the class ContentLoaderServiceImplTest method testLoadContent_WebResource_Map.
/**
* Test of loadContent method, of class ContentLoaderServiceImpl.
*/
public void testLoadContent_WebResource_Map() {
System.out.println("loadContent with file Map");
WebResource mockWebResource = EasyMock.createMock(WebResource.class);
ContentDataService mockContentDataService = EasyMock.createMock(ContentDataService.class);
ContentLoaderFactory mockContentLoaderFactory = EasyMock.createMock(ContentLoaderFactory.class);
DateFactory mockDateFactory = EasyMock.createMock(DateFactory.class);
ContentLoader mockContentLoader = EasyMock.createMock(ContentLoader.class);
Map<String, String> fileMap = new HashMap<>();
EasyMock.expect(mockContentLoaderFactory.create(fileMap, mockDateFactory)).andReturn(mockContentLoader).once();
mockContentLoader.setWebResource(mockWebResource);
EasyMock.expectLastCall().once();
mockContentLoader.run();
EasyMock.expectLastCall().once();
List<Content> contentList = new ArrayList<>();
Content mockContent = EasyMock.createMock(Content.class);
contentList.add(mockContent);
EasyMock.expect(mockContentLoader.getResult()).andReturn(contentList).once();
EasyMock.replay(mockContent);
EasyMock.replay(mockContentDataService);
EasyMock.replay(mockContentLoader);
EasyMock.replay(mockContentLoaderFactory);
EasyMock.replay(mockDateFactory);
ContentLoaderServiceImpl instance = new ContentLoaderServiceImpl(mockContentLoaderFactory, mockDateFactory);
assertEquals(contentList, instance.loadContent(mockWebResource, fileMap));
EasyMock.verify(mockContent);
EasyMock.verify(mockContentDataService);
EasyMock.verify(mockContentLoader);
EasyMock.verify(mockContentLoaderFactory);
EasyMock.verify(mockDateFactory);
}
use of org.asqatasun.entity.service.audit.ContentDataService in project Asqatasun by Asqatasun.
the class FileContentLoaderImplTest method testRun.
/**
* Test of run method, of class FileContentLoaderImpl.
*/
public void testRun() {
System.out.println("run");
Page mockPage = EasyMock.createMock(Page.class);
EasyMock.expect(mockPage.getURL()).andReturn("http://my.testUrl.org").times(2);
ContentDataService mockContentDataService = EasyMock.createMock(ContentDataService.class);
SSP mockSSP = EasyMock.createMock(SSP.class);
Date date = new Date();
DateFactory mockDateFactory = EasyMock.createMock(DateFactory.class);
EasyMock.expect(mockDateFactory.createDate()).andReturn(date).once();
EasyMock.expect(mockContentDataService.getSSP(date, "http://my.testUrl.org", "My Page Content", mockPage, HttpStatus.SC_OK)).andReturn(mockSSP).once();
Map<String, String> fileMap = new HashMap<>();
fileMap.put("http://my.testUrl.org", "My Page Content");
EasyMock.replay(mockPage);
EasyMock.replay(mockSSP);
EasyMock.replay(mockContentDataService);
EasyMock.replay(mockDateFactory);
FileContentLoaderImpl instance = new FileContentLoaderImpl(mockContentDataService, mockDateFactory, fileMap);
instance.setWebResource(mockPage);
instance.run();
assertTrue(instance.getResult().contains(mockSSP));
EasyMock.verify(mockPage);
EasyMock.verify(mockSSP);
EasyMock.verify(mockContentDataService);
EasyMock.verify(mockDateFactory);
}
use of org.asqatasun.entity.service.audit.ContentDataService in project Asqatasun by Asqatasun.
the class FileContentLoaderImplTest method testRun1.
/**
* Test of run method, of class FileContentLoaderImpl.
*/
public void testRun1() {
System.out.println("run");
Site mockSite = new SiteImpl();
Page mockPage1 = new PageImpl();
mockPage1.setURL("http://my.testUrl1.org");
Page mockPage2 = new PageImpl();
mockPage2.setURL("http://my.testUrl2.org");
mockSite.addChild(mockPage1);
mockSite.addChild(mockPage2);
ContentDataService mockContentDataService = EasyMock.createMock(ContentDataService.class);
SSP mockSSP = EasyMock.createMock(SSP.class);
Date date = new Date();
DateFactory mockDateFactory = EasyMock.createMock(DateFactory.class);
EasyMock.expect(mockDateFactory.createDate()).andReturn(date).times(2);
EasyMock.expect(mockContentDataService.getSSP(date, "http://my.testUrl1.org", "My Page Content 1", mockPage1, HttpStatus.SC_OK)).andReturn(mockSSP).once();
EasyMock.expect(mockContentDataService.getSSP(date, "http://my.testUrl2.org", "My Page Content 2", mockPage2, HttpStatus.SC_OK)).andReturn(mockSSP).once();
Map<String, String> fileMap = new HashMap<>();
fileMap.put("http://my.testUrl1.org", "My Page Content 1");
fileMap.put("http://my.testUrl2.org", "My Page Content 2");
EasyMock.replay(mockSSP);
EasyMock.replay(mockContentDataService);
EasyMock.replay(mockDateFactory);
FileContentLoaderImpl instance = new FileContentLoaderImpl(mockContentDataService, mockDateFactory, fileMap);
instance.setWebResource(mockSite);
instance.run();
assertTrue(instance.getResult().contains(mockSSP));
EasyMock.verify(mockSSP);
EasyMock.verify(mockContentDataService);
EasyMock.verify(mockDateFactory);
}
Aggregations