소스 검색

Fix tests after mockito upgrade.

Mockito now errors if a mock is unnecessary, plus a few other minor
API changes.
pull/714/head
Chris Smith 7 년 전
부모
커밋
232ee993d4
21개의 변경된 파일33개의 추가작업 그리고 147개의 파일을 삭제
  1. 0
    5
      src/test/java/com/dmdirc/ServerManagerTest.java
  2. 0
    3
      src/test/java/com/dmdirc/commandparser/aliases/AliasCommandHandlerTest.java
  3. 0
    8
      src/test/java/com/dmdirc/commandparser/commands/channel/KickReasonTest.java
  4. 0
    2
      src/test/java/com/dmdirc/commandparser/commands/channel/NamesTest.java
  5. 0
    1
      src/test/java/com/dmdirc/commandparser/commands/chat/MeTest.java
  6. 5
    7
      src/test/java/com/dmdirc/commandparser/commands/global/NewServerTest.java
  7. 0
    1
      src/test/java/com/dmdirc/commandparser/parsers/CommandParserTest.java
  8. 0
    6
      src/test/java/com/dmdirc/config/ConfigValueRetrieverTest.java
  9. 0
    16
      src/test/java/com/dmdirc/config/prefs/PreferencesDialogModelTest.java
  10. 0
    1
      src/test/java/com/dmdirc/config/profiles/IdentitiesProfileMigratorTest.java
  11. 0
    54
      src/test/java/com/dmdirc/harness/CommandArgsMatcher.java
  12. 0
    1
      src/test/java/com/dmdirc/logger/DiskLoggingErrorManagerTest.java
  13. 3
    4
      src/test/java/com/dmdirc/logger/SentryLoggingErrorManagerTest.java
  14. 0
    2
      src/test/java/com/dmdirc/ui/WindowManagerTest.java
  15. 0
    1
      src/test/java/com/dmdirc/ui/core/aliases/CoreAliasDialogModelTest.java
  16. 0
    2
      src/test/java/com/dmdirc/ui/core/aliases/RenameAliasValidatorTest.java
  17. 24
    27
      src/test/java/com/dmdirc/ui/core/feedback/CoreFeedbackDialogModelTest.java
  18. 1
    3
      src/test/java/com/dmdirc/ui/core/profiles/AddNicknameValidatorTest.java
  19. 0
    1
      src/test/java/com/dmdirc/ui/core/profiles/EditSelectedProfileNameValidatorTest.java
  20. 0
    1
      src/test/java/com/dmdirc/ui/core/profiles/NewProfileNameValidatorTest.java
  21. 0
    1
      src/test/java/com/dmdirc/updater/manager/UpdateManagerImplTest.java

+ 0
- 5
src/test/java/com/dmdirc/ServerManagerTest.java 파일 보기

