Quellcode durchsuchen

Initial work.

pull/150/head
Greg Holmes vor 9 Jahren
Ursprung
Commit
c286e8997b

+ 29
- 0
src/com/dmdirc/ui/core/autocommands/AutoCommandType.java Datei anzeigen

@@ -0,0 +1,29 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.ui.core.autocommands;
24
+
25
+public enum AutoCommandType {
26
+    GLOBAL,
27
+    CONNECTION,
28
+    ALL
29
+}

+ 154
- 0
src/com/dmdirc/ui/core/autocommands/AutoCommandsModel.java Datei anzeigen

@@ -0,0 +1,154 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.ui.core.autocommands;
24
+
25
+import com.dmdirc.commandparser.auto.AutoCommand;
26
+import com.dmdirc.commandparser.auto.AutoCommandManager;
27
+
28
+import com.google.common.collect.Sets;
29
+
30
+import java.util.Collection;
31
+import java.util.Collections;
32
+import java.util.Optional;
33
+import java.util.Set;
34
+
35
+import javax.annotation.Nonnull;
36
+
37
+import static com.google.common.base.Preconditions.checkArgument;
38
+import static com.google.common.base.Preconditions.checkNotNull;
39
+
40
+public class AutoCommandsModel {
41
+
42
+    private final AutoCommandManager manager;
43
+    private final AutoCommandType type;
44
+    private final Set<AutoCommand> originalCommands;
45
+    private final Set<MutableAutoCommand> commands;
46
+    private Optional<MutableAutoCommand> selectedCommand;
47
+
48
+    public AutoCommandsModel(final AutoCommandManager manager, final AutoCommandType type) {
49
+        this.manager = manager;
50
+        this.type = type;
51
+        originalCommands = Sets.newHashSet();
52
+        commands = Sets.newHashSet();
53
+    }
54
+
55
+    public void loadModel() {
56
+        originalCommands.clear();
57
+        commands.clear();
58
+        selectedCommand = Optional.empty();
59
+        switch(type) {
60
+            case ALL:
61
+                manager.getAutoCommands().stream().map(c -> {
62
+                    originalCommands.add(c);
63
+                    return new MutableAutoCommand(c);
64
+                }).forEach(commands::add);
65
+                break;
66
+            case CONNECTION:
67
+                originalCommands.addAll(manager.getConnectionAutoCommands());
68
+                manager.getConnectionAutoCommands()
69
+                        .stream().map(MutableAutoCommand::new).forEach(commands::add);
70
+                break;
71
+            case GLOBAL:
72
+                originalCommands.addAll(manager.getGlobalAutoCommands());
73
+                manager.getGlobalAutoCommands()
74
+                        .stream().map(MutableAutoCommand::new).forEach(commands::add);
75
+                break;
76
+        }
77
+    }
78
+
79
+    public Set<MutableAutoCommand> getAutoCommands() {
80
+        return Collections.unmodifiableSet(commands);
81
+    }
82
+
83
+    public void setAutoCommands(final Collection<MutableAutoCommand> commands) {
84
+        this.commands.clear();
85
+        this.commands.addAll(commands);
86
+    }
87
+
88
+    public Optional<MutableAutoCommand> getSelectedCommand() {
89
+        return selectedCommand;
90
+    }
91
+
92
+    public void setSelectedCommand(final Optional<MutableAutoCommand> selectedCommand) {
93
+        selectedCommand.ifPresent(s -> checkArgument(commands.contains(s)));
94
+        this.selectedCommand = selectedCommand;
95
+    }
96
+
97
+    public Optional<String> getSelectedCommandServer() {
98
+        if (selectedCommand.isPresent()) {
99
+            return selectedCommand.get().getServer();
100
+        }
101
+        return Optional.empty();
102
+    }
103
+
104
+    public Optional<String> getSelectedCommandNetwork() {
105
+        if (selectedCommand.isPresent()) {
106
+            return selectedCommand.get().getNetwork();
107
+        }
108
+        return Optional.empty();
109
+    }
110
+
111
+    public Optional<String> getSelectedCommandProfile() {
112
+        if (selectedCommand.isPresent()) {
113
+            return selectedCommand.get().getProfile();
114
+        }
115
+        return Optional.empty();
116
+    }
117
+
118
+    public String getSelectedCommandResponse() {
119
+        if (selectedCommand.isPresent()) {
120
+            return selectedCommand.get().getResponse();
121
+        }
122
+        return "";
123
+    }
124
+
125
+    public void setSelectedCommandServer(final Optional<String> server) {
126
+        selectedCommand.ifPresent(s -> s.setServer(server));
127
+    }
128
+
129
+    public void setSelectedCommandNetwork(final Optional<String> network) {
130
+        selectedCommand.ifPresent(s -> s.setNetwork(network));
131
+    }
132
+
133
+    public void setSelectedCommandProfile(final Optional<String> profile) {
134
+        selectedCommand.ifPresent(s -> s.setProfile(profile));
135
+    }
136
+
137
+    public void setSelectedCommandResponse(@Nonnull final String response) {
138
+        checkNotNull(response);
139
+        selectedCommand.ifPresent(s -> s.setResponse(response));
140
+    }
141
+
142
+    public void addCommand(final MutableAutoCommand command) {
143
+        commands.add(command);
144
+    }
145
+
146
+    public void removeCommand(final MutableAutoCommand command) {
147
+        commands.remove(command);
148
+    }
149
+
150
+    public void save() {
151
+        originalCommands.forEach(manager::removeAutoCommand);
152
+        commands.stream().map(MutableAutoCommand::getAutoCommand).forEach(manager::addAutoCommand);
153
+    }
154
+}

