Browse Source

Inject GlobalCommandParser, and tidying up.

Rename ActionFactory methods to be consistent with @Factory-generated ones.

Change-Id: Iafd20682f2fb0a166c6d7502443b56c3263da85d
Depends-On: Ifa75714ab3445634e61df3d99792cdef602d319e
Reviewed-on: http://gerrit.dmdirc.com/2899
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8rc1
Chris Smith 10 years ago
parent
commit
9591bda084

+ 1
- 1
ivy.xml View File

@@ -18,7 +18,7 @@
18 18
         <dependency org="ch.qos.logback" name="logback-classic" rev="1.+" conf="test->default" />
19 19
 
20 20
         <dependency org="org.projectlombok" name="lombok" rev="latest.integration" conf="main->default" />
21
-        <dependency org="com.dmdirc" name="annotations" rev="[0.3.2,)" conf="main->default" />
21
+        <dependency org="com.dmdirc" name="annotations" rev="[0.3.4,)" conf="main->default" />
22 22
 
23 23
         <dependency org="com.squareup.dagger" name="dagger" rev="1.1.+" conf="main->default" />
24 24
         <dependency org="com.squareup.dagger" name="dagger-compiler" rev="1.1.+" conf="main->default" />

+ 7
- 9
src/com/dmdirc/GlobalWindow.java View File

@@ -26,7 +26,6 @@ import com.dmdirc.ClientModule.GlobalConfig;
26 26
 import com.dmdirc.commandparser.CommandType;
27 27
 import com.dmdirc.commandparser.parsers.CommandParser;
28 28
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
29
-import com.dmdirc.interfaces.CommandController;
30 29
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31 30
 import com.dmdirc.interfaces.config.ConfigChangeListener;
32 31
 import com.dmdirc.messages.MessageSinkManager;