@@ -61,7 +61,6 @@ public class ServerManagerTest {
61 61
     @Mock private IdentityFactory identityFactory;
62 62
     @Mock private ConfigProviderMigrator configProviderMigrator;
63 63
     @Mock private Profile profile;
64
-    @Mock private AggregateConfigProvider configProvider;
65 64
     @Mock private WindowManager windowManager;
66 65
     @Mock private ServerFactoryImpl serverFactoryImpl;
67 66
     @Mock private Server server;
@@ -79,14 +78,11 @@ public class ServerManagerTest {
79 78
         serverManager = new ServerManager(profileManager, identityFactory, windowManager, serverFactoryImpl, eventBus);
80 79
 
81 80
         when(server.getState()).thenReturn(ServerState.DISCONNECTED);
82
-        when(server.getGroupChatManager()).thenReturn(groupChatManager);
83 81
         when(server.getWindowModel()).thenReturn(windowModel);
84 82
 
85
-        when(profileManager.getProfiles()).thenReturn(Collections.singletonList(profile));
86 83
         when(profileManager.getDefault()).thenReturn(profile);
87 84
         when(identityFactory.createMigratableConfig(anyString(), anyString(), anyString(),
88 85
                 anyString())).thenReturn(configProviderMigrator);
89
-        when(configProviderMigrator.getConfigProvider()).thenReturn(configProvider);
90 86
 
91 87
         when(serverFactoryImpl.getServer(eq(configProviderMigrator),
92 88
                 any(ScheduledExecutorService.class), uriCaptor.capture(), eq(profile)))
@@ -194,7 +190,6 @@ public class ServerManagerTest {
194 190
 
195 191
         final Server serverB = mock(Server.class);
196 192
         when(serverB.isNetwork("Quakenet")).thenReturn(false);
197
-        when(serverB.getState()).thenReturn(ServerState.CONNECTED);
198 193
 
199 194
         serverManager.registerServer(serverA);
200 195
         serverManager.registerServer(serverB);

+ 0
- 3
src/test/java/com/dmdirc/commandparser/aliases/AliasCommandHandlerTest.java 파일 보기

@@ -55,7 +55,6 @@ public class AliasCommandHandlerTest {
55 55
     @Mock private CommandController commandController;
56 56
     @Mock private CommandParser commandParser;
57 57
     @Mock private CommandContext context;
58
-    @Mock private CommandInfo commandInfo;
59 58
     @Mock private EventBus eventbus;
60 59
     @Captor private ArgumentCaptor<CommandErrorEvent> errorEventCaptor;
61 60
 
@@ -65,8 +64,6 @@ public class AliasCommandHandlerTest {
65 64
         when(inputModel.getCommandParser()).thenReturn(commandParser);
66 65
         when(commandController.getCommandChar()).thenReturn('#');
67 66
         when(commandController.getSilenceChar()).thenReturn('/');
68
-        when(context.getSource()).thenReturn(container);
69
-        when(context.getCommandInfo()).thenReturn(commandInfo);
70 67
         when(container.getEventBus()).thenReturn(eventbus);
71 68
     }
72 69
 

+ 0
- 8
src/test/java/com/dmdirc/commandparser/commands/channel/KickReasonTest.java 파일 보기

@@ -32,8 +32,6 @@ import com.dmdirc.interfaces.EventBus;
32 32
 import com.dmdirc.interfaces.GroupChatUser;
33 33
 import com.dmdirc.interfaces.User;
34 34
 import com.dmdirc.interfaces.WindowModel;
35
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
36
-import com.dmdirc.parser.interfaces.ChannelInfo;
37 35
 
38 36
 import java.util.Optional;
39 37
 
@@ -61,20 +59,14 @@ public class KickReasonTest {
61 59
     @Mock private CommandController controller;
62 60
     @Mock private WindowModel container;
63 61
     @Mock private EventBus eventbus;
64
-    @Mock private ChannelInfo channelInfo;
65
-    @Mock private AggregateConfigProvider configProvider;
66 62
     @Captor private ArgumentCaptor<CommandErrorEvent> errorEventCaptor;
67 63
     private KickReason command;
68 64
 
69 65
     @Before
70 66
     public void setup() {
71
-        when(container.getConfigManager()).thenReturn(configProvider);
72
-        when(configProvider.getOption("general", "kickmessage")).thenReturn("KICKREASON");
73
-        when(channel.getChannelInfo()).thenReturn(channelInfo);
74 67
         when(channel.getConnection()).thenReturn(Optional.of(connection));
75 68
         when(connection.getUser("user")).thenReturn(user1);
76 69
         when(connection.getUser("user1")).thenReturn(user2);
77
-        when(groupChatUser.getHostname()).thenReturn(Optional.of("HOSTNAME"));
78 70
         when(channel.getUser(user1)).thenReturn(Optional.of(groupChatUser));
79 71
         when(channel.getUser(user2)).thenReturn(Optional.empty());
80 72
         when(controller.getCommandChar()).thenReturn('/');

+ 0
- 2
src/test/java/com/dmdirc/commandparser/commands/channel/NamesTest.java 파일 보기

@@ -46,7 +46,6 @@ import static org.mockito.Mockito.when;
46 46
 public class NamesTest {
47 47
 
48 48
     @Mock private CommandController controller;
49
-    @Mock private ChannelInfo channelinfo;
50 49
     @Mock private Channel channel;
51 50
     @Mock private Connection connection;
52 51
     @Mock private Parser parser;
@@ -57,7 +56,6 @@ public class NamesTest {
57 56
     public void setUp() throws InvalidIdentityFileException {
58 57
         when(channel.getConnection()).thenReturn(Optional.of(connection));
59 58
         when(connection.getParser()).thenReturn(Optional.of(parser));
60
-        when(channel.getChannelInfo()).thenReturn(channelinfo);
61 59
         when(channel.getName()).thenReturn("#chan");
62 60
 
63 61
         command = new Names(controller);

+ 0
- 1
src/test/java/com/dmdirc/commandparser/commands/chat/MeTest.java 파일 보기

@@ -50,7 +50,6 @@ public class MeTest {
50 50
 
51 51
     @Before
52 52
     public void setUp() {
53
-        when(chat.getWindowModel()).thenReturn(frameContainer);
54 53
         when(frameContainer.getEventBus()).thenReturn(eventbus);
55 54
         command = new Me(controller);
56 55
     }

+ 5
- 7
src/test/java/com/dmdirc/commandparser/commands/global/NewServerTest.java 파일 보기

@@ -44,6 +44,7 @@ import org.junit.runner.RunWith;
44 44
 import org.mockito.Mock;
45 45
 import org.mockito.runners.MockitoJUnitRunner;
46 46
 
47
+import static org.mockito.ArgumentMatchers.isNull;
47 48
 import static org.mockito.Matchers.any;
48 49
 import static org.mockito.Matchers.eq;
49 50
 import static org.mockito.Matchers.isA;
@@ -56,7 +57,6 @@ public class NewServerTest {
56 57
     @Mock private EventBus eventBus;
57 58
     @Mock private CommandController controller;
58 59
     @Mock private ProfileManager profileManager;
59
-    @Mock private Profile identity;
60 60
     @Mock private WindowModel container;
61 61
     @Mock private ServiceManager serviceManager;
62 62
     @Mock private ConnectionFactory factory;
@@ -66,9 +66,7 @@ public class NewServerTest {
66 66
     @Before
67 67
     public void setup() {
68 68
         when(container.getEventBus()).thenReturn(eventBus);
69
-        when(factory.createServer(any(URI.class), any(Profile.class))).thenReturn(connection);
70
-        when(profileManager.getProfiles()).thenReturn(
71
-                Collections.singletonList(identity));
69
+        when(factory.createServer(any(URI.class), isNull())).thenReturn(connection);
72 70
         command = new NewServer(controller, factory, serviceManager, profileManager, new URIParser());
73 71
     }
74 72
 
@@ -77,7 +75,7 @@ public class NewServerTest {
77 75
         command.execute(container, new CommandArguments(controller, "/foo irc.foo.com"),
78 76
                 new CommandContext(null, NewServer.INFO));
79 77
 
80
-        verify(factory).createServer(eq(new URI("irc://irc.foo.com")), any(Profile.class));
78
+        verify(factory).createServer(eq(new URI("irc://irc.foo.com")), isNull());
81 79
         verify(connection).connect();
82 80
     }
83 81
 
@@ -86,7 +84,7 @@ public class NewServerTest {
86 84
         command.execute(container, new CommandArguments(controller, "/foo irc.foo.com:1234"),
87 85
                 new CommandContext(null, NewServer.INFO));
88 86
 
89
-        verify(factory).createServer(eq(new URI("irc://irc.foo.com:1234")), any(Profile.class));
87
+        verify(factory).createServer(eq(new URI("irc://irc.foo.com:1234")), isNull());
90 88
         verify(connection).connect();
91 89
     }
92 90
 
@@ -95,7 +93,7 @@ public class NewServerTest {
95 93
         command.execute(container, new CommandArguments(controller, "/foo otheruri://foo.com:123/blah"),
96 94
                 new CommandContext(null, NewServer.INFO));
97 95
 
98
-        verify(factory).createServer(eq(new URI("otheruri://foo.com:123/blah")), any(Profile.class));
96
+        verify(factory).createServer(eq(new URI("otheruri://foo.com:123/blah")), isNull());
99 97
         verify(connection).connect();
100 98
     }
101 99
 

+ 0
- 1
src/test/java/com/dmdirc/commandparser/parsers/CommandParserTest.java 파일 보기

@@ -81,7 +81,6 @@ public class CommandParserTest {
81 81
         when(container.getConnection()).thenReturn(Optional.of(connection));
82 82
         when(connection.getGroupChatManager()).thenReturn(groupChatManager);
83 83
         when(groupChatManager.isValidChannelName("#channel1")).thenReturn(true);
84
-        when(groupChatManager.isValidChannelName("#channel2")).thenReturn(true);
85 84
         when(groupChatManager.getChannel("#channel1")).thenReturn(Optional.of(channel));
86 85
 
87 86
         commandParser = new TestCommandParser(configProvider, commandController, eventBus);

+ 0
- 6
src/test/java/com/dmdirc/config/ConfigValueRetrieverTest.java 파일 보기

@@ -65,8 +65,6 @@ public class ConfigValueRetrieverTest {
65 65
 
66 66
     @Test
67 67
     public void testRetrievesStringWithFallback() {
68
-        when(configProvider.getOptionString(DOMAIN, KEY, true,
69
-                ReadOnlyConfigProvider.PERMISSIVE_VALIDATOR)).thenReturn(null);
70 68
         when(configProvider.getOptionString(
71 69
                 DOMAIN, KEY, true, ReadOnlyConfigProvider.PERMISSIVE_VALIDATOR,
72 70
                 FALLBACK_DOMAIN, FALLBACK_KEY))
@@ -80,16 +78,12 @@ public class ConfigValueRetrieverTest {
80 78
     public void testRetrievesStringWithRequiresFalse() {
81 79
         when(configProvider.getOptionString(DOMAIN, KEY, false,
82 80
                 ReadOnlyConfigProvider.PERMISSIVE_VALIDATOR)).thenReturn(null);
83
-        when(configProvider.getOptionString(DOMAIN, KEY, true,
84
-                ReadOnlyConfigProvider.PERMISSIVE_VALIDATOR)).thenReturn("value!");
85 81
 
86 82
         assertNull(retriever.getValue(String.class, DOMAIN, KEY, false));
87 83
     }
88 84
 
89 85
     @Test
90 86
     public void testRetrievesStringWithRequiresTrue() {
91
-        when(configProvider.getOptionString(DOMAIN, KEY, false,
92
-                ReadOnlyConfigProvider.PERMISSIVE_VALIDATOR)).thenReturn(null);
93 87
         when(configProvider.getOptionString(DOMAIN, KEY, true,
94 88
                 ReadOnlyConfigProvider.PERMISSIVE_VALIDATOR)).thenReturn("value!");
95 89
 

+ 0
- 16
src/test/java/com/dmdirc/config/prefs/PreferencesDialogModelTest.java 파일 보기

@@ -66,7 +66,6 @@ public class PreferencesDialogModelTest {
66 66
     @Test
67 67
     public void testDefaults() {
68 68
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
69
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
70 69
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
71 70
                 null, null, cm, null, serviceManager, eventBus);
72 71
         assertNotNull(pm.getCategory("General"));
@@ -82,7 +81,6 @@ public class PreferencesDialogModelTest {
82 81
     @Test
83 82
     public void testDismiss() {
84 83
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
85
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
86 84
         final PreferencesCategory category = mock(PreferencesCategory.class);
87 85
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
88 86
                 null, null, cm, null, serviceManager, eventBus);
@@ -97,8 +95,6 @@ public class PreferencesDialogModelTest {
97 95
         final PreferencesCategory category = mock(PreferencesCategory.class);
98 96
         when(category.save()).thenReturn(false);
99 97
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
100
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
101
-
102 98
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
103 99
                 null, null, cm, null, serviceManager, eventBus);
104 100
         pm.addCategory(category);
@@ -112,8 +108,6 @@ public class PreferencesDialogModelTest {
112 108
         final PreferencesCategory category = mock(PreferencesCategory.class);
113 109
         when(category.save()).thenReturn(true);
114 110
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
115
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
116
-
117 111
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
118 112
                 null, null, cm, null, serviceManager, eventBus);
119 113
         pm.addCategory(category);
@@ -125,8 +119,6 @@ public class PreferencesDialogModelTest {
125 119
     @Test
126 120
     public void testGetCategory() {
127 121
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
128
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
129
-
130 122
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
131 123
                 null, null, cm, null, serviceManager, eventBus);
132 124
         assertNull(pm.getCategory("unittest123"));
@@ -135,8 +127,6 @@ public class PreferencesDialogModelTest {
135 127
     @Test
136 128
     public void testGetCategories() {
137 129
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
138
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
139
-
140 130
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
141 131
                 null, null, cm, null, serviceManager, eventBus);
142 132
         assertNotNull(pm.getCategories());
@@ -150,8 +140,6 @@ public class PreferencesDialogModelTest {
150 140
     @Test
151 141
     public void testSaveListener() {
152 142
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
153
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
154
-
155 143
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
156 144
                 null, null, cm, null, serviceManager, eventBus);
157 145
         final PreferencesInterface tpi = mock(PreferencesInterface.class);
@@ -164,7 +152,6 @@ public class PreferencesDialogModelTest {
164 152
     @Test
165 153
     public void testOpenAction() {
166 154
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
167
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
168 155
 
169 156
         new PreferencesDialogModel(null, null, null, null, cm, null, serviceManager, eventBus);
170 157
 
@@ -174,7 +161,6 @@ public class PreferencesDialogModelTest {
174 161
     @Test
175 162
     public void testCloseAction() {
176 163
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
177
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
178 164
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
179 165
                 null, null, cm, null, serviceManager, eventBus);
180 166
         pm.close();
@@ -185,8 +171,6 @@ public class PreferencesDialogModelTest {
185 171
     @Test
186 172
     public void testCategoryObjectSaveListeners() {
187 173
         final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
188
-        when(cm.getOption("domain", "option")).thenReturn("fallback");
189
-
190 174
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
191 175
                 null, null, cm, null, serviceManager, eventBus);
192 176
         final PreferencesCategory category = mock(PreferencesCategory.class);

+ 0
- 1
src/test/java/com/dmdirc/config/profiles/IdentitiesProfileMigratorTest.java 파일 보기

@@ -56,7 +56,6 @@ public class IdentitiesProfileMigratorTest {
56 56
         instance = new IdentitiesProfileMigrator(identityManager, profileManager);
57 57
         when(configProvider1.getName()).thenReturn("name1");
58 58
         when(configProvider1.getOption("profile", "realname")).thenReturn("realname1");
59
-        when(configProvider1.hasOptionString("profile", "ident1")).thenReturn(false);
60 59
         when(configProvider1.getOptionList("profile", "nicknames")).thenReturn(
61 60
                 Lists.newArrayList("nickname1")
62 61
         );

+ 0
- 54
src/test/java/com/dmdirc/harness/CommandArgsMatcher.java 파일 보기

@@ -1,54 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 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.harness;
24
-
25
-import com.dmdirc.commandparser.CommandArguments;
26
-
27
-import org.hamcrest.Description;
28
-import org.mockito.ArgumentMatcher;
29
-import org.mockito.Mockito;
30
-
31
-public class CommandArgsMatcher extends ArgumentMatcher<CommandArguments> {
32
-
33
-    private final String text;
34
-
35
-    public CommandArgsMatcher(final String text) {
36
-        this.text = text;
37
-    }
38
-
39
-    /** {@inheritDoc} */
40
-    @Override
41
-    public boolean matches(final Object item) {
42
-        return text.equals(((CommandArguments) item).getLine());
43
-    }
44
-
45
-    /** {@inheritDoc} */
46
-    @Override
47
-    public void describeTo(final Description description) {
48
-        description.appendText("eqLine(\"" + text + "\")");
49
-    }
50
-
51
-    public static CommandArguments eqLine(final String line) {
52
-        return Mockito.argThat(new CommandArgsMatcher(line));
53
-    }
54
-}

+ 0
- 1
src/test/java/com/dmdirc/logger/DiskLoggingErrorManagerTest.java 파일 보기

@@ -62,7 +62,6 @@ public class DiskLoggingErrorManagerTest {
62 62
     public void setUp() throws Exception {
63 63
         when(error.getTimestamp()).thenReturn(LocalDateTime.now());
64 64
         when(error.getError()).thenReturn(programError);
65
-        when(programError.getThrowable()).thenReturn(Optional.of(new IllegalArgumentException()));
66 65
         when(programError.getThrowableAsString()).thenReturn(Optional.of("test"));
67 66
         when(programError.getLevel()).thenReturn(ErrorLevel.MEDIUM);
68 67
         when(config.getBinder()).thenReturn(configBinder);

+ 3
- 4
src/test/java/com/dmdirc/logger/SentryLoggingErrorManagerTest.java 파일 보기

@@ -38,6 +38,7 @@ import org.junit.runner.RunWith;
38 38
 import org.mockito.Mock;
39 39
 import org.mockito.runners.MockitoJUnitRunner;
40 40
 
41
+import static org.mockito.ArgumentMatchers.isNull;
41 42
 import static org.mockito.Matchers.any;
42 43
 import static org.mockito.Matchers.anyString;
43 44
 import static org.mockito.Matchers.eq;
@@ -77,8 +78,7 @@ public class SentryLoggingErrorManagerTest {
77 78
     @Test
78 79
     public void testHandleErrorEvent() throws Exception {
79 80
         instance.handleErrorEvent(appErrorEvent);
80
-        verify(sentryErrorReporter).sendException(anyString(), any(ErrorLevel.class),
81
-                any(LocalDateTime.class), any());
81
+        verify(sentryErrorReporter).sendException(isNull(), isNull(), isNull(), any());
82 82
     }
83 83
 
84 84
     @Test
@@ -120,8 +120,7 @@ public class SentryLoggingErrorManagerTest {
120 120
         instance.handleSubmitErrors(true);
121 121
         instance.handleNoErrorReporting(false);
122 122
         instance.handleErrorEvent(appErrorEvent);
123
-        verify(sentryErrorReporter).sendException(anyString(), any(ErrorLevel.class),
124
-                any(LocalDateTime.class), any());
123
+        verify(sentryErrorReporter).sendException(isNull(), isNull(), isNull(), any());
125 124
     }
126 125
 
127 126
     @Test

+ 0
- 2
src/test/java/com/dmdirc/ui/WindowManagerTest.java 파일 보기

@@ -252,7 +252,6 @@ public class WindowManagerTest {
252 252
         final CustomWindow customContainer = mock(CustomWindow.class);
253 253
         final CustomWindow customChild = mock(CustomWindow.class);
254 254
 
255
-        when(customContainer.getName()).thenReturn("test");
256 255
         when(customChild.getName()).thenReturn("test1");
257 256
 
258 257
         manager.addWindow(customContainer);
@@ -266,7 +265,6 @@ public class WindowManagerTest {
266 265
         final CustomWindow customContainer = mock(CustomWindow.class);
267 266
         final CustomWindow customChild = mock(CustomWindow.class);
268 267
 
269
-        when(customContainer.getName()).thenReturn("test");
270 268
         when(customChild.getName()).thenReturn("test1");
271 269
 
272 270
         manager.addWindow(customContainer);

+ 0
- 1
src/test/java/com/dmdirc/ui/core/aliases/CoreAliasDialogModelTest.java 파일 보기

@@ -66,7 +66,6 @@ public class CoreAliasDialogModelTest {
66 66
     @Before
67 67
     public void setupAliases() {
68 68
         aliases = new HashSet<>();
69
-        when(commandController.getCommandChar()).thenReturn('/');
70 69
     }
71 70
 
72 71
     @Before

+ 0
- 2
src/test/java/com/dmdirc/ui/core/aliases/RenameAliasValidatorTest.java 파일 보기

@@ -56,7 +56,6 @@ public class RenameAliasValidatorTest {
56 56
     @Test
57 57
     public void testRenameSelected() {
58 58
         when(model.getSelectedAlias()).thenReturn(Optional.ofNullable(alias1));
59
-        when(model.getSelectedAliasName()).thenReturn("alias1");
60 59
         final RenameAliasValidator instance = new RenameAliasValidator(model);
61 60
         assertFalse(instance.validate("alias1").isFailure());
62 61
         assertTrue(instance.validate("alias2").isFailure());
@@ -67,7 +66,6 @@ public class RenameAliasValidatorTest {
67 66
     @Test
68 67
     public void testRenameNonSelected() {
69 68
         when(model.getSelectedAlias()).thenReturn(Optional.<Alias>empty());
70
-        when(model.getSelectedAliasName()).thenReturn(null);
71 69
         final RenameAliasValidator instance = new RenameAliasValidator(model);
72 70
         assertTrue(instance.validate("alias1").isFailure());
73 71
         assertTrue(instance.validate("alias2").isFailure());

+ 24
- 27
src/test/java/com/dmdirc/ui/core/feedback/CoreFeedbackDialogModelTest.java 파일 보기

@@ -47,7 +47,6 @@ public class CoreFeedbackDialogModelTest {
47 47
     private static final String FEEDBACK = "DMDirc Rocks.";
48 48
 
49 49
     @Mock private FeedbackSenderFactory feedbackSenderFactory;
50
-    @Mock private FeedbackSender feedbackSender;
51 50
     @Mock private FeedbackDialogModelListener listener;
52 51
     @Mock private FeedbackHelper feedbackHelper;
53 52
 
@@ -56,29 +55,27 @@ public class CoreFeedbackDialogModelTest {
56 55
     @Before
57 56
     public void setup() {
58 57
         instance = new CoreFeedbackDialogModel(feedbackSenderFactory, feedbackHelper);
59
-        when(feedbackSenderFactory.getFeedbackSender(anyString(), anyString(), anyString(),
60
-                anyString(), anyString(), anyString())).thenReturn(feedbackSender);
61 58
     }
62 59
 
63 60
     @Test
64 61
     public void testName() {
65 62
         assertEquals("testName", Optional.<String>empty(), instance.getName());
66
-        instance.setName(Optional.ofNullable(NAME));
67
-        assertEquals("testName", Optional.ofNullable(NAME), instance.getName());
63
+        instance.setName(Optional.of(NAME));
64
+        assertEquals("testName", Optional.of(NAME), instance.getName());
68 65
     }
69 66
 
70 67
     @Test
71 68
     public void testEmail() {
72 69
         assertEquals("testEmail", Optional.<String>empty(), instance.getEmail());
73
-        instance.setEmail(Optional.ofNullable(EMAIL));
74
-        assertEquals("testEmail", Optional.ofNullable(EMAIL), instance.getEmail());
70
+        instance.setEmail(Optional.of(EMAIL));
71
+        assertEquals("testEmail", Optional.of(EMAIL), instance.getEmail());
75 72
     }
76 73
 
77 74
     @Test
78 75
     public void testFeedback() {
79 76
         assertEquals("testFeedback", Optional.<String>empty(), instance.getFeedback());
80
-        instance.setFeedback(Optional.ofNullable(FEEDBACK));
81
-        assertEquals("testFeedback", Optional.ofNullable(FEEDBACK), instance.getFeedback());
77
+        instance.setFeedback(Optional.of(FEEDBACK));
78
+        assertEquals("testFeedback", Optional.of(FEEDBACK), instance.getFeedback());
82 79
     }
83 80
 
84 81
     @Test
@@ -99,9 +96,9 @@ public class CoreFeedbackDialogModelTest {
99 96
     public void testSaveWithoutServerWithoutDMDirc() {
100 97
         instance.setIncludeDMDircInfo(false);
101 98
         instance.setIncludeServerInfo(false);
102
-        instance.setName(Optional.ofNullable(NAME));
103
-        instance.setEmail(Optional.ofNullable(EMAIL));
104
-        instance.setFeedback(Optional.ofNullable(FEEDBACK));
99
+        instance.setName(Optional.of(NAME));
100
+        instance.setEmail(Optional.of(EMAIL));
101
+        instance.setFeedback(Optional.of(FEEDBACK));
105 102
         instance.save();
106 103
         verify(feedbackSenderFactory).getFeedbackSender(NAME, EMAIL, FEEDBACK,
107 104
                 feedbackHelper.getVersion(), "", "");
@@ -111,9 +108,9 @@ public class CoreFeedbackDialogModelTest {
111 108
     public void testSaveWithoutServerWithDMDirc() {
112 109
         instance.setIncludeDMDircInfo(true);
113 110
         instance.setIncludeServerInfo(false);
114
-        instance.setName(Optional.ofNullable(NAME));
115
-        instance.setEmail(Optional.ofNullable(EMAIL));
116
-        instance.setFeedback(Optional.ofNullable(FEEDBACK));
111
+        instance.setName(Optional.of(NAME));
112
+        instance.setEmail(Optional.of(EMAIL));
113
+        instance.setFeedback(Optional.of(FEEDBACK));
117 114
         instance.save();
118 115
         verify(feedbackSenderFactory).getFeedbackSender(NAME, EMAIL, FEEDBACK,
119 116
                 feedbackHelper.getVersion(), "", feedbackHelper.getDMDircInfo());
@@ -123,9 +120,9 @@ public class CoreFeedbackDialogModelTest {
123 120
     public void testSaveWithoutDMDircWithServer() {
124 121
         instance.setIncludeDMDircInfo(false);
125 122
         instance.setIncludeServerInfo(true);
126
-        instance.setName(Optional.ofNullable(NAME));
127
-        instance.setEmail(Optional.ofNullable(EMAIL));
128
-        instance.setFeedback(Optional.ofNullable(FEEDBACK));
123
+        instance.setName(Optional.of(NAME));
124
+        instance.setEmail(Optional.of(EMAIL));
125
+        instance.setFeedback(Optional.of(FEEDBACK));
129 126
         instance.save();
130 127
         verify(feedbackSenderFactory).getFeedbackSender(NAME, EMAIL, FEEDBACK,
131 128
                 feedbackHelper.getVersion(), feedbackHelper.getServerInfo(), "");
@@ -135,9 +132,9 @@ public class CoreFeedbackDialogModelTest {
135 132
     public void testSaveWithServerWithDMDirc() {
136 133
         instance.setIncludeDMDircInfo(true);
137 134
         instance.setIncludeServerInfo(true);
138
-        instance.setName(Optional.ofNullable(NAME));
139
-        instance.setEmail(Optional.ofNullable(EMAIL));
140
-        instance.setFeedback(Optional.ofNullable(FEEDBACK));
135
+        instance.setName(Optional.of(NAME));
136
+        instance.setEmail(Optional.of(EMAIL));
137
+        instance.setFeedback(Optional.of(FEEDBACK));
141 138
         instance.save();
142 139
         verify(feedbackSenderFactory).getFeedbackSender(NAME, EMAIL, FEEDBACK,
143 140
                 feedbackHelper.getVersion(), feedbackHelper.getServerInfo(),
@@ -147,22 +144,22 @@ public class CoreFeedbackDialogModelTest {
147 144
     @Test
148 145
     public void testNameListener() {
149 146
         instance.addListener(listener);
150
-        instance.setName(Optional.ofNullable(NAME));
151
-        verify(listener).nameChanged(Optional.ofNullable(NAME));
147
+        instance.setName(Optional.of(NAME));
148
+        verify(listener).nameChanged(Optional.of(NAME));
152 149
     }
153 150
 
154 151
     @Test
155 152
     public void testEmailListener() {
156 153
         instance.addListener(listener);
157
-        instance.setEmail(Optional.ofNullable(EMAIL));
158
-        verify(listener).emailChanged(Optional.ofNullable(EMAIL));
154
+        instance.setEmail(Optional.of(EMAIL));
155
+        verify(listener).emailChanged(Optional.of(EMAIL));
159 156
     }
160 157
 
161 158
     @Test
162 159
     public void testFeedbackListener() {
163 160
         instance.addListener(listener);
164
-        instance.setFeedback(Optional.ofNullable(FEEDBACK));
165
-        verify(listener).feedbackChanged(Optional.ofNullable(FEEDBACK));
161
+        instance.setFeedback(Optional.of(FEEDBACK));
162
+        verify(listener).feedbackChanged(Optional.of(FEEDBACK));
166 163
     }
167 164
 
168 165
     @Test

+ 1
- 3
src/test/java/com/dmdirc/ui/core/profiles/AddNicknameValidatorTest.java 파일 보기

@@ -52,9 +52,7 @@ public class AddNicknameValidatorTest {
52 52
         when(model.getSelectedProfile())
53 53
                 .thenReturn(Optional.ofNullable(profile));
54 54
         when(model.getSelectedProfileNicknames())
55
-                .thenReturn(Optional.ofNullable(nicknames));
56
-        when(model.getSelectedProfileSelectedNickname())
57
-                .thenReturn(Optional.ofNullable("nickname2"));
55
+                .thenReturn(Optional.of(nicknames));
58 56
     }
59 57
 
60 58
     @Test

+ 0
- 1
src/test/java/com/dmdirc/ui/core/profiles/EditSelectedProfileNameValidatorTest.java 파일 보기

@@ -52,7 +52,6 @@ public class EditSelectedProfileNameValidatorTest {
52 52
     public void setupModel() {
53 53
         final List<MutableProfile> profiles = Lists.newArrayList(profile1, profile2, profile3);
54 54
         when(profile1.getName()).thenReturn("profile1");
55
-        when(profile2.getName()).thenReturn("profile2");
56 55
         when(profile3.getName()).thenReturn("profile3");
57 56
         when(model.getProfileList()).thenReturn(profiles);
58 57
         when(model.getSelectedProfile()).thenReturn(Optional.ofNullable(profile2));

+ 0
- 1
src/test/java/com/dmdirc/ui/core/profiles/NewProfileNameValidatorTest.java 파일 보기

@@ -55,7 +55,6 @@ public class NewProfileNameValidatorTest {
55 55
         when(profile2.getName()).thenReturn("profile2");
56 56
         when(profile3.getName()).thenReturn("profile3");
57 57
         when(model.getProfileList()).thenReturn(profiles);
58
-        when(model.getSelectedProfile()).thenReturn(Optional.ofNullable(profile2));
59 58
     }
60 59
 
61 60
     @Test

+ 0
- 1
src/test/java/com/dmdirc/updater/manager/UpdateManagerImplTest.java 파일 보기

@@ -111,7 +111,6 @@ public class UpdateManagerImplTest {
111 111
     @Test
112 112
     public void testGetNoRetrievalStrategy() {
113 113
         // Given a retrieval strategies that can handle a specific check result
114
-        when(strategy1.canHandle(checkResult1)).thenReturn(true);
115 114
         manager.addRetrievalStrategy(strategy1);
116 115
 
117 116
         // Then null is returned for other check results

Loading…
취소
저장