Search in sources :

Example 6 with ContentDataService

use of org.asqatasun.entity.service.audit.ContentDataService 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)

Example 7 with ContentDataService

use of org.asqatasun.entity.service.audit.ContentDataService 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, mockDateFactory, fileMap);
    instance.setWebResource(mockPage);
    instance.run();
    assertTrue(instance.getResult().contains(mockSSP));
    EasyMock.verify(mockPage);
    EasyMock.verify(mockSSP);
    EasyMock.verify(mockContentDataService);
    EasyMock.verify(mockDateFactory);
}
Also used : SSP(org.asqatasun.entity.audit.SSP) DateFactory(org.asqatasun.util.factory.DateFactory) ContentDataService(org.asqatasun.entity.service.audit.ContentDataService)

Example 8 with ContentDataService

use of org.asqatasun.entity.service.audit.ContentDataService 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, mockDateFactory, fileMap);
    instance.setWebResource(mockSite);
    instance.run();
    assertTrue(instance.getResult().contains(mockSSP));
    EasyMock.verify(mockSSP);
    EasyMock.verify(mockContentDataService);
    EasyMock.verify(mockDateFactory);
}
Also used : SSP(org.asqatasun.entity.audit.SSP) DateFactory(org.asqatasun.util.factory.DateFactory) ContentDataService(org.asqatasun.entity.service.audit.ContentDataService)

Aggregations

ContentDataService (org.asqatasun.entity.service.audit.ContentDataService)8 DateFactory (org.asqatasun.util.factory.DateFactory)6 ArrayList (java.util.ArrayList)3 Content (org.asqatasun.entity.audit.Content)3 SSP (org.asqatasun.entity.audit.SSP)3 WebResource (org.asqatasun.entity.subject.WebResource)3 ContentLoader (org.asqatasun.contentloader.ContentLoader)2 ContentLoaderFactory (org.asqatasun.contentloader.ContentLoaderFactory)2 WebResourceDataService (org.asqatasun.entity.service.subject.WebResourceDataService)2 HashMap (java.util.HashMap)1 Audit (org.asqatasun.entity.audit.Audit)1 Page (org.asqatasun.entity.subject.Page)1 Site (org.asqatasun.entity.subject.Site)1 ScenarioLoader (org.asqatasun.scenarioloader.ScenarioLoader)1 ScenarioLoaderFactory (org.asqatasun.scenarioloader.ScenarioLoaderFactory)1