View Javadoc

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