Browse Source

Fix up DebugTest.

Fix ambiguous verify calls that somehow work on J7 but not J8.

Tidy imports, use Guava Sets instead of icky AICs.

Change-Id: I2638c0338a898454588ec435c83de849259f9133
Reviewed-on: http://gerrit.dmdirc.com/3564
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
changes/64/3564/2
Chris Smith 10 years ago
parent
commit
5669e78c77
1 changed files with 17 additions and 8 deletions
  1. 17
    8
      test/com/dmdirc/addons/debug/DebugTest.java

+ 17
- 8
test/com/dmdirc/addons/debug/DebugTest.java View File

@@ -27,15 +27,24 @@ import com.dmdirc.commandparser.CommandArguments;
27 27
 import com.dmdirc.commandparser.commands.context.CommandContext;
28 28
 import com.dmdirc.interfaces.CommandController;
29 29
 
30
+import com.google.common.collect.Sets;
31
+
30 32
 import java.util.HashSet;
33
+
31 34
 import org.junit.Before;
32 35
 import org.junit.Test;
33 36
 import org.junit.runner.RunWith;
34 37
 import org.mockito.Mock;
35 38
 import org.mockito.runners.MockitoJUnitRunner;
36 39
 
37
-import static com.dmdirc.harness.CommandArgsMatcher.*;
38
-import static org.mockito.Mockito.*;
40
+import static com.dmdirc.harness.CommandArgsMatcher.eqLine;
41
+import static org.mockito.Matchers.anyObject;
42
+import static org.mockito.Matchers.anyString;
43
+import static org.mockito.Matchers.eq;
44
+import static org.mockito.Matchers.same;
45
+import static org.mockito.Mockito.never;
46
+import static org.mockito.Mockito.verify;
47
+import static org.mockito.Mockito.when;
39 48
 
40 49
 @RunWith(MockitoJUnitRunner.class)
41 50
 public class DebugTest {
@@ -68,18 +77,18 @@ public class DebugTest {
68 77
     /** Checks the debug command with an invalid subcommand shows an error. */
69 78
     @Test
70 79
     public void testInvalidArg() {
71
-        debug = new Debug(controller, new HashSet<DebugCommand>());
80
+        debug = new Debug(controller, Sets.<DebugCommand>newHashSet());
72 81
         when(arguments.isCommand()).thenReturn(true);
73 82
         when(arguments.getArguments()).thenReturn(new String[]{"test"});
74 83
 
75 84
         debug.execute(container, arguments, null);
76
-        verify(container).addLine(eq("commandError"), anyObject());
85
+        verify(container).addLine(eq("commandError"), anyString());
77 86
     }
78 87
 
79 88
     /** Checks the debug command executes a subcommand with no args. */
80 89
     @Test
81 90
     public void testCommandNoArgs() {
82
-        debug = new Debug(controller, new HashSet<DebugCommand>() {{ add(debugCommand); }});
91
+        debug = new Debug(controller, Sets.newHashSet(debugCommand));
83 92
         when(arguments.isCommand()).thenReturn(true);
84 93
         when(arguments.getArguments()).thenReturn(new String[]{"test"});
85 94
         when(arguments.getArgumentsAsString(1)).thenReturn("");
@@ -87,14 +96,14 @@ public class DebugTest {
87 96
 
88 97
         debug.execute(container, arguments, commandContext);
89 98
 
90
-        verify(container, never()).addLine(anyString(), anyObject());
99
+        verify(container, never()).addLine(anyString(), anyString());
91 100
         verify(debugCommand).execute(same(container), eqLine("/test"), same(commandContext));
92 101
     }
93 102
 
94 103
     /** Checks the debug command executes a subcommand with args. */
95 104
     @Test
96 105
     public void testCommandWithArgs() {
97
-        debug = new Debug(controller, new HashSet<DebugCommand>() {{ add(debugCommand); }});
106
+        debug = new Debug(controller, Sets.newHashSet(debugCommand));
98 107
         when(arguments.isCommand()).thenReturn(true);
99 108
         when(arguments.getArguments()).thenReturn(new String[]{"test", "1", "2", "3"});
100 109
         when(arguments.getArgumentsAsString(1)).thenReturn("1 2 3");
@@ -102,7 +111,7 @@ public class DebugTest {
102 111
 
103 112
         debug.execute(container, arguments, commandContext);
104 113
 
105
-        verify(container, never()).addLine(anyString(), anyObject());
114
+        verify(container, never()).addLine(anyString(), anyString());
106 115
         verify(debugCommand).execute(same(container), eqLine("/test 1 2 3"), same(commandContext));
107 116
     }
108 117
 

Loading…
Cancel
Save