Procházet zdrojové kódy

Unit test fiddling

Remove unreachable/unused test code

Change-Id: I2bfd2d7d3f37065f218afa09a67c38e4e91e7a10
Reviewed-on: http://gerrit.dmdirc.com/468
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Tested-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3b1
Chris Smith před 14 roky
rodič
revize
b3009f3843

+ 6
- 122
test/com/dmdirc/commandparser/CommandTypeTest.java Zobrazit soubor

21
  */
21
  */
22
 package com.dmdirc.commandparser;
22
 package com.dmdirc.commandparser;
23
 
23
 
24
-import com.dmdirc.Channel;
25
-import com.dmdirc.MessageTarget;
26
-import com.dmdirc.Query;
27
-import com.dmdirc.Server;
28
 import com.dmdirc.commandparser.commands.ChannelCommand;
24
 import com.dmdirc.commandparser.commands.ChannelCommand;
29
 import com.dmdirc.commandparser.commands.ChatCommand;
25
 import com.dmdirc.commandparser.commands.ChatCommand;
30
 import com.dmdirc.commandparser.commands.Command;
26
 import com.dmdirc.commandparser.commands.Command;
31
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.commandparser.commands.GlobalCommand;
32
 import com.dmdirc.commandparser.commands.QueryCommand;
28
 import com.dmdirc.commandparser.commands.QueryCommand;
33
 import com.dmdirc.commandparser.commands.ServerCommand;
29
 import com.dmdirc.commandparser.commands.ServerCommand;
34
-import com.dmdirc.ui.interfaces.InputWindow;
35
 import org.junit.Test;
30
 import org.junit.Test;
36
 import static org.junit.Assert.*;
31
 import static org.junit.Assert.*;
32
+import static org.mockito.Mockito.*;
37
 
33
 
