use of org.asqatasun.util.factory.DateFactory in project Asqatasun by Asqatasun.
the class FileContentLoaderFactoryImplTest method testCreate.
/**
* Test of create method, of class FileContentLoaderFactoryImpl.
*/
public void testCreate() {
System.out.println("create");
ContentDataService contentDataService = null;
Downloader downloader = null;
Map<String, String> fileMap = null;
DateFactory dateFactory = null;
FileContentLoaderFactoryImpl instance = new FileContentLoaderFactoryImpl();
ContentLoader contentLoader = instance.create(contentDataService, downloader, dateFactory, fileMap);
assertTrue(contentLoader instanceof FileContentLoaderImpl);
}
use of org.asqatasun.util.factory.DateFactory in project Asqatasun by Asqatasun.
the class ContentLoaderServiceImplTest method testLoadContent_WebResource.
/**
* Test of loadContent method, of class ContentLoaderServiceImpl.
*/
public void testLoadContent_WebResource() {
System.out.println("loadContent");
WebResource mockWebResource = EasyMock.createMock(WebResource.class);
ContentDataService mockContentDataService = EasyMock.createMock(ContentDataService.class);
Downloader mockDownloader = EasyMock.createMock(Downloader.class);
DownloaderFactory mockDownloaderFactory = EasyMock.createMock(DownloaderFactory.class);
ContentLoaderFactory mockContentLoaderFactory = EasyMock.createMock(ContentLoaderFactory.class);
ContentLoader mockContentLoader = EasyMock.createMock(ContentLoader.class);
DateFactory mockDateFactory = EasyMock.createMock(DateFactory.class);
EasyMock.expect(mockDownloaderFactory.create()).andReturn(mockDownloader).once();
EasyMock.expect(mockContentLoaderFactory.create(mockContentDataService, mockDownloader, mockDateFactory, null)).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(mockDownloader);
EasyMock.replay(mockDownloaderFactory);
EasyMock.replay(mockDateFactory);
ContentLoaderServiceImpl instance = new ContentLoaderServiceImpl();
instance.setContentDataService(mockContentDataService);
instance.setContentLoaderFactory(mockContentLoaderFactory);
instance.setDownloaderFactory(mockDownloaderFactory);
instance.setDateFactory(mockDateFactory);
assertEquals(contentList, instance.loadContent(mockWebResource));
EasyMock.verify(mockContent);
EasyMock.verify(mockContentDataService);
EasyMock.verify(mockContentLoader);
EasyMock.verify(mockContentLoaderFactory);
EasyMock.verify(mockDownloader);
EasyMock.verify(mockDownloaderFactory);
EasyMock.verify(mockDateFactory);
}
use of org.asqatasun.util.factory.DateFactory 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, fileMap, mockDateFactory);
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.util.factory.DateFactory 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, fileMap, mockDateFactory);
instance.setWebResource(mockSite);
instance.run();
assertTrue(instance.getResult().contains(mockSSP));
EasyMock.verify(mockSSP);
EasyMock.verify(mockContentDataService);
EasyMock.verify(mockDateFactory);
}
use of org.asqatasun.util.factory.DateFactory 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(mockContentDataService, null, mockDateFactory, fileMap)).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();
instance.setContentDataService(mockContentDataService);
instance.setContentLoaderFactory(mockContentLoaderFactory);
instance.setDateFactory(mockDateFactory);
assertEquals(contentList, instance.loadContent(mockWebResource, fileMap));
EasyMock.verify(mockContent);
EasyMock.verify(mockContentDataService);
EasyMock.verify(mockContentLoader);
EasyMock.verify(mockContentLoaderFactory);
EasyMock.verify(mockDateFactory);
}
Aggregations