@@ -119,34 +118,34 @@ public class GlobalWindow extends WritableFrameContainer {
119 118
         private final AggregateConfigProvider globalConfig;
120 119
         /** The factory to use to create tab completers. */
121 120
         private final TabCompleterFactory tabCompleterFactory;
122
-        /** The provider to use to retrieve a command controller. */
123
-        private final Provider<CommandController> commandControllerProvider;
124 121
         /** The provider to use to retrieve a window manager. */
125 122
         private final Provider<WindowManager> windowManagerProvider;
126 123
         /** The provider to use to retrieve message sink managers. */
127 124
         private final Provider<MessageSinkManager> messageSinkManagerProvider;
125
+        /** The provider to use to retrieve a global command parser. */
126
+        private final Provider<GlobalCommandParser> globalCommandParserProvider;
128 127
 
129 128
         /**
130 129
          * Creates a new instance of {@link GlobalWindowManager}.
131 130
          *
132 131
          * @param globalConfig Configuration provider to read settings from.
133 132
          * @param tabCompleterFactory Factory to use to create tab completers.
134
-         * @param commandControllerProvider The provider to use to retrieve a command controller.
135 133
          * @param windowManagerProvider The provider to use to retrieve a window manager.
136 134
          * @param messageSinkManagerProvider The provider to use to retrieve a sink manager.
135
+         * @param globalCommandParserProvider The provider to use to retrieve a global command parser.
137 136
          */
138 137
         @Inject
139 138
         public GlobalWindowManager(
140 139
                 @GlobalConfig final AggregateConfigProvider globalConfig,
141 140
                 final TabCompleterFactory tabCompleterFactory,
142
-                final Provider<CommandController> commandControllerProvider,
143 141
                 final Provider<WindowManager> windowManagerProvider,
144
-                final Provider<MessageSinkManager> messageSinkManagerProvider) {
142
+                final Provider<MessageSinkManager> messageSinkManagerProvider,
143
+                final Provider<GlobalCommandParser> globalCommandParserProvider) {
145 144
             this.globalConfig = globalConfig;
146 145
             this.tabCompleterFactory = tabCompleterFactory;
147
-            this.commandControllerProvider = commandControllerProvider;
148 146
             this.windowManagerProvider = windowManagerProvider;
149 147
             this.messageSinkManagerProvider = messageSinkManagerProvider;
148
+            this.globalCommandParserProvider = globalCommandParserProvider;
150 149
         }
151 150
 
152 151
         /** {@inheritDoc} */
@@ -172,8 +171,7 @@ public class GlobalWindow extends WritableFrameContainer {
172 171
                 if (globalConfig.getOptionBool("general", "showglobalwindow")) {
173 172
                     if (globalWindow == null) {
174 173
                         globalWindow = new GlobalWindow(globalConfig,
175
-                                new GlobalCommandParser(globalConfig,
176
-                                commandControllerProvider.get()),
174
+                                globalCommandParserProvider.get(),
177 175
                                 tabCompleterFactory,
178 176
                                 messageSinkManagerProvider.get());
179 177
                         windowManagerProvider.get().addWindow(globalWindow);

+ 9
- 2
src/com/dmdirc/actions/Action.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.actions;
24 24
 
25
+import com.dmdirc.commandparser.parsers.GlobalCommandParser;
25 26
 import com.dmdirc.config.prefs.PreferencesSetting;
26 27
 import com.dmdirc.config.prefs.PreferencesType;
27 28
 import com.dmdirc.interfaces.ActionController;
@@ -44,6 +45,8 @@ import java.util.HashMap;
44 45
 import java.util.List;
45 46
 import java.util.Map;
46 47
 
48
+import javax.inject.Provider;
49
+
47 50
 /**
48 51
  * Describes a single action.
49 52
  */
@@ -81,6 +84,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
81 84
      * Creates a new instance of Action. The group and name specified must
82 85
      * be the group and name of a valid action already saved to disk.
83 86
      *
87
+     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
84 88
      * @param actionController The controller that owns this action.
85 89
      * @param identityController The controller to use to retrieve and update settings.
86 90
      * @param actionsDirectory The base directory to store actions in.
@@ -88,12 +92,13 @@ public class Action extends ActionModel implements ConfigChangeListener {
88 92
      * @param name The name of the action
89 93
      */
90 94
     public Action(
95
+            final Provider<GlobalCommandParser> globalCommandParserProvider,
91 96
             final ActionController actionController,
92 97
             final IdentityController identityController,
93 98
             final String actionsDirectory,
94 99
             final String group,
95 100
             final String name) {
96
-        super(group, name);
101
+        super(globalCommandParserProvider, group, name);
97 102
 
98 103
         this.actionController = actionController;
99 104
         this.identityController = identityController;
@@ -120,6 +125,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
120 125
      * Creates a new instance of Action with the specified properties and saves
121 126
      * it to disk.
122 127
      *
128
+     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
123 129
      * @param actionController The controller that owns this action.
124 130
      * @param identityController The controller to use to retrieve and update settings.
125 131
      * @param actionsDirectory The base directory to store actions in.
@@ -132,6 +138,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
132 138
      * @param newFormat The new formatter to use
133 139
      */
134 140
     public Action(
141
+            final Provider<GlobalCommandParser> globalCommandParserProvider,
135 142
             final ActionController actionController,
136 143
             final IdentityController identityController,
137 144
             final String actionsDirectory,
@@ -142,7 +149,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
142 149
             final List<ActionCondition> conditions,
143 150
             final ConditionTree conditionTree,
144 151
             final String newFormat) {
145
-        super(group, name, triggers, response, conditions, conditionTree, newFormat);
152
+        super(globalCommandParserProvider, group, name, triggers, response, conditions, conditionTree, newFormat);
146 153
 
147 154
         this.actionController = actionController;
148 155
         this.identityController = identityController;

+ 12
- 23
src/com/dmdirc/actions/ActionFactory.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.actions;
24 24
 
25 25
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
26 26
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
27
+import com.dmdirc.commandparser.parsers.GlobalCommandParser;
27 28
 import com.dmdirc.interfaces.ActionController;
28 29
 import com.dmdirc.interfaces.actions.ActionType;
29 30
 import com.dmdirc.interfaces.config.IdentityController;
@@ -40,6 +41,8 @@ import javax.inject.Singleton;
40 41
 @Singleton
41 42
 public class ActionFactory {
42 43
 
44
+    /** Provider of global command parsers. */
45
+    private final Provider<GlobalCommandParser> globalCommandParserProvider;
43 46
     /** The controller that will own actions. */
44 47
     private final Provider<ActionController> actionController;
45 48
     /** The controller to use to retrieve and update settings. */
@@ -52,15 +55,18 @@ public class ActionFactory {
52 55
      *
53 56
      * @param actionController The controller that will own actions.
54 57
      * @param identityController The controller to use to retrieve and update settings.
58
+     * @param globalCommandParserProvider The global command parser to use for actions without windows.
55 59
      * @param actionsDirectory The base directory to store actions in.
56 60
      */
57 61
     @Inject
58 62
     public ActionFactory(
59 63
             final Provider<ActionController> actionController,
60 64
             final Provider<IdentityController> identityController,
65
+            final Provider<GlobalCommandParser> globalCommandParserProvider,
61 66
             @Directory(DirectoryType.ACTIONS) final String actionsDirectory) {
62 67
         this.actionController = actionController;
63 68
         this.identityController = identityController;
69
+        this.globalCommandParserProvider = globalCommandParserProvider;
64 70
         this.actionsDirectory = actionsDirectory;
65 71
     }
66 72
 
@@ -72,27 +78,9 @@ public class ActionFactory {
72 78
      * @param name The name of the action
73 79
      * @return A relevant action.
74 80
      */
75
-    public Action create(final String group, final String name) {
76
-        return new Action(actionController.get(), identityController.get(), actionsDirectory, group, name);
77
-    }
78
-
79
-    /**
80
-     * Creates a new instance of Action with the specified properties and saves
81
-     * it to disk.
82
-     *
83
-     * @param group The group the action belongs to
84
-     * @param name The name of the action
85
-     * @param triggers The triggers to use
86
-     * @param response The response to use
87
-     * @param conditions The conditions to use
88
-     * @param newFormat The new formatter to use
89
-     * @return A relevant action.
90
-     */
91
-    public Action create(final String group, final String name,
92
-            final ActionType[] triggers, final String[] response,
93
-            final List<ActionCondition> conditions, final String newFormat) {
94
-        return create(group, name, triggers, response, conditions,
95
-                ConditionTree.createConjunction(conditions.size()), newFormat);
81
+    public Action getAction(final String group, final String name) {
82
+        return new Action(globalCommandParserProvider, actionController.get(),
83
+                identityController.get(), actionsDirectory, group, name);
96 84
     }
97 85
 
98 86
     /**
@@ -108,11 +96,12 @@ public class ActionFactory {
108 96
      * @param newFormat The new formatter to use
109 97
      * @return A relevant action.
110 98
      */
111
-    public Action create(final String group, final String name,
99
+    public Action getAction(final String group, final String name,
112 100
             final ActionType[] triggers, final String[] response,
113 101
             final List<ActionCondition> conditions,
114 102
             final ConditionTree conditionTree, final String newFormat) {
115
-        return new Action(actionController.get(), identityController.get(), actionsDirectory, group,
103
+        return new Action(globalCommandParserProvider, actionController.get(),
104
+                identityController.get(), actionsDirectory, group,
116 105
                 name, triggers, response, conditions, conditionTree, newFormat);
117 106
     }
118 107
 

+ 1
- 1
src/com/dmdirc/actions/ActionManager.java View File

@@ -317,7 +317,7 @@ public class ActionManager implements ActionController {
317 317
         }
318 318
 
319 319
         for (File file : dir.listFiles()) {
320
-            factory.create(dir.getName(), file.getName());
320
+            factory.getAction(dir.getName(), file.getName());
321 321
         }
322 322
     }
323 323
 

+ 17
- 7
src/com/dmdirc/actions/ActionModel.java View File

@@ -25,22 +25,25 @@ package com.dmdirc.actions;
25 25
 import com.dmdirc.Precondition;
26 26
 import com.dmdirc.ServerManager;
27 27
 import com.dmdirc.WritableFrameContainer;
28
-import com.dmdirc.commandparser.CommandManager;
29 28
 import com.dmdirc.commandparser.parsers.CommandParser;
30 29
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
31
-import com.dmdirc.config.IdentityManager;
32 30
 import com.dmdirc.interfaces.actions.ActionType;
33 31
 
34 32
 import java.util.ArrayList;
35 33
 import java.util.Arrays;
36 34
 import java.util.List;
37 35
 
36
+import javax.inject.Provider;
37
+
38 38
 /**
39 39
  * Represents the basic model of an action, and its triggering mechanism.
40 40
  * Saving and loading are handled by the Action class.
41 41
  */
42 42
 public class ActionModel {
43 43
 
44
+    /** Provider of global command parsers, for use when triggering window-less actions. */
45
+    private final Provider<GlobalCommandParser> globalCommandParserProvider;
46
+
44 47
     /** The group this action belongs to. */
45 48
     protected String group;
46 49
 
@@ -83,10 +86,15 @@ public class ActionModel {
83 86
     /**
84 87
      * Creates a new instance of ActionModel with the specified properties.
85 88
      *
89
+     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
86 90
      * @param group The group the action belongs to
87 91
      * @param name The name of the action
88 92
      */
89
-    public ActionModel(final String group, final String name) {
93
+    public ActionModel(
94
+            final Provider<GlobalCommandParser> globalCommandParserProvider,
95
+            final String group,
96
+            final String name) {
97
+        this.globalCommandParserProvider = globalCommandParserProvider;
90 98
         this.group = group;
91 99
         this.name = name;
92 100
     }
@@ -94,6 +102,7 @@ public class ActionModel {
94 102
     /**
95 103
      * Creates a new instance of ActionModel with the specified properties.
96 104
      *
105
+     * @param globalCommandParserProvider Provider of global command parsers for triggering actions.
97 106
      * @param group The group the action belongs to
98 107
      * @param name The name of the action
99 108
      * @param triggers The triggers to use
@@ -102,11 +111,13 @@ public class ActionModel {
102 111
      * @param conditionTree The condition tree to use
103 112
      * @param newFormat The new formatter to use
104 113
      */
105
-    public ActionModel(final String group, final String name,
114
+    public ActionModel(
115
+            final Provider<GlobalCommandParser> globalCommandParserProvider,
116
+            final String group, final String name,
106 117
             final ActionType[] triggers, final String[] response,
107 118
             final List<ActionCondition> conditions,
108 119
             final ConditionTree conditionTree, final String newFormat) {
109
-        this(group, name);
120
+        this(globalCommandParserProvider, group, name);
110 121
         this.triggers = triggers.clone();
111 122
         this.response = response.clone();
112 123
         this.conditions = conditions;
@@ -154,8 +165,7 @@ public class ActionModel {
154 165
         }
155 166
 
156 167
         if (container == null) {
157
-            cp = new GlobalCommandParser(IdentityManager.getIdentityManager()
158
-                    .getGlobalConfiguration(), CommandManager.getCommandManager());
168
+            cp = globalCommandParserProvider.get();
159 169
         } else {
160 170
             cp = container.getCommandParser();
161 171
         }

+ 3
- 1
src/com/dmdirc/actions/wrappers/Alias.java View File

@@ -25,6 +25,7 @@ package com.dmdirc.actions.wrappers;
25 25
 import com.dmdirc.actions.Action;
26 26
 import com.dmdirc.actions.ActionCondition;
27 27
 import com.dmdirc.actions.ActionFactory;
28
+import com.dmdirc.actions.ConditionTree;
28 29
 import com.dmdirc.actions.CoreActionComparison;
29 30
 import com.dmdirc.actions.CoreActionComponent;
30 31
 import com.dmdirc.actions.CoreActionType;
@@ -231,12 +232,13 @@ public class Alias implements Serializable {
231 232
      * @return A new action for this alias.
232 233
      */
233 234
     public Action createAction() {
234
-        return actionFactory.create(
235
+        return actionFactory.getAction(
235 236
                 AliasWrapper.GROUP_NAME,
236 237
                 getName(),
237 238
                 new ActionType[] {CoreActionType.UNKNOWN_COMMAND, },
238 239
                 getResponse(),
239 240
                 getArguments(),
241
+                ConditionTree.createConjunction(getArguments().size()),
240 242
                 "");
241 243
     }
242 244
 

+ 4
- 2
src/com/dmdirc/actions/wrappers/PerformWrapper.java View File

@@ -29,6 +29,7 @@ import com.dmdirc.actions.ActionCondition;
29 29
 import com.dmdirc.actions.ActionFactory;
30 30
 import com.dmdirc.actions.ActionGroup;
31 31
 import com.dmdirc.actions.ActionManager;
32
+import com.dmdirc.actions.ConditionTree;
32 33
 import com.dmdirc.actions.CoreActionComparison;
33 34
 import com.dmdirc.actions.CoreActionComponent;
34 35
 import com.dmdirc.actions.CoreActionType;
@@ -233,10 +234,11 @@ public class PerformWrapper extends ActionGroup {
233 234
                     CoreActionComparison.STRING_EQUALS, profile));
234 235
         }
235 236
 
236
-        return actionFactory.create(getName(), server + network
237
+        return actionFactory.getAction(getName(), server + network
237 238
                 + (profile == null ? "" : " - " + profile),
238 239
                 new ActionType[]{CoreActionType.SERVER_CONNECTED},
239
-                new String[0], conditions, null);
240
+                new String[0], conditions,
241
+                ConditionTree.createConjunction(conditions.size()), null);
240 242
     }
241 243
 
242 244
     /**

+ 11
- 2
src/com/dmdirc/commandparser/commands/global/Ifplugin.java View File

@@ -39,6 +39,7 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
39 39
 import com.dmdirc.ui.input.TabCompleter;
40 40
 
41 41
 import javax.inject.Inject;
42
+import javax.inject.Provider;
42 43
 
43 44
 /**
44 45
  * The if plugin command allows the user to execute commands based on whether
@@ -55,16 +56,24 @@ public class Ifplugin extends Command implements IntelligentCommand {
55 56
     /** The plugin manager to use to query plugins. */
56 57
     private final PluginManager pluginManager;
57 58
 
59
+    /** Provider of global command parsers. */
60
+    private final Provider<GlobalCommandParser> globalCommandParserProvider;
61
+
58 62
     /**
59 63
      * Creates a new instance of the {@link Ifplugin} command.
60 64
      *
61 65
      * @param controller The controller to use for command information.
62 66
      * @param pluginManager The plugin manager to use to query plugins.
67
+     * @param globalCommandParserProvider Provider to use to retrieve a global command parser.
63 68
      */
64 69
     @Inject
65
-    public Ifplugin(final CommandController controller, final PluginManager pluginManager) {
70
+    public Ifplugin(
71
+            final CommandController controller,
72
+            final PluginManager pluginManager,
73
+            final Provider<GlobalCommandParser> globalCommandParserProvider) {
66 74
         super(controller);
67 75
         this.pluginManager = pluginManager;
76
+        this.globalCommandParserProvider = globalCommandParserProvider;
68 77
     }
69 78
 
70 79
     /** {@inheritDoc} */
@@ -90,7 +99,7 @@ public class Ifplugin extends Command implements IntelligentCommand {
90 99
 
91 100
         if (result != negative) {
92 101
             if (origin == null) {
93
-                new GlobalCommandParser(origin.getConfigManager(), getController())
102
+                globalCommandParserProvider.get()
94 103
                         .parseCommand(null, args.getArgumentsAsString(1));
95 104
             } else {
96 105
                 ((WritableFrameContainer) origin).getCommandParser()

+ 8
- 1
src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.parsers;
24 24
 
25
+import com.dmdirc.ClientModule;
25 26
 import com.dmdirc.FrameContainer;
26 27
 import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandInfo;
@@ -33,9 +34,13 @@ import com.dmdirc.interfaces.config.AggregateConfigProvider;
33 34
 import com.dmdirc.logger.ErrorLevel;
34 35
 import com.dmdirc.logger.Logger;
35 36
 
37
+import javax.inject.Inject;
38
+import javax.inject.Singleton;
39
+
36 40
 /**
37 41
  * The command parser used for global commands.
38 42
  */
43
+@Singleton
39 44
 public class GlobalCommandParser extends CommandParser {
40 45
 
41 46
     /**
@@ -51,7 +56,9 @@ public class GlobalCommandParser extends CommandParser {
51 56
      * @param configManager Config manager to read settings from
52 57
      * @param commandManager Command manager to load commands from
53 58
      */
54
-    public GlobalCommandParser(final AggregateConfigProvider configManager,
59
+    @Inject
60
+    public GlobalCommandParser(
61
+            @ClientModule.GlobalConfig final AggregateConfigProvider configManager,
55 62
             final CommandController commandManager) {
56 63
         super(configManager, commandManager);
57 64
     }

+ 11
- 8
test/com/dmdirc/actions/ActionModelTest.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.actions;
24 24
 
25
+import com.dmdirc.commandparser.parsers.GlobalCommandParser;
25 26
 import com.dmdirc.interfaces.ActionController;
26 27
 import com.dmdirc.interfaces.actions.ActionType;
27 28
 
@@ -29,6 +30,7 @@ import java.util.ArrayList;
29 30
 import java.util.Arrays;
30 31
 import java.util.List;
31 32
 
33
+import javax.inject.Provider;
32 34
 import org.junit.Test;
33 35
 import org.junit.runner.RunWith;
34 36
 import org.mockito.Mock;
@@ -39,11 +41,12 @@ import static org.junit.Assert.*;
39 41
 @RunWith(MockitoJUnitRunner.class)
40 42
 public class ActionModelTest {
41 43
 
44
+    @Mock private Provider<GlobalCommandParser> gcpProvider;
42 45
     @Mock private ActionController actionController;
43 46
 
44 47
     @Test
45 48
     public void testConditions() {
46
-        final ActionModel model = new ActionModel("group", "name");
49
+        final ActionModel model = new ActionModel(gcpProvider, "group", "name");
47 50
 
48 51
         assertTrue("ActionModel must start with no conditions",
49 52
                 model.getConditions().isEmpty());
@@ -58,7 +61,7 @@ public class ActionModelTest {
58 61
 
59 62
     @Test
60 63
     public void testTriggers() {
61
-        final ActionModel model = new ActionModel("group", "name");
64
+        final ActionModel model = new ActionModel(gcpProvider, "group", "name");
62 65
 
63 66
         assertNull("ActionModel must start with null triggers",
64 67
                 model.getTriggers());
@@ -73,7 +76,7 @@ public class ActionModelTest {
73 76
 
74 77
     @Test
75 78
     public void testNewFormat() {
76
-        final ActionModel model = new ActionModel("group", "name");
79
+        final ActionModel model = new ActionModel(gcpProvider, "group", "name");
77 80
 
78 81
         assertNull("ActionModel must start with null format",
79 82
                 model.getNewFormat());
@@ -91,7 +94,7 @@ public class ActionModelTest {
91 94
 
92 95
     @Test
93 96
     public void testResponse() {
94
-        final ActionModel model = new ActionModel("group", "name");
97
+        final ActionModel model = new ActionModel(gcpProvider, "group", "name");
95 98
 
96 99
         assertNull("ActionModel must start with null response",
97 100
                 model.getResponse());
@@ -106,7 +109,7 @@ public class ActionModelTest {
106 109
 
107 110
     @Test
108 111
     public void testGroup() {
109
-        final ActionModel model = new ActionModel("group", "name");
112
+        final ActionModel model = new ActionModel(gcpProvider, "group", "name");
110 113
 
111 114
         assertEquals("ActionModel constructor must set group",
112 115
                 "group", model.getGroup());
@@ -119,7 +122,7 @@ public class ActionModelTest {
119 122
 
120 123
     @Test
121 124
     public void testName() {
122
-        final ActionModel model = new ActionModel("group", "name");
125
+        final ActionModel model = new ActionModel(gcpProvider, "group", "name");
123 126
 
124 127
         assertEquals("ActionModel constructor must set name",
125 128
                 "name", model.getName());
@@ -132,7 +135,7 @@ public class ActionModelTest {
132 135
 
133 136
     @Test
134 137
     public void testTest() {
135
-        final ActionModel model = new ActionModel("group", "name",
138
+        final ActionModel model = new ActionModel(gcpProvider, "group", "name",
136 139
                 new ActionType[]{CoreActionType.CHANNEL_ACTION},
137 140
                 new String[0], Arrays.asList(new ActionCondition[]{
138 141
                     new ActionCondition(2, CoreActionComponent.STRING_STRING,
@@ -152,7 +155,7 @@ public class ActionModelTest {
152 155
 
153 156
     @Test
154 157
     public void testTestNoCondTree() {
155
-        final ActionModel model = new ActionModel("group", "name",
158
+        final ActionModel model = new ActionModel(gcpProvider, "group", "name",
156 159
                 new ActionType[]{CoreActionType.CHANNEL_ACTION},
157 160
                 new String[0], Arrays.asList(new ActionCondition[]{
158 161
                     new ActionCondition(2, CoreActionComponent.STRING_STRING,

+ 10
- 6
test/com/dmdirc/actions/ActionTest.java View File

@@ -21,6 +21,7 @@
21 21
  */
22 22
 package com.dmdirc.actions;
23 23
 
24
+import com.dmdirc.commandparser.parsers.GlobalCommandParser;
24 25
 import com.dmdirc.config.prefs.PreferencesSetting;
25 26
 import com.dmdirc.config.prefs.PreferencesType;
26 27
 import com.dmdirc.interfaces.ActionController;
@@ -40,6 +41,8 @@ import java.util.Arrays;
40 41
 import java.util.HashMap;
41 42
 import java.util.Map;
42 43
 
44
+import javax.inject.Provider;
45
+
43 46
 import org.junit.After;
44 47
 import org.junit.Before;
45 48
 import org.junit.BeforeClass;
@@ -54,6 +57,7 @@ import static org.mockito.Mockito.*;
54 57
 @RunWith(MockitoJUnitRunner.class)
55 58
 public class ActionTest {
56 59
 
60
+    @Mock private Provider<GlobalCommandParser> gcpProvider;
57 61
     @Mock private ActionController actionController;
58 62
     @Mock private ActionGroup actionGroup;
59 63
     @Mock private IdentityController identityController;
@@ -100,7 +104,7 @@ public class ActionTest {
100 104
 
101 105
     @Test
102 106
     public void testSave() {
103
-        new Action(actionController, identityController, testDirectory,
107
+        new Action(gcpProvider, actionController, identityController, testDirectory,
104 108
                 "unit-test", "test1", new ActionType[0],
105 109
                 new String[0], new ArrayList<ActionCondition>(),
106 110
                 ConditionTree.createConjunction(0), null);
@@ -111,7 +115,7 @@ public class ActionTest {
111 115
 
112 116
     @Test
113 117
     public void testSetGroup() {
114
-        Action action = new Action(actionController, identityController, testDirectory,
118
+        Action action = new Action(gcpProvider, actionController, identityController, testDirectory,
115 119
                 "unit-test", "test1", new ActionType[0],
116 120
                 new String[0], new ArrayList<ActionCondition>(),
117 121
                 ConditionTree.createConjunction(0), null);
@@ -125,7 +129,7 @@ public class ActionTest {
125 129
 
126 130
     @Test
127 131
     public void testSetName() {
128
-        Action action = new Action(actionController, identityController, testDirectory,
132
+        Action action = new Action(gcpProvider, actionController, identityController, testDirectory,
129 133
                 "unit-test", "test1", new ActionType[0],
130 134
                 new String[0], new ArrayList<ActionCondition>(),
131 135
                 ConditionTree.createConjunction(0), null);
@@ -139,7 +143,7 @@ public class ActionTest {
139 143
 
140 144
     @Test
141 145
     public void testDelete() {
142
-        Action action = new Action(actionController, identityController, testDirectory,
146
+        Action action = new Action(gcpProvider, actionController, identityController, testDirectory,
143 147
                 "unit-test", "test1", new ActionType[0],
144 148
                 new String[0], new ArrayList<ActionCondition>(),
145 149
                 ConditionTree.createConjunction(0), null);
@@ -152,7 +156,7 @@ public class ActionTest {
152 156
 
153 157
     @Test
154 158
     public void testRead() throws IOException, InvalidConfigFileException {
155
-        Action action = new Action(actionController, identityController, testDirectory,
159
+        Action action = new Action(gcpProvider, actionController, identityController, testDirectory,
156 160
                 "unit-test", "doesn't_exist");
157 161
         action.config = new ConfigFile(getClass().getResourceAsStream("action1"));
158 162
         action.config.read();
@@ -170,7 +174,7 @@ public class ActionTest {
170 174
 
171 175
     @Test
172 176
     public void testMultipleGroups() throws IOException, InvalidConfigFileException {
173
-        Action action = new Action(actionController, identityController, testDirectory,
177
+        Action action = new Action(gcpProvider, actionController, identityController, testDirectory,
174 178
                 "unit-test", "doesn't_exist");
175 179
         action.config = new ConfigFile(getClass().getResourceAsStream("action_multisettings"));
176 180
         action.config.read();

+ 4
- 1
test/com/dmdirc/commandparser/commands/global/IfpluginTest.java View File

@@ -24,9 +24,11 @@ package com.dmdirc.commandparser.commands.global;
24 24
 import com.dmdirc.FrameContainer;
25 25
 import com.dmdirc.commandparser.CommandArguments;
26 26
 import com.dmdirc.commandparser.commands.context.CommandContext;
27
+import com.dmdirc.commandparser.parsers.GlobalCommandParser;
27 28
 import com.dmdirc.interfaces.CommandController;
28 29
 import com.dmdirc.plugins.PluginManager;
29 30
 
31
+import javax.inject.Provider;
30 32
 import org.junit.Before;
31 33
 import org.junit.Test;
32 34
 import org.junit.runner.RunWith;
@@ -38,6 +40,7 @@ import static org.mockito.Mockito.*;
38 40
 @RunWith(MockitoJUnitRunner.class)
39 41
 public class IfpluginTest {
40 42
 
43
+    @Mock private Provider<GlobalCommandParser> gcpProvider;
41 44
     @Mock private CommandController controller;
42 45
     @Mock private PluginManager pluginManager;
43 46
     @Mock private FrameContainer tiw;
@@ -45,7 +48,7 @@ public class IfpluginTest {
45 48
 
46 49
     @Before
47 50
     public void setUp() {
48
-        command = new Ifplugin(controller, pluginManager);
51
+        command = new Ifplugin(controller, pluginManager, gcpProvider);
49 52
     }
50 53
 
51 54
     @Test

Loading…
Cancel
Save