Browse Source

Rename getOptionalConnection() to getConnection().

pull/212/head
Chris Smith 9 years ago
parent
commit
f830257585
38 changed files with 48 additions and 51 deletions
  1. 1
    1
      src/com/dmdirc/Channel.java
  2. 1
    1
      src/com/dmdirc/ChannelEventHandler.java
  3. 2
    2
      src/com/dmdirc/CustomWindow.java
  4. 1
    1
      src/com/dmdirc/FrameContainer.java
  5. 1
    1
      src/com/dmdirc/GlobalWindow.java
  6. 1
    1
      src/com/dmdirc/Query.java
  7. 1
    1
      src/com/dmdirc/Raw.java
  8. 1
    1
      src/com/dmdirc/Server.java
  9. 2
    2
      src/com/dmdirc/actions/ActionSubstitutor.java
  10. 1
    1
      src/com/dmdirc/actions/CoreActionComponent.java
  11. 1
    1
      src/com/dmdirc/commandparser/commands/channel/Mode.java
  12. 1
    1
      src/com/dmdirc/commandparser/commands/channel/Names.java
  13. 1
    1
      src/com/dmdirc/commandparser/commands/channel/ShowTopic.java
  14. 1
    1
      src/com/dmdirc/commandparser/commands/chat/Me.java
  15. 1
    1
      src/com/dmdirc/commandparser/commands/context/ChatCommandContext.java
  16. 1
    2
      src/com/dmdirc/commandparser/commands/global/Echo.java
  17. 1
    1
      src/com/dmdirc/commandparser/commands/global/OpenWindow.java
  18. 1
    1
      src/com/dmdirc/commandparser/commands/global/SetCommand.java
  19. 1
    1
      src/com/dmdirc/commandparser/commands/server/Ignore.java
  20. 1
    1
      src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java
  21. 1
    1
      src/com/dmdirc/commandparser/commands/server/Message.java
  22. 1
    1
      src/com/dmdirc/commandparser/commands/server/OpenQuery.java
  23. 1
    1
      src/com/dmdirc/commandparser/parsers/CommandParser.java
  24. 1
    1
      src/com/dmdirc/interfaces/Chat.java
  25. 1
    1
      src/com/dmdirc/ui/messages/BackBuffer.java
  26. 1
    1
      src/com/dmdirc/ui/messages/sink/AllMessageSink.java
  27. 1
    1
      src/com/dmdirc/ui/messages/sink/ChannelMessageSink.java
  28. 1
    1
      src/com/dmdirc/ui/messages/sink/CommonChannelsMessageSink.java
  29. 1
    2
      src/com/dmdirc/ui/messages/sink/CustomWindowMessageSink.java
  30. 1
    1
      src/com/dmdirc/ui/messages/sink/LastCommandMessageSink.java
  31. 1
    2
      src/com/dmdirc/ui/messages/sink/ServerMessageSink.java
  32. 1
    1
      test/com/dmdirc/actions/ActionSubstitutorTest.java
  33. 2
    2
      test/com/dmdirc/commandparser/commands/channel/BanTest.java
  34. 4
    4
      test/com/dmdirc/commandparser/commands/channel/KickReasonTest.java
  35. 1
    1
      test/com/dmdirc/commandparser/commands/channel/ModeTest.java
  36. 1
    1
      test/com/dmdirc/commandparser/commands/channel/NamesTest.java
  37. 5
    5
      test/com/dmdirc/commandparser/parsers/CommandParserTest.java
  38. 1
    1
      test/com/dmdirc/harness/TestWritableFrameContainer.java

+ 1
- 1
src/com/dmdirc/Channel.java View File

548
     }
548
     }
549
 
549
 
550
     @Override
550
     @Override
551
-    public Optional<Connection> getOptionalConnection() {
551
+    public Optional<Connection> getConnection() {
552
         return Optional.of(server);
552
         return Optional.of(server);
553
     }
553
     }
554
 
554
 

+ 1
- 1
src/com/dmdirc/ChannelEventHandler.java View File

114
     @Nonnull
114
     @Nonnull
115
     @Override
115
     @Override
116
     protected Connection getConnection() {
116
     protected Connection getConnection() {
117
-        return owner.getOptionalConnection().get();
117
+        return owner.getConnection().get();
118
     }
118
     }
119
 
119
 
120
     /**
120
     /**

+ 2
- 2
src/com/dmdirc/CustomWindow.java View File

65
     }
65
     }
66
 
66
 
67
     @Override
67
     @Override
68
-    public Optional<Connection> getOptionalConnection() {
69
-        return getParent().flatMap(FrameContainer::getOptionalConnection);
68
+    public Optional<Connection> getConnection() {
69
+        return getParent().flatMap(FrameContainer::getConnection);
70
     }
70
     }
71
 
71
 
72
 }
72
 }

+ 1
- 1
src/com/dmdirc/FrameContainer.java View File

349
      *
349
      *
350
      * @return the associated connection.
350
      * @return the associated connection.
351
      */
