Search in sources :

Example 1 with ScenarioLoader

use of org.asqatasun.scenarioloader.ScenarioLoader in project Asqatasun by Asqatasun.

the class ScenarioLoaderServiceImplTest method testLoadScenario.

/**
     * Test of loadScenario method, of class ScenarioLoaderServiceImpl.
     */
public void testLoadScenario() {
    System.out.println("loadScenario");
    String scenarioFile = "My Scenario";
    WebResource mockWebResource = createMock(WebResource.class);
    Audit mockAudit = createMock(Audit.class);
    expect(mockWebResource.getAudit()).andReturn(mockAudit).once();
    ScenarioLoaderFactory mockScenarioLoaderFactory = createMock(ScenarioLoaderFactory.class);
    ScenarioLoader mockScenarioLoader = createMock(ScenarioLoader.class);
    expect(mockScenarioLoaderFactory.create(mockWebResource, scenarioFile)).andReturn(mockScenarioLoader).once();
    mockScenarioLoader.run();
    expectLastCall().once();
    List<Content> contentList = new ArrayList<Content>();
    expect(mockScenarioLoader.getResult()).andReturn(contentList).once();
    ContentDataService mockContentDataService = createMock(ContentDataService.class);
    WebResourceDataService mockWebResourceDataService = createMock(WebResourceDataService.class);
    expect(mockWebResourceDataService.saveOrUpdate(mockWebResource)).andReturn(mockWebResource).once();
    replay(mockAudit);
    replay(mockWebResource);
    replay(mockWebResourceDataService);
    replay(mockContentDataService);
    replay(mockScenarioLoader);
    replay(mockScenarioLoaderFactory);
    ScenarioLoaderServiceImpl instance = new ScenarioLoaderServiceImpl();
    instance.setContentDataService(mockContentDataService);
    instance.setScenarioLoaderFactory(mockScenarioLoaderFactory);
    instance.setWebResourceDataService(mockWebResourceDataService);
    instance.loadScenario(mockWebResource, scenarioFile);
    verify(mockAudit);
    verify(mockWebResource);
    verify(mockWebResourceDataService);
    verify(mockContentDataService);
    verify(mockScenarioLoader);
    verify(mockScenarioLoaderFactory);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) ScenarioLoader(org.asqatasun.scenarioloader.ScenarioLoader) Content(org.asqatasun.entity.audit.Content) WebResourceDataService(org.asqatasun.entity.service.subject.WebResourceDataService) ArrayList(java.util.ArrayList) WebResource(org.asqatasun.entity.subject.WebResource) ScenarioLoaderFactory(org.asqatasun.scenarioloader.ScenarioLoaderFactory) ContentDataService(org.asqatasun.entity.service.audit.ContentDataService)

Example 2 with ScenarioLoader

use of org.asqatasun.scenarioloader.ScenarioLoader in project Asqatasun by Asqatasun.

the class ScenarioLoaderServiceImpl method loadScenario.

@Override
public List<Content> loadScenario(WebResource webResource, String scenarioFile) {
    Audit audit = webResource.getAudit();
    ScenarioLoader scenarioLoader = scenarioLoaderFactory.create(webResource, scenarioFile);
    scenarioLoader.run();
    List<Content> contentList = scenarioLoader.getResult();
    for (Content content : contentList) {
        //            content.setAudit(audit);
        contentDataService.saveAuditToContent(content.getId(), audit.getId());
    }
    // Before returning the list of content we save the webResource
    webResourceDataService.saveOrUpdate(webResource);
    return contentList;
}
Also used : Audit(org.asqatasun.entity.audit.Audit) ScenarioLoader(org.asqatasun.scenarioloader.ScenarioLoader) Content(org.asqatasun.entity.audit.Content)

Aggregations

Audit (org.asqatasun.entity.audit.Audit)2 Content (org.asqatasun.entity.audit.Content)2 ScenarioLoader (org.asqatasun.scenarioloader.ScenarioLoader)2 ArrayList (java.util.ArrayList)1 ContentDataService (org.asqatasun.entity.service.audit.ContentDataService)1 WebResourceDataService (org.asqatasun.entity.service.subject.WebResourceDataService)1 WebResource (org.asqatasun.entity.subject.WebResource)1 ScenarioLoaderFactory (org.asqatasun.scenarioloader.ScenarioLoaderFactory)1