ScenarioSimulationServiceImpl extends KieService<ScenarioSimulationModelContent> implements ScenarioSimulationService { @Override public Path create(final Path context, final String fileName, final ScenarioSimulationModel content, final String comment) { return create(context, fileName, content, comment, Type.RULE, null); } ScenarioSimulationServiceImpl(); @Inject  ScenarioSimulationServiceImpl(final SessionInfo sessionInfo); @PostConstruct void init(); @Override SimulationRunResult runScenario(final Path path,
                                           final ScesimModelDescriptor simulationDescriptor,
                                           final List<ScenarioWithIndex> scenarios,
                                           final Settings settings,
                                           final Background background); @Override Path create(final Path context,
                       final String fileName,
                       final ScenarioSimulationModel content,
                       final String comment); @Override Path create(Path context, String fileName, ScenarioSimulationModel content, String comment, Type type, String value); @Override ScenarioSimulationModel load(final Path path); @Override Path save(final Path resource,
                     final ScenarioSimulationModel content,
                     final Metadata metadata,
                     final String comment); @Override void delete(final Path path,
                       final String comment); @Override Path rename(final Path path,
                       final String newName,
                       final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final Path targetDirectory,
                     final String comment); @Override Path saveAndRename(final Path path,
                              final String newFileName,
                              final Metadata metadata,
                              final ScenarioSimulationModel content,
                              final String comment); @Override List<FactMappingValidationError> validate(Simulation simulation, Settings settings, Path path);  }
@Test public void createRULEScenario() throws Exception { doReturn(false).when(ioServiceMock).exists(any()); ScenarioSimulationModel model = new ScenarioSimulationModel(); assertNull(model.getSimulation()); assertNull(model.getBackground()); assertNull(model.getSettings()); final Path returnPath = service.create(this.path, "test.scesim", model, "Commit comment", Type.RULE, null); assertNotNull(returnPath); assertNotNull(model.getSimulation()); assertNotNull(model.getBackground()); assertNotNull(model.getSettings()); verify(ioServiceMock, times(2)).write(any(org.uberfire.java.nio.file.Path.class), anyString(), any(CommentedOption.class)); }
@Test public void createDMNScenario() throws Exception { doReturn(false).when(ioServiceMock).exists(any()); ScenarioSimulationModel model = new ScenarioSimulationModel(); assertNull(model.getSimulation()); assertNull(model.getBackground()); assertNull(model.getSettings()); final Path returnPath = service.create(this.path, "test.scesim", model, "Commit comment", Type.DMN, "test"); assertNotNull(returnPath); assertNotNull(model.getSimulation()); assertNotNull(model.getBackground()); assertNotNull(model.getSettings()); verify(ioServiceMock, times(2)).write(any(org.uberfire.java.nio.file.Path.class), anyString(), any(CommentedOption.class)); }
@Test(expected = FileAlreadyExistsException.class) public void createFileExists() throws Exception { doReturn(true).when(ioServiceMock).exists(any()); ScenarioSimulationModel model = new ScenarioSimulationModel(); service.create(this.path, "test.scesim", model, "Commit comment"); }