@Test public void testCreate() throws Exception { final String fileName = "enum.enumeration"; final String fileContent = "'Person.age' : [10,20,30]\n"; final String comment = "comment of the author"; when(commentedOptionFactory.makeCommentedOption(comment)).thenReturn(commentedOption); enumService.create(PathFactory.newPath(fileName, getClass().getResource("enums").toString()), fileName, fileContent, comment); verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), eq(fileContent), eq(commentedOption)); }
@Override public Path create(final Path context, final String fileName, final String content, final String comment) { try { final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName); final Path newPath = Paths.convert(nioPath); if (ioService.exists(nioPath)) { throw new FileAlreadyExistsException(nioPath.toString()); } ioService.write(nioPath, content, commentedOptionFactory.makeCommentedOption(comment)); return newPath; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
EnumServiceImpl extends KieService<EnumModelContent> implements EnumService { @Override public Path create(final Path context, final String fileName, final String content, final String comment) { try { final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName); final Path newPath = Paths.convert(nioPath); if (ioService.exists(nioPath)) { throw new FileAlreadyExistsException(nioPath.toString()); } ioService.write(nioPath, content, commentedOptionFactory.makeCommentedOption(comment)); return newPath; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } }
EnumServiceImpl extends KieService<EnumModelContent> implements EnumService { @Override public Path create(final Path context, final String fileName, final String content, final String comment) { try { final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName); final Path newPath = Paths.convert(nioPath); if (ioService.exists(nioPath)) { throw new FileAlreadyExistsException(nioPath.toString()); } ioService.write(nioPath, content, commentedOptionFactory.makeCommentedOption(comment)); return newPath; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } EnumServiceImpl(); @Inject  EnumServiceImpl(final SessionInfo sessionInfo); }
EnumServiceImpl extends KieService<EnumModelContent> implements EnumService { @Override public Path create(final Path context, final String fileName, final String content, final String comment) { try { final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName); final Path newPath = Paths.convert(nioPath); if (ioService.exists(nioPath)) { throw new FileAlreadyExistsException(nioPath.toString()); } ioService.write(nioPath, content, commentedOptionFactory.makeCommentedOption(comment)); return newPath; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } EnumServiceImpl(); @Inject  EnumServiceImpl(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 EnumModelContent loadContent(final Path path); @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 boolean accepts(final Path path); @Override List<ValidationMessage> validate(final Path path); @Override List<ValidationMessage> validate(final Path path,
                                            final String content); @Override Path saveAndRename(final Path path,
                              final String newFileName,
                              final Metadata metadata,
                              final String content,
                              final String comment); }
EnumServiceImpl extends KieService<EnumModelContent> implements EnumService { @Override public Path create(final Path context, final String fileName, final String content, final String comment) { try { final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName); final Path newPath = Paths.convert(nioPath); if (ioService.exists(nioPath)) { throw new FileAlreadyExistsException(nioPath.toString()); } ioService.write(nioPath, content, commentedOptionFactory.makeCommentedOption(comment)); return newPath; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } EnumServiceImpl(); @Inject  EnumServiceImpl(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 EnumModelContent loadContent(final Path path); @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 boolean accepts(final Path path); @Override List<ValidationMessage> validate(final Path path); @Override List<ValidationMessage> validate(final Path path,
                                            final String content); @Override Path saveAndRename(final Path path,
                              final String newFileName,
                              final Metadata metadata,
                              final String content,
                              final String comment);  }