use of org.asqatasun.contentloader.Downloader 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);
}
Aggregations