Search in sources :

Example 1 with ContentLoader

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();
}
Also used : ContentLoader(org.asqatasun.contentloader.ContentLoader)

Example 2 with ContentLoader

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

Example 3 with ContentLoader

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();
}
Also used : ContentLoader(org.asqatasun.contentloader.ContentLoader)

Example 4 with ContentLoader

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

Aggregations

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