Search in sources :

Example 1 with Downloader

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);
}
Also used : Content(org.asqatasun.entity.audit.Content) ContentLoader(org.asqatasun.contentloader.ContentLoader) ArrayList(java.util.ArrayList) WebResource(org.asqatasun.entity.subject.WebResource) Downloader(org.asqatasun.contentloader.Downloader) ContentLoaderFactory(org.asqatasun.contentloader.ContentLoaderFactory) DateFactory(org.asqatasun.util.factory.DateFactory) ContentDataService(org.asqatasun.entity.service.audit.ContentDataService) DownloaderFactory(org.asqatasun.contentloader.DownloaderFactory)

Aggregations

ArrayList (java.util.ArrayList)1 ContentLoader (org.asqatasun.contentloader.ContentLoader)1 ContentLoaderFactory (org.asqatasun.contentloader.ContentLoaderFactory)1 Downloader (org.asqatasun.contentloader.Downloader)1 DownloaderFactory (org.asqatasun.contentloader.DownloaderFactory)1 Content (org.asqatasun.entity.audit.Content)1 ContentDataService (org.asqatasun.entity.service.audit.ContentDataService)1 WebResource (org.asqatasun.entity.subject.WebResource)1 DateFactory (org.asqatasun.util.factory.DateFactory)1