@Test public void testSave() throws Exception { final String fileName = "enum.enumeration"; final String fileContent = "'Person.age' : [10,20,30]\n"; final String comment = "comment of the author"; final Metadata metadata = mock(Metadata.class); final Path path = PathFactory.newPath(fileName, getClass().getResource("enums").toString()); when(commentedOptionFactory.makeCommentedOption(comment)).thenReturn(commentedOption); when(metadataService.setUpAttributes(path, metadata)).thenReturn(Collections.EMPTY_MAP); enumService.save(path, fileContent, metadata, comment); verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), eq(fileContent), eq(Collections.EMPTY_MAP), eq(commentedOption)); }
@Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { ioService.write(Paths.convert(resource), content, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); invalidateDMOPackageCache.fire(new InvalidateDMOPackageCacheEvent(resource)); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
EnumServiceImpl extends KieService<EnumModelContent> implements EnumService { @Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { ioService.write(Paths.convert(resource), content, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); invalidateDMOPackageCache.fire(new InvalidateDMOPackageCacheEvent(resource)); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } }
EnumServiceImpl extends KieService<EnumModelContent> implements EnumService { @Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { ioService.write(Paths.convert(resource), content, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); invalidateDMOPackageCache.fire(new InvalidateDMOPackageCacheEvent(resource)); return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } EnumServiceImpl(); @Inject  EnumServiceImpl(final SessionInfo sessionInfo); }
EnumServiceImpl extends KieService<EnumModelContent> implements EnumService { @Override public Path save(final Path resource, final String content, final Metadata metadata, final String comment) { try { ioService.write(Paths.convert(resource), content, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); invalidateDMOPackageCache.fire(new InvalidateDMOPackageCacheEvent(resource)); return resource; } 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 save(final Path resource, final String content, final Metadata metadata, final String comment) { try { ioService.write(Paths.convert(resource), content, metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment)); invalidateDMOPackageCache.fire(new InvalidateDMOPackageCacheEvent(resource)); return resource; } 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);  }