351
      */
352
-    public abstract Optional<Connection> getOptionalConnection();
352
+    public abstract Optional<Connection> getConnection();
353
 
353
 
354
     /**
354
     /**
355
      * Sets the icon to be used by this frame container and fires a {@link FrameIconChangedEvent}.
355
      * Sets the icon to be used by this frame container and fires a {@link FrameIconChangedEvent}.

+ 1
- 1
src/com/dmdirc/GlobalWindow.java View File

64
     }
64
     }
65
 
65
 
66
     @Override
66
     @Override
67
-    public Optional<Connection> getOptionalConnection() {
67
+    public Optional<Connection> getConnection() {
68
         return Optional.empty();
68
         return Optional.empty();
69
     }
69
     }
70
 
70
 

+ 1
- 1
src/com/dmdirc/Query.java View File

285
     }
285
     }
286
 
286
 
287
     @Override
287
     @Override
288
-    public Optional<Connection> getOptionalConnection() {
288
+    public Optional<Connection> getConnection() {
289
         return Optional.of(server);
289
         return Optional.of(server);
290
     }
290
     }
291
 
291
 

+ 1
- 1
src/com/dmdirc/Raw.java View File

112
     }
112
     }
113
 
113
 
114
     @Override
114
     @Override
115
-    public Optional<Connection> getOptionalConnection() {
115
+    public Optional<Connection> getConnection() {
116
         return Optional.of(server);
116
         return Optional.of(server);
117
     }
117
     }
118
 
118
 

+ 1
- 1
src/com/dmdirc/Server.java View File

1038
     }
1038
     }
1039
 
1039
 
1040
     @Override
1040
     @Override
1041
-    public Optional<Connection> getOptionalConnection() {
1041
+    public Optional<Connection> getConnection() {
1042
         return Optional.of(this);
1042
         return Optional.of(this);
1043
     }
1043
     }
1044
 
1044
 

+ 2
- 2
src/com/dmdirc/actions/ActionSubstitutor.java View File

279
 
279
 
280
         if (hasFrameContainer() && serverMatcher.matches()) {
280
         if (hasFrameContainer() && serverMatcher.matches()) {
281
             final Optional<Connection> connection =
281
             final Optional<Connection> connection =
282
-                    ((FrameContainer) args[0]).getOptionalConnection();
282
+                    ((FrameContainer) args[0]).getConnection();
283
 
283
 
284
             if (connection.isPresent()) {
284
             if (connection.isPresent()) {
285
                 try {
285
                 try {
311
     protected String checkConnection(final ActionComponentChain chain,
311
     protected String checkConnection(final ActionComponentChain chain,
312
             final Object[] args, final Object argument) {
312
             final Object[] args, final Object argument) {
313
         if ((chain.requiresConnection() && args[0] instanceof FrameContainer
313
         if ((chain.requiresConnection() && args[0] instanceof FrameContainer
314
-                && ((FrameContainer) args[0]).getOptionalConnection().get().getState()
314
+                && ((FrameContainer) args[0]).getConnection().get().getState()
315
                 == ServerState.CONNECTED) || !chain.requiresConnection()) {
315
                 == ServerState.CONNECTED) || !chain.requiresConnection()) {
316
             final Object res = chain.get(argument);
316
             final Object res = chain.get(argument);
317
             return res == null ? ERR_NULL_CHAIN : res.toString();
317
             return res == null ? ERR_NULL_CHAIN : res.toString();

+ 1
- 1
src/com/dmdirc/actions/CoreActionComponent.java View File

730
     WINDOW_SERVER {
730
     WINDOW_SERVER {
731
         @Override
731
         @Override
732
         public Object get(final Object arg) {
732
         public Object get(final Object arg) {
733
-            return ((Window) arg).getContainer().getOptionalConnection().orElse(null);
733
+            return ((Window) arg).getContainer().getConnection().orElse(null);
734
         }
734
         }
735
 
735
 
736
         @Override
736
         @Override

+ 1
- 1
src/com/dmdirc/commandparser/commands/channel/Mode.java View File

74
         if (args.getArguments().length == 0) {
74
         if (args.getArguments().length == 0) {
75
             sendLine(origin, args.isSilent(), "channelModeDiscovered", cChannel.getModes(), cChannel);
75
             sendLine(origin, args.isSilent(), "channelModeDiscovered", cChannel.getModes(), cChannel);
76
         } else {
76
         } else {
77
-            channel.getOptionalConnection().get().getParser().sendRawMessage("MODE "
77
+            channel.getConnection().get().getParser().sendRawMessage("MODE "
78
                     + cChannel + " " + args.getArgumentsAsString());
78
                     + cChannel + " " + args.getArgumentsAsString());
79
         }
79
         }
80
     }
80
     }

+ 1
- 1
src/com/dmdirc/commandparser/commands/channel/Names.java View File

67
     public void execute(@Nonnull final FrameContainer origin,
67
     public void execute(@Nonnull final FrameContainer origin,
68
             final CommandArguments args, final CommandContext context) {
68
             final CommandArguments args, final CommandContext context) {
69
         final Channel channel = ((ChannelCommandContext) context).getChannel();
69
         final Channel channel = ((ChannelCommandContext) context).getChannel();
70
-        channel.getOptionalConnection().get().getParser().sendRawMessage("NAMES "
70
+        channel.getConnection().get().getParser().sendRawMessage("NAMES "
71
                 + channel.getChannelInfo().getName());
71
                 + channel.getChannelInfo().getName());
72
     }
72
     }
73
 
73
 

+ 1
- 1
src/com/dmdirc/commandparser/commands/channel/ShowTopic.java View File

71
             if (cChannel.getTopic().isEmpty()) {
71
             if (cChannel.getTopic().isEmpty()) {
72
                 sendLine(origin, args.isSilent(), "channelNoTopic", cChannel);
72
                 sendLine(origin, args.isSilent(), "channelNoTopic", cChannel);
73
             } else {
73
             } else {
74
-                final String[] parts = channel.getOptionalConnection().get().parseHostmask(
74
+                final String[] parts = channel.getConnection().get().parseHostmask(
75
                         cChannel.getTopicSetter());
75
                         cChannel.getTopicSetter());
76
 
76
 
77
                 sendLine(origin, args.isSilent(), "channelTopicDiscovered",
77
                 sendLine(origin, args.isSilent(), "channelTopicDiscovered",

+ 1
- 1
src/com/dmdirc/commandparser/commands/chat/Me.java View File

78
     public ValidationResponse validateArguments(
78
     public ValidationResponse validateArguments(
79
             final FrameContainer origin,
79
             final FrameContainer origin,
80
             final CommandArguments arguments) {
80
             final CommandArguments arguments) {
81
-        final Optional<Connection> connection = origin.getOptionalConnection();
81
+        final Optional<Connection> connection = origin.getConnection();
82
         final Optional<Parser> parser = connection.flatMap(c -> Optional.ofNullable(c.getParser()));
82
         final Optional<Parser> parser = connection.flatMap(c -> Optional.ofNullable(c.getParser()));
83
 
83
 
84
         if (!parser.isPresent()) {
84
         if (!parser.isPresent()) {

+ 1
- 1
src/com/dmdirc/commandparser/commands/context/ChatCommandContext.java View File

49
             final CommandInfo commandInfo, final MessageTarget chat) {
49
             final CommandInfo commandInfo, final MessageTarget chat) {
50
         super(source, commandInfo,
50
         super(source, commandInfo,
51
                 Optional.ofNullable(source)
51
                 Optional.ofNullable(source)
52
-                        .flatMap(FrameContainer::getOptionalConnection)
52
+                        .flatMap(FrameContainer::getConnection)
53
                         .orElse(null));
53
                         .orElse(null));
54
         this.chat = chat;
54
         this.chat = chat;
55
     }
55
     }

+ 1
- 2
src/com/dmdirc/commandparser/commands/global/Echo.java View File

43
 import java.util.ArrayList;
43
 import java.util.ArrayList;
44
 import java.util.Collection;
44
 import java.util.Collection;
45
 import java.util.Date;
45
 import java.util.Date;
46
-import java.util.List;
47
 import java.util.Optional;
46
 import java.util.Optional;
48
 import java.util.stream.Collectors;
47
 import java.util.stream.Collectors;
49
 
48
 
141
                 && context.getPreviousArgs().get(0).equals("--ts"))) {
140
                 && context.getPreviousArgs().get(0).equals("--ts"))) {
142
 
141
 
143
             final Collection<FrameContainer> windowList = new ArrayList<>();
142
             final Collection<FrameContainer> windowList = new ArrayList<>();
144
-            final Optional<Connection> connection = context.getWindow().getOptionalConnection();
143
+            final Optional<Connection> connection = context.getWindow().getConnection();
145
 
144
 
146
             //Active window's Children
145
             //Active window's Children
147
             windowList.addAll(context.getWindow().getChildren());
146
             windowList.addAll(context.getWindow().getChildren());

+ 1
- 1
src/com/dmdirc/commandparser/commands/global/OpenWindow.java View File

94
         FrameContainer parent = null;
94
         FrameContainer parent = null;
95
 
95
 
96
         if (args.getArguments().length > 0 && "--server".equals(args.getArguments()[0])) {
96
         if (args.getArguments().length > 0 && "--server".equals(args.getArguments()[0])) {
97
-            final Optional<Connection> connection = origin.getOptionalConnection();
97
+            final Optional<Connection> connection = origin.getConnection();
98
             if (!connection.isPresent()) {
98
             if (!connection.isPresent()) {
99
                 sendLine(origin, args.isSilent(), FORMAT_ERROR,
99
                 sendLine(origin, args.isSilent(), FORMAT_ERROR,
100
                         "This window doesn't have an associated server.");
100
                         "This window doesn't have an associated server.");

+ 1
- 1
src/com/dmdirc/commandparser/commands/global/SetCommand.java View File

114
 
114
 
115
         ConfigProvider identity = identityController.getUserSettings();
115
         ConfigProvider identity = identityController.getUserSettings();
116
         AggregateConfigProvider manager = identityController.getGlobalConfiguration();
116
         AggregateConfigProvider manager = identityController.getGlobalConfiguration();
117
-        final Optional<Connection> connection = origin.getOptionalConnection();
117
+        final Optional<Connection> connection = origin.getConnection();
118
 
118
 
119
         if (res.hasFlag(serverFlag)) {
119
         if (res.hasFlag(serverFlag)) {
120
             if (!connection.isPresent()) {
120
             if (!connection.isPresent()) {

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/Ignore.java View File

185
             targets.include(TabCompletionType.CHANNEL_NICK);
185
             targets.include(TabCompletionType.CHANNEL_NICK);
186
             targets.include(TabCompletionType.QUERY_NICK);
186
             targets.include(TabCompletionType.QUERY_NICK);
187
         } else if (arg == 1 && "--remove".equals(context.getPreviousArgs().get(0))) {
187
         } else if (arg == 1 && "--remove".equals(context.getPreviousArgs().get(0))) {
188
-            final IgnoreList ignoreList = context.getWindow().getOptionalConnection()
188
+            final IgnoreList ignoreList = context.getWindow().getConnection()
189
                     .get().getIgnoreList();
189
                     .get().getIgnoreList();
190
             if (ignoreList.canConvert()) {
190
             if (ignoreList.canConvert()) {
191
                 targets.addAll(ignoreList.getSimpleList().stream().collect(Collectors.toList()));
191
                 targets.addAll(ignoreList.getSimpleList().stream().collect(Collectors.toList()));

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/JoinChannelCommand.java View File

119
     public AdditionalTabTargets getSuggestions(final int arg,
119
     public AdditionalTabTargets getSuggestions(final int arg,
120
             final IntelligentCommandContext context) {
120
             final IntelligentCommandContext context) {
121
         final FrameContainer source = context.getWindow();
121
         final FrameContainer source = context.getWindow();
122
-        final Connection connection = source.getOptionalConnection().get();
122
+        final Connection connection = source.getConnection().get();
123
         final List<String> results = checkSource(source, true, true);
123
         final List<String> results = checkSource(source, true, true);
124
 
124
 
125
         final AdditionalTabTargets targets = new AdditionalTabTargets().excludeAll();
125
         final AdditionalTabTargets targets = new AdditionalTabTargets().excludeAll();

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/Message.java View File

116
     public int getLineCount(final FrameContainer origin, final CommandArguments arguments) {
116
     public int getLineCount(final FrameContainer origin, final CommandArguments arguments) {
117
         if (arguments.getArguments().length >= 2) {
117
         if (arguments.getArguments().length >= 2) {
118
             final String target = arguments.getArguments()[0];
118
             final String target = arguments.getArguments()[0];
119
-            return origin.getOptionalConnection().get().getWindowModel().getNumLines(
119
+            return origin.getConnection().get().getWindowModel().getNumLines(
120
                     "PRIVMSG " + target + " :" + arguments.getArgumentsAsString(1));
120
                     "PRIVMSG " + target + " :" + arguments.getArgumentsAsString(1));
121
         } else {
121
         } else {
122
             return 1;
122
             return 1;

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/OpenQuery.java View File

109
     public int getLineCount(final FrameContainer origin, final CommandArguments arguments) {
109
     public int getLineCount(final FrameContainer origin, final CommandArguments arguments) {
110
         if (arguments.getArguments().length >= 2) {
110
         if (arguments.getArguments().length >= 2) {
111
             final String target = arguments.getArguments()[0];
111
             final String target = arguments.getArguments()[0];
112
-            return origin.getOptionalConnection().get().getWindowModel().getNumLines("PRIVMSG "
112
+            return origin.getConnection().get().getWindowModel().getNumLines("PRIVMSG "
113
                     + target + " :" + arguments.getArgumentsAsString(1));
113
                     + target + " :" + arguments.getArgumentsAsString(1));
114
         } else {
114
         } else {
115
             return 1;
115
             return 1;

+ 1
- 1
src/com/dmdirc/commandparser/parsers/CommandParser.java View File

179
         final boolean silent = args.isSilent();
179
         final boolean silent = args.isSilent();
180
         final String command = args.getCommandName();
180
         final String command = args.getCommandName();
181
         final String[] cargs = args.getArguments();
181
         final String[] cargs = args.getArguments();
182
-        final Optional<Connection> connection = origin.getOptionalConnection();
182
+        final Optional<Connection> connection = origin.getConnection();
183
 
183
 
184
         if (cargs.length == 0
184
         if (cargs.length == 0
185
                 || !parseChannel
185
                 || !parseChannel

+ 1
- 1
src/com/dmdirc/interfaces/Chat.java View File

36
      *
36
      *
37
      * @return This chat's connection.
37
      * @return This chat's connection.
38
      */
