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());
}
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;
}
}
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);
}
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);
}
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());
}
Aggregations