Search in sources :

Example 41 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools by kiegroup.

the class ScenarioTest method testRemoveFixture.

@Test
public void testRemoveFixture() {
    Scenario sc = new Scenario();
    VerifyRuleFired vf1 = new VerifyRuleFired();
    VerifyRuleFired vf2 = new VerifyRuleFired();
    VerifyRuleFired vf3 = new VerifyRuleFired();
    FactData fd = new FactData();
    sc.getFixtures().add(vf1);
    sc.getFixtures().add(vf2);
    sc.getFixtures().add(vf3);
    sc.getGlobals().add(fd);
    sc.removeFixture(vf2);
    assertEquals(2, sc.getFixtures().size());
    assertEquals(vf1, sc.getFixtures().get(0));
    assertEquals(vf3, sc.getFixtures().get(1));
    assertEquals(1, sc.getGlobals().size());
    sc.removeFixture(fd);
    assertEquals(0, sc.getGlobals().size());
    assertEquals(2, sc.getFixtures().size());
}
Also used : VerifyRuleFired(org.drools.workbench.models.testscenarios.shared.VerifyRuleFired) FactData(org.drools.workbench.models.testscenarios.shared.FactData) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Example 42 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class ScenarioTestEditorServiceImpl method load.

@Override
public Scenario load(final Path path) {
    try {
        final String content = ioService.readAllString(Paths.convert(path));
        final Scenario scenario = ScenarioXMLPersistence.getInstance().unmarshal(content);
        scenario.setName(path.getFileName());
        return scenario;
    } catch (final Exception e) {
        logger.error("Unable to unmarshal content. Returning an empty Test Scenario.", e);
        final Package resolvedPackage = moduleService.resolvePackage(path);
        final Scenario scenario = new Scenario();
        if (resolvedPackage != null) {
            scenario.setPackageName(resolvedPackage.getPackageName());
        }
        scenario.setImports(new Imports());
        return scenario;
    }
}
Also used : Package(org.guvnor.common.services.project.model.Package) Imports(org.kie.soup.project.datamodel.imports.Imports) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario)

Example 43 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class ScenarioTestEditorServiceImplTest method loadEmptyScenario.

@Test
public void loadEmptyScenario() throws Exception {
    final Path scenarioPath = getEmptyScenarioPath();
    final Scenario loadedScenario = testEditorService.load(scenarioPath);
    assertNotNull(loadedScenario);
}
Also used : Path(org.uberfire.backend.vfs.Path) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Example 44 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class ScenarioTestEditorServiceImplTest method testSaveAndRename.

@Test
public void testSaveAndRename() throws Exception {
    final Path path = mock(Path.class);
    final String newFileName = "newFileName";
    final Metadata metadata = mock(Metadata.class);
    final Scenario content = mock(Scenario.class);
    final String comment = "comment";
    testEditorService.saveAndRename(path, newFileName, metadata, content, comment);
    verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Mockito.anyString(org.mockito.Mockito.anyString) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Example 45 with Scenario

use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.

the class ScenarioTestEditorServiceImplTest method loadBrokenScenario.

@Test
public void loadBrokenScenario() throws Exception {
    final Package pgk = mock(Package.class);
    when(pgk.getPackageName()).thenReturn("org.test");
    when(moduleService.resolvePackage(path)).thenReturn(pgk);
    final Scenario load = testEditorService.load(path);
    assertNotNull(load);
    assertEquals("org.test", load.getPackageName());
    assertNotNull(load.getImports());
}
Also used : Package(org.guvnor.common.services.project.model.Package) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Aggregations

Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)59 Test (org.junit.Test)45 FactData (org.drools.workbench.models.testscenarios.shared.FactData)24 ExecutionTrace (org.drools.workbench.models.testscenarios.shared.ExecutionTrace)20 VerifyFact (org.drools.workbench.models.testscenarios.shared.VerifyFact)17 KieSession (org.kie.api.runtime.KieSession)14 Import (org.kie.soup.project.datamodel.imports.Import)14 VerifyField (org.drools.workbench.models.testscenarios.shared.VerifyField)13 FieldData (org.drools.workbench.models.testscenarios.shared.FieldData)12 ArrayList (java.util.ArrayList)11 VerifyRuleFired (org.drools.workbench.models.testscenarios.shared.VerifyRuleFired)9 Expectation (org.drools.workbench.models.testscenarios.shared.Expectation)6 Path (org.uberfire.backend.vfs.Path)6 Field (org.drools.workbench.models.testscenarios.shared.Field)5 HashMap (java.util.HashMap)4 RetractFact (org.drools.workbench.models.testscenarios.shared.RetractFact)4 Failure (org.junit.runner.notification.Failure)4 RunListener (org.junit.runner.notification.RunListener)4 RunNotifier (org.junit.runner.notification.RunNotifier)4 Date (java.util.Date)3