+ 8
- 0
src/com/dmdirc/ui/core/autocommands/MutableAutoCommand.java Datei anzeigen

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.ui.core.autocommands;
24 24
 
25 25
 import com.dmdirc.commandparser.auto.AutoCommand;
26
+import com.dmdirc.ui.core.profiles.MutableProfile;
26 27
 
27 28
 import com.google.common.base.MoreObjects;
28 29
 
@@ -41,6 +42,13 @@ public class MutableAutoCommand {
41 42
     private Optional<String> profile;
42 43
     private String response;
43 44
 
45
+    public MutableAutoCommand(@Nonnull final AutoCommand command) {
46
+        this(command.getServer(),
47
+                command.getNetwork(),
48
+                command.getProfile(),
49
+                command.getResponse());
50
+    }
51
+
44 52
     public MutableAutoCommand(
45 53
             final Optional<String> server,
46 54
             final Optional<String> network,

+ 283
- 0
test/com/dmdirc/ui/core/autocommands/AutoCommandsModelTest.java Datei anzeigen

@@ -0,0 +1,283 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.ui.core.autocommands;
24
+
25
+import com.dmdirc.commandparser.auto.AutoCommand;
26
+import com.dmdirc.commandparser.auto.AutoCommandManager;
27
+
28
+import com.google.common.collect.Sets;
29
+
30
+import java.util.Optional;
31
+
32
+import org.junit.Before;
33
+import org.junit.Test;
34
+import org.junit.runner.RunWith;
35
+import org.mockito.Mock;
36
+import org.mockito.runners.MockitoJUnitRunner;
37
+
38
+import static junit.framework.TestCase.assertEquals;
39
+import static junit.framework.TestCase.assertFalse;
40
+import static junit.framework.TestCase.assertTrue;
41
+import static org.mockito.Mockito.never;
42
+import static org.mockito.Mockito.verify;
43
+import static org.mockito.Mockito.when;
44
+
45
+@RunWith(MockitoJUnitRunner.class)
46
+public class AutoCommandsModelTest {
47
+
48
+    @Mock private AutoCommandManager manager;
49
+    private AutoCommandsModel instance;
50
+    private MutableAutoCommand mutableCommand1;
51
+    private MutableAutoCommand mutableCommand2;
52
+    private MutableAutoCommand mutableCommand3;
53
+    private MutableAutoCommand mutableCommand4;
54
+    private MutableAutoCommand mutableCommand5;
55
+
56
+    @Before
57
+    public void setUp() throws Exception {
58
+        final AutoCommand command1 = new AutoCommand(Optional.of("server1"),
59
+                Optional.of("network1"), Optional.of("profile1"), "response1");
60
+        final AutoCommand command2 = new AutoCommand(Optional.empty(),
61
+                Optional.empty(), Optional.of("profile2"), "response2");
62
+        final AutoCommand command3 = new AutoCommand(Optional.of("server3"),
63
+                Optional.of("network3"), Optional.of("profile3"), "response3");
64
+        final AutoCommand command4 = new AutoCommand(Optional.empty(),
65
+                Optional.empty(), Optional.of("profile4"), "response4");
66
+        final AutoCommand command5 = new AutoCommand(Optional.empty(),
67
+                Optional.empty(), Optional.of("profile5"), "response5");
68
+        mutableCommand1 = new MutableAutoCommand(command1);
69
+        mutableCommand2 = new MutableAutoCommand(command2);
70
+        mutableCommand3 = new MutableAutoCommand(command3);
71
+        mutableCommand4 = new MutableAutoCommand(command4);
72
+        mutableCommand5 = new MutableAutoCommand(command5);
73
+        when(manager.getAutoCommands())
74
+                .thenReturn(Sets.newHashSet(command1, command2, command3, command4));
75
+        when(manager.getConnectionAutoCommands()).thenReturn(Sets.newHashSet(command1, command3));
76
+        when(manager.getGlobalAutoCommands()).thenReturn(Sets.newHashSet(command2, command4));
77
+        instance = new AutoCommandsModel(manager, AutoCommandType.ALL);
78
+        instance.loadModel();
79
+    }
80
+
81
+    @Test
82
+    public void testLoadModel_All() throws Exception {
83
+        instance = new AutoCommandsModel(manager, AutoCommandType.ALL);
84
+        assertTrue(instance.getAutoCommands().isEmpty());
85
+        instance.loadModel();
86
+        assertFalse(instance.getAutoCommands().isEmpty());
87
+        assertEquals(4, instance.getAutoCommands().size());
88
+        assertTrue(instance.getAutoCommands().contains(mutableCommand1));
89
+        assertTrue(instance.getAutoCommands().contains(mutableCommand2));
90
+        assertTrue(instance.getAutoCommands().contains(mutableCommand3));
91
+        assertTrue(instance.getAutoCommands().contains(mutableCommand4));
92
+    }
93
+
94
+    @Test
95
+    public void testLoadModel_Global() throws Exception {
96
+        instance = new AutoCommandsModel(manager, AutoCommandType.GLOBAL);
97
+        assertTrue(instance.getAutoCommands().isEmpty());
98
+        instance.loadModel();
99
+        assertFalse(instance.getAutoCommands().isEmpty());
100
+        assertEquals(2, instance.getAutoCommands().size());
101
+        assertFalse(instance.getAutoCommands().contains(mutableCommand1));
102
+        assertTrue(instance.getAutoCommands().contains(mutableCommand2));
103
+        assertFalse(instance.getAutoCommands().contains(mutableCommand3));
104
+        assertTrue(instance.getAutoCommands().contains(mutableCommand4));
105
+    }
106
+
107
+    @Test
108
+    public void testLoadModel_Connection() throws Exception {
109
+        instance = new AutoCommandsModel(manager, AutoCommandType.CONNECTION);
110
+        assertTrue(instance.getAutoCommands().isEmpty());
111
+        instance.loadModel();
112
+        assertFalse(instance.getAutoCommands().isEmpty());
113
+        assertEquals(2, instance.getAutoCommands().size());
114
+        assertTrue(instance.getAutoCommands().contains(mutableCommand1));
115
+        assertFalse(instance.getAutoCommands().contains(mutableCommand2));
116
+        assertTrue(instance.getAutoCommands().contains(mutableCommand3));
117
+        assertFalse(instance.getAutoCommands().contains(mutableCommand4));
118
+    }
119
+
120
+    @Test
121
+    public void testSetAutoCommands_Empty() throws Exception {
122
+        assertFalse(instance.getAutoCommands().isEmpty());
123
+        instance.setAutoCommands(Sets.newHashSet());
124
+        assertTrue(instance.getAutoCommands().isEmpty());
125
+    }
126
+
127
+    @Test
128
+    public void testSetAutoCommands_NotEmpty() throws Exception {
129
+        assertEquals(4, instance.getAutoCommands().size());
130
+        instance.setAutoCommands(Sets.newHashSet(mutableCommand1, mutableCommand2));
131
+        assertEquals(2, instance.getAutoCommands().size());
132
+    }
133
+
134
+    @Test
135
+    public void testGetSelectedCommand() throws Exception {
136
+        assertEquals(Optional.<MutableAutoCommand>empty(), instance.getSelectedCommand());
137
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
138
+        assertEquals(Optional.of(mutableCommand1), instance.getSelectedCommand());
139
+    }
140
+
141
+    @Test(expected = IllegalArgumentException.class)
142
+    public void testSetSelectedCommand_UnknownCommand() {
143
+        assertEquals(Optional.<MutableAutoCommand>empty(), instance.getSelectedCommand());
144
+        instance.setSelectedCommand(Optional.of(mutableCommand5));
145
+    }
146
+
147
+    @Test
148
+    public void testSetSelectedCommand_EmptyCommand() {
149
+        assertEquals(Optional.<MutableAutoCommand>empty(), instance.getSelectedCommand());
150
+        instance.setSelectedCommand(Optional.of(mutableCommand4));
151
+        assertEquals(Optional.of(mutableCommand4), instance.getSelectedCommand());
152
+        instance.setSelectedCommand(Optional.empty());
153
+        assertEquals(Optional.<MutableAutoCommand>empty(), instance.getSelectedCommand());
154
+    }
155
+
156
+    @Test
157
+    public void testGetSelectedCommandServer() throws Exception {
158
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandServer());
159
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
160
+        assertEquals(mutableCommand1.getServer(), instance.getSelectedCommandServer());
161
+    }
162
+
163
+    @Test
164
+    public void testGetSelectedCommandNetwork() throws Exception {
165
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandNetwork());
166
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
167
+        assertEquals(mutableCommand1.getNetwork(), instance.getSelectedCommandNetwork());
168
+    }
169
+
170
+    @Test
171
+    public void testGetSelectedCommandProfile() throws Exception {
172
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandProfile());
173
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
174
+        assertEquals(mutableCommand1.getProfile(), instance.getSelectedCommandProfile());
175
+    }
176
+
177
+    @Test
178
+    public void testGetSelectedCommandResponse() throws Exception {
179
+        assertEquals("", instance.getSelectedCommandResponse());
180
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
181
+        assertEquals(mutableCommand1.getResponse(), instance.getSelectedCommandResponse());
182
+    }
183
+
184
+    @Test
185
+    public void testSetSelectedCommandServer_Empty() throws Exception {
186
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandServer());
187
+        instance.setSelectedCommandServer(Optional.of("server"));
188
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandServer());
189
+    }
190
+
191
+    @Test
192
+    public void testSetSelectedCommandServer() throws Exception {
193
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandServer());
194
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
195
+        instance.setSelectedCommandServer(Optional.of("server"));
196
+        assertEquals(Optional.of("server"), instance.getSelectedCommandServer());
197
+    }
198
+
199
+    @Test
200
+    public void testSetSelectedCommandNetwork_Empty() throws Exception {
201
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandNetwork());
202
+        instance.setSelectedCommandNetwork(Optional.of("network"));
203
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandNetwork());
204
+    }
205
+
206
+    @Test
207
+    public void testSetSelectedCommandNetwork() throws Exception {
208
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandNetwork());
209
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
210
+        instance.setSelectedCommandNetwork(Optional.of("network"));
211
+        assertEquals(Optional.of("network"), instance.getSelectedCommandNetwork());
212
+    }
213
+
214
+    @Test
215
+    public void testSetSelectedCommandProfile_Empty() throws Exception {
216
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandProfile());
217
+        instance.setSelectedCommandProfile(Optional.of("profile"));
218
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandProfile());
219
+    }
220
+
221
+    @Test
222
+    public void testSetSelectedCommandProfile() throws Exception {
223
+        assertEquals(Optional.<String>empty(), instance.getSelectedCommandProfile());
224
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
225
+        instance.setSelectedCommandProfile(Optional.of("profile"));
226
+        assertEquals(Optional.of("profile"), instance.getSelectedCommandProfile());
227
+    }
228
+
229
+    @Test
230
+    public void testSetSelectedCommandResponse_Empty() throws Exception {
231
+        assertEquals("", instance.getSelectedCommandResponse());
232
+        instance.setSelectedCommandResponse("response");
233
+        assertEquals("", instance.getSelectedCommandResponse());
234
+    }
235
+
236
+    @Test(expected = NullPointerException.class)
237
+    public void testSetSelectedCommandResponse_Null() throws Exception {
238
+        assertEquals("", instance.getSelectedCommandResponse());
239
+        instance.setSelectedCommandResponse(null);
240
+    }
241
+
242
+    @Test
243
+    public void testSetSelectedCommandResponse() throws Exception {
244
+        assertEquals("", instance.getSelectedCommandResponse());
245
+        instance.setSelectedCommand(Optional.of(mutableCommand1));
246
+        instance.setSelectedCommandResponse("response");
247
+        assertEquals("response", instance.getSelectedCommandResponse());
248
+    }
249
+
250
+    @Test
251
+    public void testAddCommand() throws Exception {
252
+        assertEquals(4, instance.getAutoCommands().size());
253
+        assertFalse(instance.getAutoCommands().contains(mutableCommand5));
254
+        instance.addCommand(mutableCommand5);
255
+        assertEquals(5, instance.getAutoCommands().size());
256
+        assertTrue(instance.getAutoCommands().contains(mutableCommand5));
257
+    }
258
+
259
+    @Test
260
+    public void testRemoveCommand() throws Exception {
261
+        assertEquals(4, instance.getAutoCommands().size());
262
+        assertTrue(instance.getAutoCommands().contains(mutableCommand4));
263
+        instance.removeCommand(mutableCommand4);
264
+        assertEquals(3, instance.getAutoCommands().size());
265
+        assertFalse(instance.getAutoCommands().contains(mutableCommand4));
266
+    }
267
+
268
+    @Test
269
+    public void testSave() throws Exception {
270
+        instance.addCommand(mutableCommand5);
271
+        instance.removeCommand(mutableCommand1);
272
+        instance.save();
273
+        verify(manager).removeAutoCommand(mutableCommand1.getAutoCommand());
274
+        verify(manager).removeAutoCommand(mutableCommand2.getAutoCommand());
275
+        verify(manager).removeAutoCommand(mutableCommand3.getAutoCommand());
276
+        verify(manager).removeAutoCommand(mutableCommand4.getAutoCommand());
277
+        verify(manager, never()).addAutoCommand(mutableCommand1.getAutoCommand());
278
+        verify(manager).addAutoCommand(mutableCommand2.getAutoCommand());
279
+        verify(manager).addAutoCommand(mutableCommand3.getAutoCommand());
280
+        verify(manager).addAutoCommand(mutableCommand4.getAutoCommand());
281
+        verify(manager).addAutoCommand(mutableCommand5.getAutoCommand());
282
+    }
283
+}

+ 10
- 0
test/com/dmdirc/ui/core/autocommands/MutableAutoCommandTest.java Datei anzeigen

@@ -40,6 +40,16 @@ public class MutableAutoCommandTest {
40 40
     private final Optional<String> profile = Optional.of("profile");
41 41
     private static final String response = "response";
42 42
 
43
+    @Test
44
+    public void testConstructor() {
45
+        final AutoCommand autoCommand = new AutoCommand(server, network, profile, response);
46
+        command = new MutableAutoCommand(autoCommand);
47
+        assertEquals(server, command.getServer());
48
+        assertEquals(network, command.getNetwork());
49
+        assertEquals(profile, command.getProfile());
50
+        assertEquals(response, command.getResponse());
51
+    }
52
+
43 53
     @Test
44 54
     public void testGetServer() {
45 55
         command = new MutableAutoCommand(server, network, profile, response);

Laden…
Abbrechen
Speichern