mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
renamed PluginWrapper to InstalledPlugin
This commit is contained in:
@@ -42,7 +42,7 @@ import java.nio.file.Path;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class PluginWrapper
|
||||
public final class InstalledPlugin
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ public final class PluginWrapper
|
||||
* @param webResourceLoader web resource loader
|
||||
* @param directory plugin directory
|
||||
*/
|
||||
public PluginWrapper(Plugin plugin, ClassLoader classLoader,
|
||||
public InstalledPlugin(Plugin plugin, ClassLoader classLoader,
|
||||
WebResourceLoader webResourceLoader, Path directory)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
@@ -68,7 +68,7 @@ public interface PluginLoader
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<PluginWrapper> getInstalledPlugins();
|
||||
public Collection<InstalledPlugin> getInstalledPlugins();
|
||||
|
||||
/**
|
||||
* Returns a {@link ClassLoader} which is able to load classes and resources
|
||||
|
||||
@@ -7,7 +7,7 @@ import sonia.scm.plugin.Plugin;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.plugin.PluginManager;
|
||||
import sonia.scm.plugin.PluginPermissions;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.InstalledPlugin;
|
||||
import sonia.scm.web.VndMediaType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -53,7 +53,7 @@ public class InstalledPluginResource {
|
||||
@Produces(VndMediaType.PLUGIN_COLLECTION)
|
||||
public Response getInstalledPlugins() {
|
||||
PluginPermissions.read().check();
|
||||
List<PluginWrapper> plugins = new ArrayList<>(pluginLoader.getInstalledPlugins());
|
||||
List<InstalledPlugin> plugins = new ArrayList<>(pluginLoader.getInstalledPlugins());
|
||||
return Response.ok(collectionMapper.map(plugins)).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import de.otto.edison.hal.Embedded;
|
||||
import de.otto.edison.hal.HalRepresentation;
|
||||
import de.otto.edison.hal.Links;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.InstalledPlugin;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -25,7 +25,7 @@ public class PluginDtoCollectionMapper {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public HalRepresentation map(List<PluginWrapper> plugins) {
|
||||
public HalRepresentation map(List<InstalledPlugin> plugins) {
|
||||
List<PluginDto> dtos = plugins.stream().map(mapper::map).collect(toList());
|
||||
return new HalRepresentation(createInstalledPluginsLinks(), embedDtos(dtos));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.ObjectFactory;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
import sonia.scm.plugin.PluginState;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.InstalledPlugin;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -20,7 +20,7 @@ public abstract class PluginDtoMapper {
|
||||
@Inject
|
||||
private ResourceLinks resourceLinks;
|
||||
|
||||
public PluginDto map(PluginWrapper plugin) {
|
||||
public PluginDto map(InstalledPlugin plugin) {
|
||||
return map(plugin.getPlugin().getInformation());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.google.inject.Inject;
|
||||
import de.otto.edison.hal.Embedded;
|
||||
import de.otto.edison.hal.HalRepresentation;
|
||||
import de.otto.edison.hal.Links;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.InstalledPlugin;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -24,7 +24,7 @@ public class UIPluginDtoCollectionMapper {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public HalRepresentation map(Collection<PluginWrapper> plugins) {
|
||||
public HalRepresentation map(Collection<InstalledPlugin> plugins) {
|
||||
List<UIPluginDto> dtos = plugins.stream().map(mapper::map).collect(toList());
|
||||
return new HalRepresentation(createLinks(), embedDtos(dtos));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package sonia.scm.api.v2.resources;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import de.otto.edison.hal.Links;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.InstalledPlugin;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -25,7 +25,7 @@ public class UIPluginDtoMapper {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public UIPluginDto map(PluginWrapper plugin) {
|
||||
public UIPluginDto map(InstalledPlugin plugin) {
|
||||
UIPluginDto dto = new UIPluginDto(
|
||||
plugin.getPlugin().getInformation().getName(),
|
||||
getScriptResources(plugin)
|
||||
@@ -40,7 +40,7 @@ public class UIPluginDtoMapper {
|
||||
return dto;
|
||||
}
|
||||
|
||||
private Set<String> getScriptResources(PluginWrapper wrapper) {
|
||||
private Set<String> getScriptResources(InstalledPlugin wrapper) {
|
||||
Set<String> scriptResources = wrapper.getPlugin().getResources().getScriptResources();
|
||||
if (scriptResources != null) {
|
||||
return scriptResources.stream()
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.webcohesion.enunciate.metadata.rs.ResponseCode;
|
||||
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
|
||||
import com.webcohesion.enunciate.metadata.rs.TypeHint;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.InstalledPlugin;
|
||||
import sonia.scm.security.AllowAnonymousAccess;
|
||||
import sonia.scm.web.VndMediaType;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class UIPluginResource {
|
||||
@TypeHint(CollectionDto.class)
|
||||
@Produces(VndMediaType.UI_PLUGIN_COLLECTION)
|
||||
public Response getInstalledPlugins() {
|
||||
List<PluginWrapper> plugins = pluginLoader.getInstalledPlugins()
|
||||
List<InstalledPlugin> plugins = pluginLoader.getInstalledPlugins()
|
||||
.stream()
|
||||
.filter(this::filter)
|
||||
.collect(Collectors.toList());
|
||||
@@ -85,7 +85,7 @@ public class UIPluginResource {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean filter(PluginWrapper plugin) {
|
||||
private boolean filter(InstalledPlugin plugin) {
|
||||
return plugin.getPlugin().getResources() != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import sonia.scm.plugin.Plugin;
|
||||
import sonia.scm.plugin.PluginException;
|
||||
import sonia.scm.plugin.PluginLoadException;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.InstalledPlugin;
|
||||
import sonia.scm.plugin.PluginsInternal;
|
||||
import sonia.scm.plugin.SmpArchive;
|
||||
import sonia.scm.util.IOUtil;
|
||||
@@ -43,7 +43,7 @@ public final class PluginBootstrap {
|
||||
|
||||
private final ClassLoaderLifeCycle classLoaderLifeCycle;
|
||||
private final ServletContext servletContext;
|
||||
private final Set<PluginWrapper> plugins;
|
||||
private final Set<InstalledPlugin> plugins;
|
||||
private final PluginLoader pluginLoader;
|
||||
|
||||
PluginBootstrap(ServletContext servletContext, ClassLoaderLifeCycle classLoaderLifeCycle) {
|
||||
@@ -58,7 +58,7 @@ public final class PluginBootstrap {
|
||||
return pluginLoader;
|
||||
}
|
||||
|
||||
public Set<PluginWrapper> getPlugins() {
|
||||
public Set<InstalledPlugin> getPlugins() {
|
||||
return plugins;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class PluginBootstrap {
|
||||
return new DefaultPluginLoader(servletContext, classLoaderLifeCycle.getBootstrapClassLoader(), plugins);
|
||||
}
|
||||
|
||||
private Set<PluginWrapper> collectPlugins() {
|
||||
private Set<InstalledPlugin> collectPlugins() {
|
||||
try {
|
||||
File pluginDirectory = getPluginDirectory();
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
* @param installedPlugins
|
||||
*/
|
||||
public DefaultPluginLoader(ServletContext servletContext, ClassLoader parent,
|
||||
Set<PluginWrapper> installedPlugins)
|
||||
Set<InstalledPlugin> installedPlugins)
|
||||
{
|
||||
this.installedPlugins = installedPlugins;
|
||||
this.uberClassLoader = new UberClassLoader(parent, installedPlugins);
|
||||
@@ -141,7 +141,7 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<PluginWrapper> getInstalledPlugins()
|
||||
public Collection<InstalledPlugin> getInstalledPlugins()
|
||||
{
|
||||
return installedPlugins;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
private final ExtensionProcessor extensionProcessor;
|
||||
|
||||
/** Field description */
|
||||
private final Set<PluginWrapper> installedPlugins;
|
||||
private final Set<InstalledPlugin> installedPlugins;
|
||||
|
||||
/** Field description */
|
||||
private final Set<ScmModule> modules;
|
||||
|
||||
@@ -129,7 +129,7 @@ public class DefaultPluginManager implements PluginManager
|
||||
this.httpClient = httpClient;
|
||||
installedPlugins = new HashMap<>();
|
||||
|
||||
for (PluginWrapper wrapper : pluginLoader.getInstalledPlugins())
|
||||
for (InstalledPlugin wrapper : pluginLoader.getInstalledPlugins())
|
||||
{
|
||||
Plugin plugin = wrapper.getPlugin();
|
||||
PluginInformation info = plugin.getInformation();
|
||||
|
||||
@@ -71,11 +71,11 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<PluginWrapper> plugins) {
|
||||
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<InstalledPlugin> plugins) {
|
||||
this(servletContext, plugins, SCMContext.getContext().getStage());
|
||||
}
|
||||
|
||||
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<PluginWrapper> plugins, Stage stage) {
|
||||
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<InstalledPlugin> plugins, Stage stage) {
|
||||
this.servletContext = servletContext;
|
||||
this.plugins = plugins;
|
||||
this.cache = createCache(stage);
|
||||
@@ -153,7 +153,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
resources.add(ctxResource);
|
||||
}
|
||||
|
||||
for (PluginWrapper wrapper : plugins)
|
||||
for (InstalledPlugin wrapper : plugins)
|
||||
{
|
||||
URL resource = nonDirectory(wrapper.getWebResourceLoader().getResource(path));
|
||||
|
||||
@@ -205,7 +205,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
|
||||
if (resource == null)
|
||||
{
|
||||
for (PluginWrapper wrapper : plugins)
|
||||
for (InstalledPlugin wrapper : plugins)
|
||||
{
|
||||
resource = nonDirectory(wrapper.getWebResourceLoader().getResource(path));
|
||||
|
||||
@@ -259,7 +259,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
private final Cache<String, URL> cache;
|
||||
|
||||
/** Field description */
|
||||
private final Iterable<PluginWrapper> plugins;
|
||||
private final Iterable<InstalledPlugin> plugins;
|
||||
|
||||
/** Field description */
|
||||
private final ServletContext servletContext;
|
||||
|
||||
@@ -157,7 +157,7 @@ public final class PluginNode
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PluginWrapper getWrapper()
|
||||
public InstalledPlugin getWrapper()
|
||||
{
|
||||
return wrapper;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public final class PluginNode
|
||||
*
|
||||
* @param wrapper
|
||||
*/
|
||||
public void setWrapper(PluginWrapper wrapper)
|
||||
public void setWrapper(InstalledPlugin wrapper)
|
||||
{
|
||||
this.wrapper = wrapper;
|
||||
}
|
||||
@@ -192,5 +192,5 @@ public final class PluginNode
|
||||
private final ExplodedSmp plugin;
|
||||
|
||||
/** Field description */
|
||||
private PluginWrapper wrapper;
|
||||
private InstalledPlugin wrapper;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class PluginProcessor
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public Set<PluginWrapper> collectPlugins(ClassLoader classLoader)
|
||||
public Set<InstalledPlugin> collectPlugins(ClassLoader classLoader)
|
||||
throws IOException
|
||||
{
|
||||
logger.info("collect plugins");
|
||||
@@ -187,7 +187,7 @@ public final class PluginProcessor
|
||||
|
||||
logger.trace("create plugin wrappers and build classloaders");
|
||||
|
||||
Set<PluginWrapper> wrappers = createPluginWrappers(classLoader, rootNodes);
|
||||
Set<InstalledPlugin> wrappers = createPluginWrappers(classLoader, rootNodes);
|
||||
|
||||
logger.debug("collected {} plugins", wrappers.size());
|
||||
|
||||
@@ -204,7 +204,7 @@ public final class PluginProcessor
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendPluginWrapper(Set<PluginWrapper> plugins,
|
||||
private void appendPluginWrapper(Set<InstalledPlugin> plugins,
|
||||
ClassLoader classLoader, PluginNode node)
|
||||
throws IOException
|
||||
{
|
||||
@@ -217,7 +217,7 @@ public final class PluginProcessor
|
||||
|
||||
for (PluginNode parent : node.getParents())
|
||||
{
|
||||
PluginWrapper wrapper = parent.getWrapper();
|
||||
InstalledPlugin wrapper = parent.getWrapper();
|
||||
|
||||
if (wrapper != null)
|
||||
{
|
||||
@@ -236,7 +236,7 @@ public final class PluginProcessor
|
||||
|
||||
}
|
||||
|
||||
PluginWrapper plugin =
|
||||
InstalledPlugin plugin =
|
||||
createPluginWrapper(createParentPluginClassLoader(classLoader, parents),
|
||||
smp);
|
||||
|
||||
@@ -257,7 +257,7 @@ public final class PluginProcessor
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendPluginWrappers(Set<PluginWrapper> plugins,
|
||||
private void appendPluginWrappers(Set<InstalledPlugin> plugins,
|
||||
ClassLoader classLoader, List<PluginNode> nodes)
|
||||
throws IOException
|
||||
{
|
||||
@@ -474,11 +474,11 @@ public final class PluginProcessor
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private PluginWrapper createPluginWrapper(ClassLoader classLoader,
|
||||
private InstalledPlugin createPluginWrapper(ClassLoader classLoader,
|
||||
ExplodedSmp smp)
|
||||
throws IOException
|
||||
{
|
||||
PluginWrapper wrapper = null;
|
||||
InstalledPlugin wrapper = null;
|
||||
Path directory = smp.getPath();
|
||||
Path descriptor = directory.resolve(PluginConstants.FILE_DESCRIPTOR);
|
||||
|
||||
@@ -490,7 +490,7 @@ public final class PluginProcessor
|
||||
|
||||
WebResourceLoader resourceLoader = createWebResourceLoader(directory);
|
||||
|
||||
wrapper = new PluginWrapper(plugin, cl, resourceLoader, directory);
|
||||
wrapper = new InstalledPlugin(plugin, cl, resourceLoader, directory);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -512,11 +512,11 @@ public final class PluginProcessor
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private Set<PluginWrapper> createPluginWrappers(ClassLoader classLoader,
|
||||
private Set<InstalledPlugin> createPluginWrappers(ClassLoader classLoader,
|
||||
List<PluginNode> rootNodes)
|
||||
throws IOException
|
||||
{
|
||||
Set<PluginWrapper> plugins = Sets.newHashSet();
|
||||
Set<InstalledPlugin> plugins = Sets.newHashSet();
|
||||
|
||||
appendPluginWrappers(plugins, classLoader, rootNodes);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class PluginsInternal
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Set<PluginWrapper> collectPlugins(ClassLoaderLifeCycle classLoaderLifeCycle,
|
||||
public static Set<InstalledPlugin> collectPlugins(ClassLoaderLifeCycle classLoaderLifeCycle,
|
||||
Path directory)
|
||||
throws IOException
|
||||
{
|
||||
@@ -159,7 +159,7 @@ public final class PluginsInternal
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Iterable<Plugin> unwrap(Iterable<PluginWrapper> wrapped)
|
||||
public static Iterable<Plugin> unwrap(Iterable<InstalledPlugin> wrapped)
|
||||
{
|
||||
return Iterables.transform(wrapped, new Unwrap());
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public final class PluginsInternal
|
||||
* @version Enter version here..., 14/06/05
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
private static class Unwrap implements Function<PluginWrapper, Plugin>
|
||||
private static class Unwrap implements Function<InstalledPlugin, Plugin>
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ public final class PluginsInternal
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Plugin apply(PluginWrapper wrapper)
|
||||
public Plugin apply(InstalledPlugin wrapper)
|
||||
{
|
||||
return wrapper.getPlugin();
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class UberClassLoader extends ClassLoader
|
||||
* @param parent
|
||||
* @param plugins
|
||||
*/
|
||||
public UberClassLoader(ClassLoader parent, Iterable<PluginWrapper> plugins)
|
||||
public UberClassLoader(ClassLoader parent, Iterable<InstalledPlugin> plugins)
|
||||
{
|
||||
super(parent);
|
||||
this.plugins = plugins;
|
||||
@@ -87,7 +87,7 @@ public final class UberClassLoader extends ClassLoader
|
||||
}
|
||||
|
||||
private Class<?> findClassInPlugins(String name) throws ClassNotFoundException {
|
||||
for (PluginWrapper plugin : plugins) {
|
||||
for (InstalledPlugin plugin : plugins) {
|
||||
Class<?> clazz = findClass(plugin.getClassLoader(), name);
|
||||
if (clazz != null) {
|
||||
return clazz;
|
||||
@@ -119,7 +119,7 @@ public final class UberClassLoader extends ClassLoader
|
||||
{
|
||||
URL url = null;
|
||||
|
||||
for (PluginWrapper plugin : plugins)
|
||||
for (InstalledPlugin plugin : plugins)
|
||||
{
|
||||
ClassLoader cl = plugin.getClassLoader();
|
||||
|
||||
@@ -149,7 +149,7 @@ public final class UberClassLoader extends ClassLoader
|
||||
{
|
||||
List<URL> urls = Lists.newArrayList();
|
||||
|
||||
for (PluginWrapper plugin : plugins)
|
||||
for (InstalledPlugin plugin : plugins)
|
||||
{
|
||||
ClassLoader cl = plugin.getClassLoader();
|
||||
|
||||
@@ -194,5 +194,5 @@ public final class UberClassLoader extends ClassLoader
|
||||
Maps.newConcurrentMap();
|
||||
|
||||
/** Field description */
|
||||
private final Iterable<PluginWrapper> plugins;
|
||||
private final Iterable<InstalledPlugin> plugins;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import sonia.scm.plugin.Plugin;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.plugin.PluginState;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.plugin.InstalledPlugin;
|
||||
import sonia.scm.web.VndMediaType;
|
||||
|
||||
import javax.inject.Provider;
|
||||
@@ -86,9 +86,9 @@ class InstalledPluginResourceTest {
|
||||
|
||||
@Test
|
||||
void getInstalledPlugins() throws URISyntaxException, UnsupportedEncodingException {
|
||||
PluginWrapper pluginWrapper = new PluginWrapper(null, null, null, null);
|
||||
when(pluginLoader.getInstalledPlugins()).thenReturn(Collections.singletonList(pluginWrapper));
|
||||
when(collectionMapper.map(Collections.singletonList(pluginWrapper))).thenReturn(new MockedResultDto());
|
||||
InstalledPlugin installedPlugin = new InstalledPlugin(null, null, null, null);
|
||||
when(pluginLoader.getInstalledPlugins()).thenReturn(Collections.singletonList(installedPlugin));
|
||||
when(collectionMapper.map(Collections.singletonList(installedPlugin))).thenReturn(new MockedResultDto());
|
||||
|
||||
MockHttpRequest request = MockHttpRequest.get("/v2/plugins/installed");
|
||||
request.accept(VndMediaType.PLUGIN_COLLECTION);
|
||||
@@ -107,12 +107,12 @@ class InstalledPluginResourceTest {
|
||||
pluginInformation.setName("pluginName");
|
||||
pluginInformation.setState(PluginState.INSTALLED);
|
||||
Plugin plugin = new Plugin(2, pluginInformation, null, null, false, null);
|
||||
PluginWrapper pluginWrapper = new PluginWrapper(plugin, null, null, null);
|
||||
when(pluginLoader.getInstalledPlugins()).thenReturn(Collections.singletonList(pluginWrapper));
|
||||
InstalledPlugin installedPlugin = new InstalledPlugin(plugin, null, null, null);
|
||||
when(pluginLoader.getInstalledPlugins()).thenReturn(Collections.singletonList(installedPlugin));
|
||||
|
||||
PluginDto pluginDto = new PluginDto();
|
||||
pluginDto.setName("pluginName");
|
||||
when(mapper.map(pluginWrapper)).thenReturn(pluginDto);
|
||||
when(mapper.map(installedPlugin)).thenReturn(pluginDto);
|
||||
|
||||
MockHttpRequest request = MockHttpRequest.get("/v2/plugins/installed/pluginName");
|
||||
request.accept(VndMediaType.PLUGIN);
|
||||
|
||||
@@ -170,7 +170,7 @@ public class UIRootResourceTest {
|
||||
assertTrue(response.getContentAsString().contains("/scm/my/bundle.js"));
|
||||
}
|
||||
|
||||
private void mockPlugins(PluginWrapper... plugins) {
|
||||
private void mockPlugins(InstalledPlugin... plugins) {
|
||||
when(pluginLoader.getInstalledPlugins()).thenReturn(Lists.newArrayList(plugins));
|
||||
}
|
||||
|
||||
@@ -180,12 +180,12 @@ public class UIRootResourceTest {
|
||||
return new PluginResources(scripts, styles);
|
||||
}
|
||||
|
||||
private PluginWrapper mockPlugin(String id) {
|
||||
private InstalledPlugin mockPlugin(String id) {
|
||||
return mockPlugin(id, id, null);
|
||||
}
|
||||
|
||||
private PluginWrapper mockPlugin(String id, String name, PluginResources pluginResources) {
|
||||
PluginWrapper wrapper = mock(PluginWrapper.class);
|
||||
private InstalledPlugin mockPlugin(String id, String name, PluginResources pluginResources) {
|
||||
InstalledPlugin wrapper = mock(InstalledPlugin.class);
|
||||
when(wrapper.getId()).thenReturn(id);
|
||||
|
||||
Plugin plugin = mock(Plugin.class);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class DefaultUberWebResourceLoaderTest extends WebResourceLoaderTestBase
|
||||
public void testGetResourceFromCache() {
|
||||
DefaultUberWebResourceLoader resourceLoader =
|
||||
new DefaultUberWebResourceLoader(servletContext,
|
||||
new ArrayList<PluginWrapper>(), Stage.PRODUCTION);
|
||||
new ArrayList<InstalledPlugin>(), Stage.PRODUCTION);
|
||||
|
||||
resourceLoader.getCache().put("/myresource", GITHUB);
|
||||
|
||||
@@ -131,8 +131,8 @@ public class DefaultUberWebResourceLoaderTest extends WebResourceLoaderTestBase
|
||||
{
|
||||
File directory = temp.newFolder();
|
||||
File file = file(directory, "myresource");
|
||||
PluginWrapper wrapper = createPluginWrapper(directory);
|
||||
List<PluginWrapper> plugins = Lists.newArrayList(wrapper);
|
||||
InstalledPlugin wrapper = createPluginWrapper(directory);
|
||||
List<InstalledPlugin> plugins = Lists.newArrayList(wrapper);
|
||||
WebResourceLoader resourceLoader =
|
||||
new DefaultUberWebResourceLoader(servletContext, plugins);
|
||||
|
||||
@@ -170,8 +170,8 @@ public class DefaultUberWebResourceLoaderTest extends WebResourceLoaderTestBase
|
||||
|
||||
File directory = temp.newFolder();
|
||||
File file = file(directory, "myresource");
|
||||
PluginWrapper wrapper = createPluginWrapper(directory);
|
||||
List<PluginWrapper> plugins = Lists.newArrayList(wrapper);
|
||||
InstalledPlugin wrapper = createPluginWrapper(directory);
|
||||
List<InstalledPlugin> plugins = Lists.newArrayList(wrapper);
|
||||
|
||||
UberWebResourceLoader resourceLoader =
|
||||
new DefaultUberWebResourceLoader(servletContext, plugins);
|
||||
@@ -197,11 +197,11 @@ public class DefaultUberWebResourceLoaderTest extends WebResourceLoaderTestBase
|
||||
WebResourceLoader loader = mock(WebResourceLoader.class);
|
||||
when(loader.getResource("/myresource")).thenReturn(url);
|
||||
|
||||
PluginWrapper pluginWrapper = mock(PluginWrapper.class);
|
||||
when(pluginWrapper.getWebResourceLoader()).thenReturn(loader);
|
||||
InstalledPlugin installedPlugin = mock(InstalledPlugin.class);
|
||||
when(installedPlugin.getWebResourceLoader()).thenReturn(loader);
|
||||
|
||||
WebResourceLoader resourceLoader =
|
||||
new DefaultUberWebResourceLoader(servletContext, Lists.newArrayList(pluginWrapper));
|
||||
new DefaultUberWebResourceLoader(servletContext, Lists.newArrayList(installedPlugin));
|
||||
|
||||
assertNull(resourceLoader.getResource("/myresource"));
|
||||
}
|
||||
@@ -214,11 +214,11 @@ public class DefaultUberWebResourceLoaderTest extends WebResourceLoaderTestBase
|
||||
WebResourceLoader loader = mock(WebResourceLoader.class);
|
||||
when(loader.getResource("/myresource")).thenReturn(url);
|
||||
|
||||
PluginWrapper pluginWrapper = mock(PluginWrapper.class);
|
||||
when(pluginWrapper.getWebResourceLoader()).thenReturn(loader);
|
||||
InstalledPlugin installedPlugin = mock(InstalledPlugin.class);
|
||||
when(installedPlugin.getWebResourceLoader()).thenReturn(loader);
|
||||
|
||||
UberWebResourceLoader resourceLoader =
|
||||
new DefaultUberWebResourceLoader(servletContext, Lists.newArrayList(pluginWrapper));
|
||||
new DefaultUberWebResourceLoader(servletContext, Lists.newArrayList(installedPlugin));
|
||||
|
||||
List<URL> resources = resourceLoader.getResources("/myresource");
|
||||
Assertions.assertThat(resources).isEmpty();
|
||||
@@ -232,7 +232,7 @@ public class DefaultUberWebResourceLoaderTest extends WebResourceLoaderTestBase
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private PluginWrapper createPluginWrapper(File directory)
|
||||
private InstalledPlugin createPluginWrapper(File directory)
|
||||
{
|
||||
return createPluginWrapper(directory.toPath());
|
||||
}
|
||||
@@ -245,9 +245,9 @@ public class DefaultUberWebResourceLoaderTest extends WebResourceLoaderTestBase
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private PluginWrapper createPluginWrapper(Path directory)
|
||||
private InstalledPlugin createPluginWrapper(Path directory)
|
||||
{
|
||||
return new PluginWrapper(null, null, new PathWebResourceLoader(directory),
|
||||
return new InstalledPlugin(null, null, new PathWebResourceLoader(directory),
|
||||
directory);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public class PluginProcessorTest
|
||||
{
|
||||
copySmp(PLUGIN_A);
|
||||
|
||||
PluginWrapper plugin = collectAndGetFirst();
|
||||
InstalledPlugin plugin = collectAndGetFirst();
|
||||
|
||||
assertThat(plugin.getId(), is(PLUGIN_A.id));
|
||||
}
|
||||
@@ -145,15 +145,15 @@ public class PluginProcessorTest
|
||||
{
|
||||
copySmps(PLUGIN_A, PLUGIN_B);
|
||||
|
||||
Set<PluginWrapper> plugins = collectPlugins();
|
||||
Set<InstalledPlugin> plugins = collectPlugins();
|
||||
|
||||
assertThat(plugins, hasSize(2));
|
||||
|
||||
PluginWrapper a = findPlugin(plugins, PLUGIN_A.id);
|
||||
InstalledPlugin a = findPlugin(plugins, PLUGIN_A.id);
|
||||
|
||||
assertNotNull(a);
|
||||
|
||||
PluginWrapper b = findPlugin(plugins, PLUGIN_B.id);
|
||||
InstalledPlugin b = findPlugin(plugins, PLUGIN_B.id);
|
||||
|
||||
assertNotNull(b);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public class PluginProcessorTest
|
||||
{
|
||||
copySmp(PLUGIN_A);
|
||||
|
||||
PluginWrapper plugin = collectAndGetFirst();
|
||||
InstalledPlugin plugin = collectAndGetFirst();
|
||||
ClassLoader cl = plugin.getClassLoader();
|
||||
|
||||
// load parent class
|
||||
@@ -216,9 +216,9 @@ public class PluginProcessorTest
|
||||
{
|
||||
copySmps(PLUGIN_A, PLUGIN_B);
|
||||
|
||||
Set<PluginWrapper> plugins = collectPlugins();
|
||||
Set<InstalledPlugin> plugins = collectPlugins();
|
||||
|
||||
PluginWrapper plugin = findPlugin(plugins, PLUGIN_B.id);
|
||||
InstalledPlugin plugin = findPlugin(plugins, PLUGIN_B.id);
|
||||
ClassLoader cl = plugin.getClassLoader();
|
||||
|
||||
// load parent class
|
||||
@@ -247,7 +247,7 @@ public class PluginProcessorTest
|
||||
{
|
||||
copySmp(PLUGIN_A);
|
||||
|
||||
PluginWrapper plugin = collectAndGetFirst();
|
||||
InstalledPlugin plugin = collectAndGetFirst();
|
||||
WebResourceLoader wrl = plugin.getWebResourceLoader();
|
||||
|
||||
assertNotNull(wrl);
|
||||
@@ -269,7 +269,7 @@ public class PluginProcessorTest
|
||||
{
|
||||
copySmp(PLUGIN_F_1_0_0);
|
||||
|
||||
PluginWrapper plugin = collectAndGetFirst();
|
||||
InstalledPlugin plugin = collectAndGetFirst();
|
||||
|
||||
assertThat(plugin.getId(), is(PLUGIN_F_1_0_0.id));
|
||||
copySmp(PLUGIN_F_1_0_1);
|
||||
@@ -302,9 +302,9 @@ public class PluginProcessorTest
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private PluginWrapper collectAndGetFirst() throws IOException
|
||||
private InstalledPlugin collectAndGetFirst() throws IOException
|
||||
{
|
||||
Set<PluginWrapper> plugins = collectPlugins();
|
||||
Set<InstalledPlugin> plugins = collectPlugins();
|
||||
|
||||
assertThat(plugins, hasSize(1));
|
||||
|
||||
@@ -319,7 +319,7 @@ public class PluginProcessorTest
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private Set<PluginWrapper> collectPlugins() throws IOException
|
||||
private Set<InstalledPlugin> collectPlugins() throws IOException
|
||||
{
|
||||
return processor.collectPlugins(PluginProcessorTest.class.getClassLoader());
|
||||
}
|
||||
@@ -368,14 +368,14 @@ public class PluginProcessorTest
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private PluginWrapper findPlugin(Iterable<PluginWrapper> plugin,
|
||||
private InstalledPlugin findPlugin(Iterable<InstalledPlugin> plugin,
|
||||
final String id)
|
||||
{
|
||||
return Iterables.find(plugin, new Predicate<PluginWrapper>()
|
||||
return Iterables.find(plugin, new Predicate<InstalledPlugin>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean apply(PluginWrapper input)
|
||||
public boolean apply(InstalledPlugin input)
|
||||
{
|
||||
return id.equals(input.getId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user