38
      */
39
-    Optional<Connection> getOptionalConnection();
39
+    Optional<Connection> getConnection();
40
 
40
 
41
     /**
41
     /**
42
      * Sends an action to the chat. If an action is too long to be sent, an error will be displayed.
42
      * Sends an action to the chat. If an action is too long to be sent, an error will be displayed.

+ 1
- 1
src/com/dmdirc/ui/messages/BackBuffer.java View File

49
             final ColourManagerFactory colourManagerFactory,
49
             final ColourManagerFactory colourManagerFactory,
50
             final EventFormatter formatter) {
50
             final EventFormatter formatter) {
51
         this.styliser = new Styliser(
51
         this.styliser = new Styliser(
52
-                owner.getOptionalConnection().orElse(null),
52
+                owner.getConnection().orElse(null),
53
                 owner.getConfigManager(),
53
                 owner.getConfigManager(),
54
                 colourManagerFactory.getColourManager(owner.getConfigManager()),
54
                 colourManagerFactory.getColourManager(owner.getConfigManager()),
55
                 owner.getEventBus());
55
                 owner.getEventBus());

+ 1
- 1
src/com/dmdirc/ui/messages/sink/AllMessageSink.java View File

51
             final FrameContainer source,
51
             final FrameContainer source,
52
             final String[] patternMatches, final Date date,
52
             final String[] patternMatches, final Date date,
53
             final String messageType, final Object... args) {
53
             final String messageType, final Object... args) {
54
-        source.getOptionalConnection().get().addLineToAll(messageType, date, args);
54
+        source.getConnection().get().addLineToAll(messageType, date, args);
55
     }
55
     }
56
 
56
 
57
 }
57
 }

+ 1
- 1
src/com/dmdirc/ui/messages/sink/ChannelMessageSink.java View File

58
         final String user = String.format(patternMatches[0], args);
58
         final String user = String.format(patternMatches[0], args);
59
         boolean found = false;
59
         boolean found = false;
60
 
60
 
61
-        final Connection connection = source.getOptionalConnection().get();
61
+        final Connection connection = source.getConnection().get();
62
         for (String channelName : connection.getChannels()) {
62
         for (String channelName : connection.getChannels()) {
63
             final Channel channel = connection.getChannel(channelName);
63
             final Channel channel = connection.getChannel(channelName);
64
             if (channel.getChannelInfo().getChannelClient(user) != null) {
64
             if (channel.getChannelInfo().getChannelClient(user) != null) {

+ 1
- 1
src/com/dmdirc/ui/messages/sink/CommonChannelsMessageSink.java View File

57
             final String[] patternMatches, final Date date,
57
             final String[] patternMatches, final Date date,
58
             final String messageType, final Object... args) {
58
             final String messageType, final Object... args) {
59
         final String user = String.format(patternMatches[0], args);
59
         final String user = String.format(patternMatches[0], args);
60
-        final Connection connection = source.getOptionalConnection().get();
60
+        final Connection connection = source.getConnection().get();
61
         boolean found = false;
61
         boolean found = false;
62
 
62
 
63
         for (String channelName : connection.getChannels()) {
63
         for (String channelName : connection.getChannels()) {

+ 1
- 2
src/com/dmdirc/ui/messages/sink/CustomWindowMessageSink.java View File

24
 
24
 
25
 import com.dmdirc.CustomWindow;
25
 import com.dmdirc.CustomWindow;
26
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28
 import com.dmdirc.ui.WindowManager;
27
 import com.dmdirc.ui.WindowManager;
29
 import com.dmdirc.ui.messages.BackBufferFactory;
28
 import com.dmdirc.ui.messages.BackBufferFactory;
30
 import com.dmdirc.util.URLBuilder;
29
 import com.dmdirc.util.URLBuilder;
71
             final FrameContainer source,
70
             final FrameContainer source,
72
             final String[] patternMatches, final Date date,
71
             final String[] patternMatches, final Date date,
73
             final String messageType, final Object... args) {
72
             final String messageType, final Object... args) {
74
-        final FrameContainer connectionContainer = source.getOptionalConnection()
73
+        final FrameContainer connectionContainer = source.getConnection()
75
                 .get().getWindowModel();
74
                 .get().getWindowModel();
76
         FrameContainer targetWindow = windowManager
75
         FrameContainer targetWindow = windowManager
77
                 .findCustomWindow(connectionContainer, patternMatches[0]);
76
                 .findCustomWindow(connectionContainer, patternMatches[0]);

+ 1
- 1
src/com/dmdirc/ui/messages/sink/LastCommandMessageSink.java View File

66
 
66
 
67
         final Collection<FrameContainer> containers = new ArrayList<>();
67
         final Collection<FrameContainer> containers = new ArrayList<>();
68
 
68
 
69
-        final FrameContainer connectionContainer = source.getOptionalConnection()
69
+        final FrameContainer connectionContainer = source.getConnection()
70
                 .get().getWindowModel();
70
                 .get().getWindowModel();
71
         containers.add(connectionContainer);
71
         containers.add(connectionContainer);
72
         containers.addAll(connectionContainer.getChildren());
72
         containers.addAll(connectionContainer.getChildren());

+ 1
- 2
src/com/dmdirc/ui/messages/sink/ServerMessageSink.java View File

23
 package com.dmdirc.ui.messages.sink;
23
 package com.dmdirc.ui.messages.sink;
24
 
24
 
25
 import com.dmdirc.FrameContainer;
25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.Server;
27
 
26
 
28
 import java.util.Date;
27
 import java.util.Date;
29
 import java.util.regex.Pattern;
28
 import java.util.regex.Pattern;
52
             final FrameContainer source,
51
             final FrameContainer source,
53
             final String[] patternMatches, final Date date,
52
             final String[] patternMatches, final Date date,
54
             final String messageType, final Object... args) {
53
             final String messageType, final Object... args) {
55
-        source.getOptionalConnection().get().getWindowModel().addLine(messageType, date, args);
54
+        source.getConnection().get().getWindowModel().addLine(messageType, date, args);
56
     }
55
     }
57
 
56
 
58
 }
57
 }

+ 1
- 1
test/com/dmdirc/actions/ActionSubstitutorTest.java View File

75
 
75
 
76
         final ChannelClientInfo clientInfo = mock(ChannelClientInfo.class);
76
         final ChannelClientInfo clientInfo = mock(ChannelClientInfo.class);
77
 
77
 
78
-        when(channel.getOptionalConnection()).thenReturn(Optional.of(server));
78
+        when(channel.getConnection()).thenReturn(Optional.of(server));
79
         when(channel.getConfigManager()).thenReturn(manager);
79
         when(channel.getConfigManager()).thenReturn(manager);
80
         when(server.getState()).thenReturn(ServerState.DISCONNECTED);
80
         when(server.getState()).thenReturn(ServerState.DISCONNECTED);
81
         when(server.getAwayMessage()).thenReturn("foo");
81
         when(server.getAwayMessage()).thenReturn("foo");

+ 2
- 2
test/com/dmdirc/commandparser/commands/channel/BanTest.java View File

77
         when(channelInfo.getChannelClient("user")).thenReturn(ccInfo);
77
         when(channelInfo.getChannelClient("user")).thenReturn(ccInfo);
78
         when(ccInfo.getClient()).thenReturn(clientInfo);
78
         when(ccInfo.getClient()).thenReturn(clientInfo);
79
         when(clientInfo.getHostname()).thenReturn("my.host.name");
79
         when(clientInfo.getHostname()).thenReturn("my.host.name");
80
-        when(container.getOptionalConnection()).thenReturn(Optional.empty());
80
+        when(container.getConnection()).thenReturn(Optional.empty());
81
 
81
 
82
         command.execute(container, new CommandArguments(controller, "/ban user"),
82
         command.execute(container, new CommandArguments(controller, "/ban user"),
83
                 new ChannelCommandContext(null, Ban.INFO, channel));
83
                 new ChannelCommandContext(null, Ban.INFO, channel));
94
         final Channel channel = mock(Channel.class);
94
         final Channel channel = mock(Channel.class);
95
 
95
 
96
         when(channel.getChannelInfo()).thenReturn(channelInfo);
96
         when(channel.getChannelInfo()).thenReturn(channelInfo);
97
-        when(container.getOptionalConnection()).thenReturn(Optional.empty());
97
+        when(container.getConnection()).thenReturn(Optional.empty());
98
 
98
 
99
         command.execute(container, new CommandArguments(controller, "/ban *!*@my.host.name"),
99
         command.execute(container, new CommandArguments(controller, "/ban *!*@my.host.name"),
100
                 new ChannelCommandContext(null, Ban.INFO, channel));
100
                 new ChannelCommandContext(null, Ban.INFO, channel));

+ 4
- 4
test/com/dmdirc/commandparser/commands/channel/KickReasonTest.java View File

65
         final FrameContainer tiw = mock(FrameContainer.class);
65
         final FrameContainer tiw = mock(FrameContainer.class);
66
         final Channel channel = mock(Channel.class);
66
         final Channel channel = mock(Channel.class);
67
 
67
 
68
-        when(tiw.getOptionalConnection()).thenReturn(Optional.empty());
68
+        when(tiw.getConnection()).thenReturn(Optional.empty());
69
 
69
 
70
         command.execute(tiw, new CommandArguments(controller, "/kick"),
70
         command.execute(tiw, new CommandArguments(controller, "/kick"),
71
                 new ChannelCommandContext(null, KickReason.INFO, channel));
71
                 new ChannelCommandContext(null, KickReason.INFO, channel));
81
 
81
 
82
         when(channel.getChannelInfo()).thenReturn(channelInfo);
82
         when(channel.getChannelInfo()).thenReturn(channelInfo);
83
         when(channelInfo.getChannelClient(anyString())).thenReturn(null);
83
         when(channelInfo.getChannelClient(anyString())).thenReturn(null);
84
-        when(tiw.getOptionalConnection()).thenReturn(Optional.empty());
84
+        when(tiw.getConnection()).thenReturn(Optional.empty());
85
 
85
 
86
         command.execute(tiw, new CommandArguments(controller, "/kick user1"),
86
         command.execute(tiw, new CommandArguments(controller, "/kick user1"),
87
                 new ChannelCommandContext(null, KickReason.INFO, channel));
87
                 new ChannelCommandContext(null, KickReason.INFO, channel));
98
 
98
 
99
         when(channel.getChannelInfo()).thenReturn(channelInfo);
99
         when(channel.getChannelInfo()).thenReturn(channelInfo);
100
         when(channelInfo.getChannelClient("user1")).thenReturn(cci);
100
         when(channelInfo.getChannelClient("user1")).thenReturn(cci);
101
-        when(tiw.getOptionalConnection()).thenReturn(Optional.empty());
101
+        when(tiw.getConnection()).thenReturn(Optional.empty());
102
 
102
 
103
         command.execute(tiw, new CommandArguments(controller, "/kick user1 reason here"),
103
         command.execute(tiw, new CommandArguments(controller, "/kick user1 reason here"),
104
                 new ChannelCommandContext(null, KickReason.INFO, channel));
104
                 new ChannelCommandContext(null, KickReason.INFO, channel));
118
         when(channel.getChannelInfo()).thenReturn(channelInfo);
118
         when(channel.getChannelInfo()).thenReturn(channelInfo);
119
         when(channelInfo.getChannelClient("user1")).thenReturn(cci);
119
         when(channelInfo.getChannelClient("user1")).thenReturn(cci);
120
         when(manager.getOption("general", "kickmessage")).thenReturn("reason here");
120
         when(manager.getOption("general", "kickmessage")).thenReturn("reason here");
121
-        when(tiw.getOptionalConnection()).thenReturn(Optional.empty());
121
+        when(tiw.getConnection()).thenReturn(Optional.empty());
122
 
122
 
123
         command.execute(tiw, new CommandArguments(controller, "/kick user1"),
123
         command.execute(tiw, new CommandArguments(controller, "/kick user1"),
124
                 new ChannelCommandContext(null, KickReason.INFO, channel));
124
                 new ChannelCommandContext(null, KickReason.INFO, channel));

+ 1
- 1
test/com/dmdirc/commandparser/commands/channel/ModeTest.java View File

56
 
56
 
57
     @Before
57
     @Before
58
     public void setUp() throws InvalidIdentityFileException {
58
     public void setUp() throws InvalidIdentityFileException {
59
-        when(channel.getOptionalConnection()).thenReturn(Optional.of(server));
59
+        when(channel.getConnection()).thenReturn(Optional.of(server));
60
         when(server.getParser()).thenReturn(parser);
60
         when(server.getParser()).thenReturn(parser);
61
         when(channel.getChannelInfo()).thenReturn(channelinfo);
61
         when(channel.getChannelInfo()).thenReturn(channelinfo);
62
         when(channelinfo.getModes()).thenReturn("my mode string!");
62
         when(channelinfo.getModes()).thenReturn("my mode string!");

+ 1
- 1
test/com/dmdirc/commandparser/commands/channel/NamesTest.java View File

55
 
55
 
56
     @Before
56
     @Before
57
     public void setUp() throws InvalidIdentityFileException {
57
     public void setUp() throws InvalidIdentityFileException {
58
-        when(channel.getOptionalConnection()).thenReturn(Optional.of(server));
58
+        when(channel.getConnection()).thenReturn(Optional.of(server));
59
         when(server.getParser()).thenReturn(parser);
59
         when(server.getParser()).thenReturn(parser);
60
         when(channel.getChannelInfo()).thenReturn(channelinfo);
60
         when(channel.getChannelInfo()).thenReturn(channelinfo);
61
         when(channelinfo.getName()).thenReturn("#chan");
61
         when(channelinfo.getName()).thenReturn("#chan");

+ 5
- 5
test/com/dmdirc/commandparser/parsers/CommandParserTest.java View File

74
 
74
 
75
         when(configProvider.getOptionInt("general", "commandhistory")).thenReturn(10);
75
         when(configProvider.getOptionInt("general", "commandhistory")).thenReturn(10);
76
 
76
 
77
-        when(container.getOptionalConnection()).thenReturn(Optional.of(connection));
77
+        when(container.getConnection()).thenReturn(Optional.of(connection));
78
         when(connection.isValidChannelName("#channel1")).thenReturn(true);
78
         when(connection.isValidChannelName("#channel1")).thenReturn(true);
79
         when(connection.isValidChannelName("#channel2")).thenReturn(true);
79
         when(connection.isValidChannelName("#channel2")).thenReturn(true);
80
         when(connection.hasChannel("#channel1")).thenReturn(true);
80
         when(connection.hasChannel("#channel1")).thenReturn(true);
191
 
191
 
192
     @Test
192
     @Test
193
     public void testParseChannelCommandWithArguments() {
193
     public void testParseChannelCommandWithArguments() {
194
-        when(container.getOptionalConnection()).thenReturn(Optional.of(connection));
194
+        when(container.getConnection()).thenReturn(Optional.of(connection));
195
         commandParser.parseCommand(container, "/channel #channel1 this is a test");
195
         commandParser.parseCommand(container, "/channel #channel1 this is a test");
196
 
196
 
197
         assertNull(channelCommandParser.nonCommandLine);
197
         assertNull(channelCommandParser.nonCommandLine);
203
 
203
 
204
     @Test
204
     @Test
205
     public void testParseChannelCommandWithoutArguments() {
205
     public void testParseChannelCommandWithoutArguments() {
206
-        when(container.getOptionalConnection()).thenReturn(Optional.of(connection));
206
+        when(container.getConnection()).thenReturn(Optional.of(connection));
207
         commandParser.parseCommand(container, "/channel #channel1");
207
         commandParser.parseCommand(container, "/channel #channel1");
208
 
208
 
209
         assertNull(channelCommandParser.nonCommandLine);
209
         assertNull(channelCommandParser.nonCommandLine);
215
 
215
 
216
     @Test
216
     @Test
217
     public void testParseSilencedChannelCommandWithArguments() {
217
     public void testParseSilencedChannelCommandWithArguments() {
218
-        when(container.getOptionalConnection()).thenReturn(Optional.of(connection));
218
+        when(container.getConnection()).thenReturn(Optional.of(connection));
219
         commandParser.parseCommand(container, "/.channel #channel1 this is a test");
219
         commandParser.parseCommand(container, "/.channel #channel1 this is a test");
220
 
220
 
221
         assertNull(channelCommandParser.nonCommandLine);
221
         assertNull(channelCommandParser.nonCommandLine);
227
 
227
 
228
     @Test
228
     @Test
229
     public void testParseSilencedChannelCommandWithoutArguments() {
229
     public void testParseSilencedChannelCommandWithoutArguments() {
230
-        when(container.getOptionalConnection()).thenReturn(Optional.of(connection));
230
+        when(container.getConnection()).thenReturn(Optional.of(connection));
231
         commandParser.parseCommand(container, "/.channel #channel1");
231
         commandParser.parseCommand(container, "/.channel #channel1");
232
 
232
 
233
         assertNull(channelCommandParser.nonCommandLine);
233
         assertNull(channelCommandParser.nonCommandLine);

+ 1
- 1
test/com/dmdirc/harness/TestWritableFrameContainer.java View File

69
     }
69
     }
70
 
70
 
71
     @Override
71
     @Override
72
-    public Optional<Connection> getOptionalConnection() {
72
+    public Optional<Connection> getConnection() {
73
         return Optional.empty();
73
         return Optional.empty();
74
     }
74
     }
75
 
75
 

Loading…
Cancel
Save