use of org.asqatasun.contentloader.ContentLoader in project Asqatasun by Asqatasun.
the class ContentLoaderServiceImpl method loadContent.
@Override
public List<Content> loadContent(WebResource webResource, Map<String, String> fileMap) {
ContentLoader contentLoader = contentLoaderFactory.create(fileMap, dateFactory);
contentLoader.setWebResource(webResource);
contentLoader.run();
return contentLoader.getResult();
}
use of org.asqatasun.contentloader.ContentLoader 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);
ContentLoaderFactory mockContentLoaderFactory = EasyMock.createMock(ContentLoaderFactory.class);
ContentLoader mockContentLoader = EasyMock.createMock(ContentLoader.class);
DateFactory mockDateFactory = EasyMock.createMock(DateFactory.class);
EasyMock.expect(mockContentLoaderFactory.create(null, 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, null));
EasyMock.verify(mockContent);
EasyMock.verify(mockContentDataService);
EasyMock.verify(mockContentLoader);
EasyMock.verify(mockContentLoaderFactory);
EasyMock.verify(mockDateFactory);
}
use of org.asqatasun.contentloader.ContentLoader in project Asqatasun by Asqatasun.
the class ContentLoaderServiceImpl method loadContent.
@Override
public List<Content> loadContent(WebResource webResource) {
ContentLoader contentLoader = contentLoaderFactory.create(contentDataService, downloaderFactory.create(), dateFactory, null);
contentLoader.setWebResource(webResource);
contentLoader.run();
return contentLoader.getResult();
}
use of org.asqatasun.contentloader.ContentLoader 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);
}
Aggregations