PluginServicesImpl implements PluginServices { @Override public org.uberfire.backend.vfs.Path save(final Plugin plugin, final String commitMessage) { if (plugin instanceof PluginSimpleContent) { return save((PluginSimpleContent) plugin, commitMessage); } return null; } PluginServicesImpl(); @Inject  PluginServicesImpl(final @Named("ioStrategy") IOService ioService,
                              final @Named("MediaServletURI") Instance<MediaServletURI> mediaServletURI,
                              final SessionInfo sessionInfo,
                              final Event<PluginAdded> pluginAddedEvent,
                              final Event<PluginDeleted> pluginDeletedEvent,
                              final Event<PluginSaved> pluginSavedEvent,
                              final Event<PluginRenamed> pluginRenamedEvent,
                              final Event<MediaDeleted> mediaDeletedEvent,
                              final DefaultFileNameValidator defaultFileNameValidator,
                              final User identity,
                              final @Named("pluginsFS") FileSystem pluginsFileSystem,
                              final @Named("perspectivesFS") FileSystem perspectivesFileSystem,
                              final SaveAndRenameServiceImpl<Plugin, DefaultMetadata> saveAndRenameService,
                              final SpacesAPI spacesAPI); @PostConstruct void init(); @Override String getMediaServletURI(); @Override Collection<RuntimePlugin> listRuntimePlugins(); @Override Collection<RuntimePlugin> listPluginRuntimePlugins(final org.uberfire.backend.vfs.Path pluginPath); @Override Collection<Plugin> listPlugins(); @Override Collection<Plugin> listPlugins(final PluginType type); @Override Plugin createNewPlugin(final String pluginName,
                                  final PluginType type); @Override PluginContent getPluginContent(final org.uberfire.backend.vfs.Path path); @Override org.uberfire.backend.vfs.Path save(final Plugin plugin,
                                              final String commitMessage); org.uberfire.backend.vfs.Path save(final PluginSimpleContent plugin,
                                              final String commitMessage); @Override void delete(final org.uberfire.backend.vfs.Path path,
                       final String comment); @Override org.uberfire.backend.vfs.Path copy(final org.uberfire.backend.vfs.Path path,
                                              final String newName,
                                              final String comment); @Override org.uberfire.backend.vfs.Path copy(org.uberfire.backend.vfs.Path path,
                                              String newName,
                                              org.uberfire.backend.vfs.Path targetDirectory,
                                              String comment); @Override org.uberfire.backend.vfs.Path rename(final org.uberfire.backend.vfs.Path path,
                                                final String newName,
                                                final String comment); @Override void deleteMedia(final Media media); @Override DynamicMenu getDynamicMenuContent(org.uberfire.backend.vfs.Path path); @Override LayoutEditorModel getLayoutEditor(org.uberfire.backend.vfs.Path path,
                                             PluginType pluginType); @Override org.uberfire.backend.vfs.Path saveMenu(final DynamicMenu plugin,
                                                  final String commitMessage); @Override org.uberfire.backend.vfs.Path saveLayout(LayoutEditorModel plugin,
                                                    String commitMessage); @Override Collection<DynamicMenu> listDynamicMenus(); @Override Collection<LayoutEditorModel> listLayoutEditor(final PluginType pluginType); @Override org.uberfire.backend.vfs.Path save(final org.uberfire.backend.vfs.Path _path,
                                              final Plugin content,
                                              final DefaultMetadata _metadata,
                                              final String comment); @Override org.uberfire.backend.vfs.Path saveAndRename(final org.uberfire.backend.vfs.Path path,
                                                       final String newFileName,
                                                       final DefaultMetadata metadata,
                                                       final Plugin content,
                                                       final String comment);  }
@Test public void testSimpleSaveWithPluginSimpleContent() { final org.uberfire.backend.vfs.Path expected = mock(org.uberfire.backend.vfs.Path.class); final PluginSimpleContent content = mock(PluginSimpleContent.class); final String comment = "comment"; doReturn(expected).when(pluginServices).save(content, comment); final Path actual = pluginServices.save((Plugin) content, comment); assertEquals(expected, actual); }
@Test public void testSimpleSaveWithoutPluginSimpleContent() { final DynamicMenu content = mock(DynamicMenu.class); final String comment = "comment"; final Path actual = pluginServices.save(content, comment); assertNull(actual); }
@Test public void testSave() { final org.uberfire.backend.vfs.Path expected = mock(org.uberfire.backend.vfs.Path.class); final org.uberfire.backend.vfs.Path path = mock(org.uberfire.backend.vfs.Path.class); final DefaultMetadata metadata = mock(DefaultMetadata.class); final PluginSimpleContent content = mock(PluginSimpleContent.class); final String comment = "comment"; doReturn(expected).when(pluginServices).save(content, comment); final Path actual = pluginServices.save(path, content, metadata, comment); assertEquals(expected, actual); }