@Test public void testSave() throws Exception { final String ruleContent = "rule \"empty\" when then"; final String creationComment = "initial version"; final Metadata metadata = mock(Metadata.class); when(metadataService.setUpAttributes(path, metadata)).thenReturn(Collections.EMPTY_MAP); when(commentedOptionFactory.makeCommentedOption(creationComment)).thenReturn(commentedOption); drlService.save(path, ruleContent, metadata, creationComment); verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), eq(ruleContent), eq(Collections.EMPTY_MAP), eq(commentedOption)); }
@Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { final String drl = assertPackageName(content, resource); ioService.write(Paths.convert(resource), drl, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
DRLTextEditorServiceImpl extends KieService<DrlModelContent> implements DRLTextEditorService { @Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { final String drl = assertPackageName(content, resource); ioService.write(Paths.convert(resource), drl, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } }
DRLTextEditorServiceImpl extends KieService<DrlModelContent> implements DRLTextEditorService { @Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { final String drl = assertPackageName(content, resource); ioService.write(Paths.convert(resource), drl, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } DRLTextEditorServiceImpl(); @Inject  DRLTextEditorServiceImpl(final SessionInfo sessionInfo); }
DRLTextEditorServiceImpl extends KieService<DrlModelContent> implements DRLTextEditorService { @Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { final String drl = assertPackageName(content, resource); ioService.write(Paths.convert(resource), drl, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } DRLTextEditorServiceImpl(); @Inject  DRLTextEditorServiceImpl(final SessionInfo sessionInfo); @PostConstruct void init(); @Override Path create(final Path context,
                       final String fileName,
                       final String content,
                       final String comment); @Override String load(final Path path); @Override DrlModelContent loadContent(final Path path); @Override List<String> loadClassFields(final Path path,
                                        final String fullyQualifiedClassName); @Override Path save(final Path resource,
                     final String 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 List<ValidationMessage> validate(final Path path,
                                            final String content); @Override String assertPackageName(final String drl,
                                    final Path resource); @Override Path saveAndRename(final Path path,
                              final String newFileName,
                              final Metadata metadata,
                              final String content,
                              final String comment); }
DRLTextEditorServiceImpl extends KieService<DrlModelContent> implements DRLTextEditorService { @Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { final String drl = assertPackageName(content, resource); ioService.write(Paths.convert(resource), drl, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } DRLTextEditorServiceImpl(); @Inject  DRLTextEditorServiceImpl(final SessionInfo sessionInfo); @PostConstruct void init(); @Override Path create(final Path context,
                       final String fileName,
                       final String content,
                       final String comment); @Override String load(final Path path); @Override DrlModelContent loadContent(final Path path); @Override List<String> loadClassFields(final Path path,
                                        final String fullyQualifiedClassName); @Override Path save(final Path resource,
                     final String 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 List<ValidationMessage> validate(final Path path,
                                            final String content); @Override String assertPackageName(final String drl,
                                    final Path resource); @Override Path saveAndRename(final Path path,
                              final String newFileName,
                              final Metadata metadata,
                              final String content,
                              final String comment);  }