View Javadoc
1   package com.atlassian.plugin;
2   
3   import com.atlassian.plugin.predicate.ModuleDescriptorPredicate;
4   import com.atlassian.plugin.predicate.PluginPredicate;
5   
6   import java.io.InputStream;
7   import java.util.ArrayList;
8   import java.util.Collection;
9   import java.util.List;
10  
11  /**
12   * @since 2.3.0
13   */
14  public class MockPluginAccessor implements PluginAccessor {
15      private Collection<Plugin> allPlugins = new ArrayList<Plugin>();
16  
17      public Collection<Plugin> getPlugins() {
18          return allPlugins;
19      }
20  
21      public void addPlugin(Plugin plugin) {
22          allPlugins.add(plugin);
23      }
24  
25      public Collection<Plugin> getPlugins(final PluginPredicate pluginPredicate) {
26          throw new UnsupportedOperationException();
27      }
28  
29      public Collection<Plugin> getEnabledPlugins() {
30          Collection<Plugin> enabledPlugins = new ArrayList<Plugin>();
31          for (Plugin plugin : allPlugins) {
32              if (plugin.isEnabled()) {
33                  enabledPlugins.add(plugin);
34              }
35          }
36          return enabledPlugins;
37      }
38  
39      public <M> Collection<M> getModules(final ModuleDescriptorPredicate<M> moduleDescriptorPredicate) {
40          throw new UnsupportedOperationException();
41      }
42  
43      public <M> Collection<ModuleDescriptor<M>> getModuleDescriptors(final ModuleDescriptorPredicate<M> moduleDescriptorPredicate) {
44          throw new UnsupportedOperationException();
45      }
46  
47      public Plugin getPlugin(final String key) {
48          for (Plugin plugin : allPlugins) {
49              if (key.equals(plugin.getKey())) {
50                  return plugin;
51              }
52          }
53          return null;
54      }
55  
56      public Plugin getEnabledPlugin(final String pluginKey) {
57          throw new UnsupportedOperationException();
58      }
59  
60      public ModuleDescriptor<?> getPluginModule(final String completeKey) {
61          throw new UnsupportedOperationException();
62      }
63  
64      public ModuleDescriptor<?> getEnabledPluginModule(final String completeKey) {
65          throw new UnsupportedOperationException();
66      }
67  
68      public boolean isPluginEnabled(final String key) {
69          return getPlugin(key).isEnabled();
70      }
71  
72      public boolean isPluginModuleEnabled(final String completeKey) {
73          return false;
74      }
75  
76      public <M> List<M> getEnabledModulesByClass(final Class<M> moduleClass) {
77          throw new UnsupportedOperationException();
78      }
79  
80      public <M> List<M> getEnabledModulesByClassAndDescriptor(final Class<ModuleDescriptor<M>>[] descriptorClazz, final Class<M> moduleClass) {
81          throw new UnsupportedOperationException();
82      }
83  
84      public <M> List<M> getEnabledModulesByClassAndDescriptor(final Class<ModuleDescriptor<M>> descriptorClass, final Class<M> moduleClass) {
85          throw new UnsupportedOperationException();
86      }
87  
88      public <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(final Class<D> descriptorClazz) {
89          throw new UnsupportedOperationException();
90      }
91  
92      @Override
93      public <D extends ModuleDescriptor<?>> List<D> getActiveModuleDescriptorsByClass(Class<D> descriptorClazz) {
94          throw new UnsupportedOperationException("Not implemented");
95      }
96  
97      public <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(final Class<D> descriptorClazz, final boolean verbose) {
98          throw new UnsupportedOperationException();
99      }
100 
101     public <M> List<ModuleDescriptor<M>> getEnabledModuleDescriptorsByType(final String type)
102             throws PluginParseException {
103         throw new UnsupportedOperationException();
104     }
105 
106     public InputStream getDynamicResourceAsStream(final String resourcePath) {
107         throw new UnsupportedOperationException();
108     }
109 
110     public InputStream getPluginResourceAsStream(final String pluginKey, final String resourcePath) {
111         throw new UnsupportedOperationException();
112     }
113 
114     public Class<?> getDynamicPluginClass(final String className) throws ClassNotFoundException {
115         throw new UnsupportedOperationException();
116     }
117 
118     public ClassLoader getClassLoader() {
119         throw new UnsupportedOperationException();
120     }
121 
122     public boolean isSystemPlugin(final String key) {
123         return false;
124     }
125 
126     public PluginRestartState getPluginRestartState(final String key) {
127         throw new UnsupportedOperationException();
128     }
129 
130     public Iterable<ModuleDescriptor<?>> getDynamicModules(final Plugin plugin) {
131         throw new UnsupportedOperationException();
132     }
133 }