Bläddra i källkod

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 år sedan
förälder
incheckning
5669e78c77
1 ändrade filer med 17 tillägg och 8 borttagningar
  1. 17
    8
      test/com/dmdirc/addons/debug/DebugTest.java

+ 17
- 8
test/com/dmdirc/addons/debug/DebugTest.java Visa fil

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

Laddar…
Avbryt
Spara