38
 public class CommandTypeTest {
34
 public class CommandTypeTest {
39
 
35
 
40
     @Test
36
     @Test
41
     public void testGlobal() {
37
     public void testGlobal() {
42
-        final Command command = new GlobalCommand() {
43
-
44
-            @Override
45
-            public void execute(InputWindow origin, boolean isSilent, CommandArguments args) {
46
-                throw new UnsupportedOperationException("Not supported yet.");
47
-            }
48
-
49
-            @Override
50
-            public String getName() {
51
-                throw new UnsupportedOperationException("Not supported yet.");
52
-            }
53
-
54
-            @Override
55
-            public boolean showInHelp() {
56
-                throw new UnsupportedOperationException("Not supported yet.");
57
-            }
58
-
59
-            @Override
60
-            public String getHelp() {
61
-                throw new UnsupportedOperationException("Not supported yet.");
62
-            }
63
-        };
64
-        
38
+        final Command command = mock(GlobalCommand.class);
65
         assertEquals(CommandType.TYPE_GLOBAL, CommandType.fromCommand(command));
39
         assertEquals(CommandType.TYPE_GLOBAL, CommandType.fromCommand(command));
66
     }
40
     }
67
     
41
     
68
     @Test
42
     @Test
69
     public void testServer() {
43
     public void testServer() {
70
-        final Command command = new ServerCommand() {
71
-
72
-            @Override
73
-            public void execute(InputWindow origin, Server server, boolean isSilent, CommandArguments args) {
74
-                throw new UnsupportedOperationException("Not supported yet.");
75
-            }
76
-
77
-            @Override
78
-            public String getName() {
79
-                throw new UnsupportedOperationException("Not supported yet.");
80
-            }
81
-
82
-            @Override
83
-            public boolean showInHelp() {
84
-                throw new UnsupportedOperationException("Not supported yet.");
85
-            }
86
-
87
-            @Override
88
-            public String getHelp() {
89
-                throw new UnsupportedOperationException("Not supported yet.");
90
-            }
91
-        };
92
-        
44
+        final Command command = mock(ServerCommand.class);
93
         assertEquals(CommandType.TYPE_SERVER, CommandType.fromCommand(command));
45
         assertEquals(CommandType.TYPE_SERVER, CommandType.fromCommand(command));
94
     }
46
     }
95
     
47
     
96
     @Test
48
     @Test
97
     public void testChat() {
49
     public void testChat() {
98
-        final Command command = new ChatCommand() {
99
-
100
-            @Override
101
-            public String getName() {
102
-                throw new UnsupportedOperationException("Not supported yet.");
103
-            }
104
-
105
-            @Override
106
-            public boolean showInHelp() {
107
-                throw new UnsupportedOperationException("Not supported yet.");
108
-            }
109
-
110
-            @Override
111
-            public String getHelp() {
112
-                throw new UnsupportedOperationException("Not supported yet.");
113
-            }
114
-
115
-            @Override
116
-            public void execute(InputWindow origin, Server server,
117
-                    MessageTarget target, boolean isSilent, CommandArguments args) {
118
-                throw new UnsupportedOperationException("Not supported yet.");
119
-            }
120
-        };
121
-        
50
+        final Command command = mock(ChatCommand.class);
122
         assertEquals(CommandType.TYPE_CHAT, CommandType.fromCommand(command));
51
         assertEquals(CommandType.TYPE_CHAT, CommandType.fromCommand(command));
123
     }    
52
     }    
124
     
53
     
125
     @Test
54
     @Test
126
     public void testChannel() {
55
     public void testChannel() {
127
-        final Command command = new ChannelCommand() {
128
-            @Override
129
-            public String getName() {
130
-                throw new UnsupportedOperationException("Not supported yet.");
131
-            }
132
-
133
-            @Override
134
-            public boolean showInHelp() {
135
-                throw new UnsupportedOperationException("Not supported yet.");
136
-            }
137
-
138
-            @Override
139
-            public String getHelp() {
140
-                throw new UnsupportedOperationException("Not supported yet.");
141
-            }
142
-
143
-            @Override
144
-            public void execute(InputWindow origin, Server server,
145
-                    Channel channel, boolean isSilent, CommandArguments args) {
146
-                throw new UnsupportedOperationException("Not supported yet.");
147
-            }
148
-        };
149
-        
56
+        final Command command = mock(ChannelCommand.class);
150
         assertEquals(CommandType.TYPE_CHANNEL, CommandType.fromCommand(command));
57
         assertEquals(CommandType.TYPE_CHANNEL, CommandType.fromCommand(command));
151
     }
58
     }
152
     
59
     
153
     @Test
60
     @Test
154
     public void testQuery() {
61
     public void testQuery() {
155
-        final Command command = new QueryCommand() {
156
-
157
-            @Override
158
-            public String getName() {
159
-                throw new UnsupportedOperationException("Not supported yet.");
160
-            }
161
-
162
-            @Override
163
-            public boolean showInHelp() {
164
-                throw new UnsupportedOperationException("Not supported yet.");
165
-            }
166
-
167
-            @Override
168
-            public String getHelp() {
169
-                throw new UnsupportedOperationException("Not supported yet.");
170
-            }
171
-
172
-            @Override
173
-            public void execute(InputWindow origin, Server server, Query query,
174
-                    boolean isSilent, CommandArguments args) {
175
-                throw new UnsupportedOperationException("Not supported yet.");
176
-            }
177
-        };
178
-        
62
+        final Command command = mock(QueryCommand.class);
179
         assertEquals(CommandType.TYPE_QUERY, CommandType.fromCommand(command));
63
         assertEquals(CommandType.TYPE_QUERY, CommandType.fromCommand(command));
180
     }
64
     }
181
     
65
     

+ 4
- 9
test/com/dmdirc/ui/messages/FormatterTest.java Zobrazit soubor

51
     
51
     
52
     @Test
52
     @Test
53
     public void testCaching() {
53
     public void testCaching() {
54
-        try {
55
-            assertEquals("H", Formatter.formatMessage(mcm, "1%1$C", "Hello!"));
56
-            assertEquals("H", Formatter.formatMessage(mcm, "1%1$C", "Hello!", 123, null));
57
-            assertEquals("HELLO!", Formatter.formatMessage(mcm, "1%1$S", "Hello!", 123, null));
58
-            assertEquals("HELLO!", Formatter.formatMessage(mcm, "1%1$S", "Hello!"));
59
-        } catch (Exception ex) {
60
-            ex.printStackTrace();
61
-            assertTrue(false);
62
-        }
54
+        assertEquals("H", Formatter.formatMessage(mcm, "1%1$C", "Hello!"));
55
+        assertEquals("H", Formatter.formatMessage(mcm, "1%1$C", "Hello!", 123, null));
56
+        assertEquals("HELLO!", Formatter.formatMessage(mcm, "1%1$S", "Hello!", 123, null));
57
+        assertEquals("HELLO!", Formatter.formatMessage(mcm, "1%1$S", "Hello!"));
63
     }
58
     }
64
     
59
     
65
     @Test
60
     @Test

Načítá se…
Zrušit
Uložit