Browse Source

Switch from `time` to `metadata`, store batch ID

tags/v0.9.0
Chris Smith 5 years ago
parent
commit
c40ebf68c0
50 changed files with 334 additions and 273 deletions
  1. 3
    0
      CHANGELOG
  2. 1
    1
      build.gradle.kts
  3. 4
    5
      src/main/kotlin/com/dmdirc/ktirc/IrcClientImpl.kt
  4. 57
    36
      src/main/kotlin/com/dmdirc/ktirc/events/Events.kt
  5. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/events/handlers/ChannelStateHandler.kt
  6. 2
    2
      src/main/kotlin/com/dmdirc/ktirc/events/mutators/ChannelFanOutMutator.kt
  7. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/events/mutators/ServerReadyMutator.kt
  8. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/AccountProcessor.kt
  9. 4
    4
      src/main/kotlin/com/dmdirc/ktirc/messages/AuthenticationProcessor.kt
  10. 14
    0
      src/main/kotlin/com/dmdirc/ktirc/messages/BatchProcessor.kt
  11. 6
    6
      src/main/kotlin/com/dmdirc/ktirc/messages/CapabilityProcessor.kt
  12. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/ISupportProcessor.kt
  13. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/JoinProcessor.kt
  14. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/KickProcessor.kt
  15. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/ModeProcessor.kt
  16. 4
    4
      src/main/kotlin/com/dmdirc/ktirc/messages/MotdProcessor.kt
  17. 2
    2
      src/main/kotlin/com/dmdirc/ktirc/messages/NamesProcessor.kt
  18. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/NickProcessor.kt
  19. 2
    2
      src/main/kotlin/com/dmdirc/ktirc/messages/NoticeProcessor.kt
  20. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/PartProcessor.kt
  21. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/PingProcessor.kt
  22. 3
    3
      src/main/kotlin/com/dmdirc/ktirc/messages/PrivmsgProcessor.kt
  23. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/QuitProcessor.kt
  24. 4
    4
      src/main/kotlin/com/dmdirc/ktirc/messages/TopicProcessor.kt
  25. 1
    1
      src/main/kotlin/com/dmdirc/ktirc/messages/WelcomeProcessor.kt
  26. 3
    0
      src/main/kotlin/com/dmdirc/ktirc/model/CapabilitiesState.kt
  27. 21
    6
      src/main/kotlin/com/dmdirc/ktirc/model/IrcMessage.kt
  28. 2
    2
      src/test/kotlin/com/dmdirc/ktirc/IrcClientImplTest.kt
  29. 10
    10
      src/test/kotlin/com/dmdirc/ktirc/events/EventUtilsTest.kt
  30. 27
    27
      src/test/kotlin/com/dmdirc/ktirc/events/handlers/CapabilitiesHandlerTest.kt
  31. 45
    45
      src/test/kotlin/com/dmdirc/ktirc/events/handlers/ChannelStateHandlerTest.kt
  32. 2
    1
      src/test/kotlin/com/dmdirc/ktirc/events/handlers/PingHandlerTest.kt
  33. 8
    8
      src/test/kotlin/com/dmdirc/ktirc/events/handlers/ServerStateHandlerTest.kt
  34. 18
    18
      src/test/kotlin/com/dmdirc/ktirc/events/handlers/UserStateHandlerTest.kt
  35. 5
    8
      src/test/kotlin/com/dmdirc/ktirc/events/mutators/ChannelFanOutMutatorTest.kt
  36. 6
    6
      src/test/kotlin/com/dmdirc/ktirc/events/mutators/ServerReadyMutatorTest.kt
  37. 12
    11
      src/test/kotlin/com/dmdirc/ktirc/io/MessageHandlerTest.kt
  38. 2
    2
      src/test/kotlin/com/dmdirc/ktirc/messages/AccountProcessorTest.kt
  39. 7
    7
      src/test/kotlin/com/dmdirc/ktirc/messages/AuthenticationProcessorTest.kt
  40. 3
    3
      src/test/kotlin/com/dmdirc/ktirc/messages/JoinProcessorTest.kt
  41. 2
    2
      src/test/kotlin/com/dmdirc/ktirc/messages/KickProcessorTest.kt
  42. 8
    8
      src/test/kotlin/com/dmdirc/ktirc/messages/ModeProcessorTest.kt
  43. 4
    4
      src/test/kotlin/com/dmdirc/ktirc/messages/MotdProcessorTest.kt
  44. 4
    4
      src/test/kotlin/com/dmdirc/ktirc/messages/NoticeProcessorTest.kt
  45. 2
    2
      src/test/kotlin/com/dmdirc/ktirc/messages/PartProcessorTest.kt
  46. 8
    8
      src/test/kotlin/com/dmdirc/ktirc/messages/PrivmsgProcessorTest.kt
  47. 2
    2
      src/test/kotlin/com/dmdirc/ktirc/messages/QuitProcessorTest.kt
  48. 4
    4
      src/test/kotlin/com/dmdirc/ktirc/messages/TopicProcessorTest.kt
  49. 1
    1
      src/test/kotlin/com/dmdirc/ktirc/messages/WelcomeProcessorTest.kt
  50. 10
    3
      src/test/kotlin/com/dmdirc/ktirc/model/IrcMessageTest.kt

+ 3
- 0
CHANGELOG View File

@@ -4,6 +4,9 @@ vNEXT (in development)
4 4
    e.g. IrcClient { server("irc.example.com", 6667) }
5 5
  * Add behaviour options
6 6
    * requestModesOnJoin - automatically sends a MODE request when joining a channel
7
+ * Events now have a `metadata` property instead of a `time` (and time is available in metadata)
8
+   * IrcEvent.time is now deprecated but will remain until after v1.0.0.
9
+   * Metadata now contains the event's batch ID, if any.
7 10
  * (Internal) Introduced event mutators
8 11
    * Event mutators are now responsible for handling changing events in response to state
9 12
      e.g. ChannelFanOutMutator creates Channel* events for global quits/nick changes/etc

+ 1
- 1
build.gradle.kts View File

@@ -9,7 +9,7 @@ plugins {
9 9
     kotlin("jvm") version "1.3.21"
10 10
     id("com.jfrog.bintray") version "1.8.4"
11 11
     id("org.jetbrains.dokka") version "0.9.17"
12
-    id("name.remal.check-updates") version "1.0.112"
12
+    id("name.remal.check-updates") version "1.0.113"
13 13
 }
14 14
 
15 15
 jacoco {

+ 4
- 5
src/main/kotlin/com/dmdirc/ktirc/IrcClientImpl.kt View File

@@ -25,7 +25,6 @@ import java.util.concurrent.atomic.AtomicBoolean
25 25
  */
26 26
 // TODO: How should alternative nicknames work?
27 27
 // TODO: Should IRC Client take a pool of servers and rotate through, or make the caller do that?
28
-// TODO: Should there be a default profile?
29 28
 internal class IrcClientImpl(private val config: IrcClientConfig) : IrcClient, CoroutineScope {
30 29
 
31 30
     private val log by logger()
@@ -61,23 +60,23 @@ internal class IrcClientImpl(private val config: IrcClientConfig) : IrcClient, C
61 60
         with(socketFactory(this, config.server.host, config.server.port, config.server.useTls)) {
62 61
             socket = this
63 62
 
64
-            emitEvent(ServerConnecting(currentTimeProvider()))
63
+            emitEvent(ServerConnecting(EventMetadata(currentTimeProvider())))
65 64
 
66 65
             launch {
67 66
                 try {
68 67
                     connect()
69
-                    emitEvent(ServerConnected(currentTimeProvider()))
68
+                    emitEvent(ServerConnected(EventMetadata(currentTimeProvider())))
70 69
                     sendCapabilityList()
71 70
                     sendPasswordIfPresent()
72 71
                     sendNickChange(config.profile.nickname)
73 72
                     sendUser(config.profile.username, config.profile.realName)
74 73
                     messageHandler.processMessages(this@IrcClientImpl, receiveChannel.map { parser.parse(it) })
75 74
                 } catch (ex : Exception) {
76
-                    emitEvent(ServerConnectionError(currentTimeProvider(), ex.toConnectionError(), ex.localizedMessage))
75
+                    emitEvent(ServerConnectionError(EventMetadata(currentTimeProvider()), ex.toConnectionError(), ex.localizedMessage))
77 76
                 }
78 77
 
79 78
                 reset()
80
-                emitEvent(ServerDisconnected(currentTimeProvider()))
79
+                emitEvent(ServerDisconnected(EventMetadata(currentTimeProvider())))
81 80
             }
82 81
         }
83 82
     }

+ 57
- 36
src/main/kotlin/com/dmdirc/ktirc/events/Events.kt View File

@@ -6,113 +6,128 @@ import com.dmdirc.ktirc.model.ServerFeatureMap
6 6
 import com.dmdirc.ktirc.model.User
7 7
 import java.time.LocalDateTime
8 8
 
9
+/**
10
+ * Metadata associated with an event.
11
+ *
12
+ * @param time The best-guess time at which the event occurred.
13
+ * @param batchId The ID of the batch this event is part of, if any.
14
+ */
15
+data class EventMetadata(val time: LocalDateTime, val batchId: String? = null)
16
+
9 17
 /** Base class for all events. */
10
-sealed class IrcEvent(val time: LocalDateTime)
18
+sealed class IrcEvent(val metadata: EventMetadata) {
19
+
20
+    /** The time at which the event occurred. */
21
+    @Deprecated("Only for backwards compatibility; to be removed post-1.0.0", replaceWith = ReplaceWith("metadata.time"))
22
+    val time: LocalDateTime
23
+        get() = metadata.time
24
+
25
+}
11 26
 
12 27
 /** Raised when a connection to the server is being established. */
13
-class ServerConnecting(time: LocalDateTime) : IrcEvent(time)
28
+class ServerConnecting(metadata: EventMetadata) : IrcEvent(metadata)
14 29
 
15 30
 /** Raised when the connection to the server has been established. The server will not be ready for use yet. */
16
-class ServerConnected(time: LocalDateTime) : IrcEvent(time)
31
+class ServerConnected(metadata: EventMetadata) : IrcEvent(metadata)
17 32
 
18 33
 /** Raised when the connection to the server has ended. */
19
-class ServerDisconnected(time: LocalDateTime) : IrcEvent(time)
34
+class ServerDisconnected(metadata: EventMetadata) : IrcEvent(metadata)
20 35
 
21 36
 /** Raised when an error occurred trying to connect. */
22
-class ServerConnectionError(time: LocalDateTime, val error: ConnectionError, val details: String?) : IrcEvent(time)
37
+class ServerConnectionError(metadata: EventMetadata, val error: ConnectionError, val details: String?) : IrcEvent(metadata)
23 38
 
24 39
 /** Raised when the server is ready for use. */
25
-class ServerReady(time: LocalDateTime) : IrcEvent(time)
40
+class ServerReady(metadata: EventMetadata) : IrcEvent(metadata)
26 41
 
27 42
 /** Raised when the server initially welcomes us to the IRC network. */
28
-class ServerWelcome(time: LocalDateTime, val server: String, val localNick: String) : IrcEvent(time)
43
+class ServerWelcome(metadata: EventMetadata, val server: String, val localNick: String) : IrcEvent(metadata)
29 44
 
30 45
 /** Raised when the features supported by the server have changed. This may occur numerous times. */
31
-class ServerFeaturesUpdated(time: LocalDateTime, val serverFeatures: ServerFeatureMap) : IrcEvent(time)
46
+class ServerFeaturesUpdated(metadata: EventMetadata, val serverFeatures: ServerFeatureMap) : IrcEvent(metadata)
32 47
 
33 48
 /** Raised whenever a PING is received from the server. */
34
-class PingReceived(time: LocalDateTime, val nonce: ByteArray) : IrcEvent(time)
49
+class PingReceived(metadata: EventMetadata, val nonce: ByteArray) : IrcEvent(metadata)
35 50
 
36 51
 /** Raised when a user joins a channel. */
37
-class ChannelJoined(time: LocalDateTime, val user: User, val channel: String) : IrcEvent(time)
52
+class ChannelJoined(metadata: EventMetadata, val user: User, val channel: String) : IrcEvent(metadata)
38 53
 
39 54
 /** Raised when a user leaves a channel. */
40
-class ChannelParted(time: LocalDateTime, val user: User, val channel: String, val reason: String = "") : IrcEvent(time)
55
+class ChannelParted(metadata: EventMetadata, val user: User, val channel: String, val reason: String = "") : IrcEvent(metadata)
41 56
 
42 57
 /** Raised when a [victim] is kicked from a channel. */
43
-class ChannelUserKicked(time: LocalDateTime, val user: User, val channel: String, val victim: String, val reason: String = "") : IrcEvent(time)
58
+class ChannelUserKicked(metadata: EventMetadata, val user: User, val channel: String, val victim: String, val reason: String = "") : IrcEvent(metadata)
44 59
 
45 60
 /** Raised when a user quits, and is in a channel. */
46
-class ChannelQuit(time: LocalDateTime, val user: User, val channel: String, val reason: String = "") : IrcEvent(time)
61
+class ChannelQuit(metadata: EventMetadata, val user: User, val channel: String, val reason: String = "") : IrcEvent(metadata)
47 62
 
48 63
 /** Raised when a user changes nickname, and is in a channel. */
49
-class ChannelNickChanged(time: LocalDateTime, val user: User, val channel: String, val newNick: String) : IrcEvent(time)
64
+class ChannelNickChanged(metadata: EventMetadata, val user: User, val channel: String, val newNick: String) : IrcEvent(metadata)
50 65
 
51 66
 /** Raised when a batch of the channel's member list has been received. More batches may follow. */
52
-class ChannelNamesReceived(time: LocalDateTime, val channel: String, val names: List<String>) : IrcEvent(time)
67
+class ChannelNamesReceived(metadata: EventMetadata, val channel: String, val names: List<String>) : IrcEvent(metadata)
53 68
 
54 69
 /** Raised when the entirety of the channel's member list has been received. */
55
-class ChannelNamesFinished(time: LocalDateTime, val channel: String) : IrcEvent(time)
70
+class ChannelNamesFinished(metadata: EventMetadata, val channel: String) : IrcEvent(metadata)
56 71
 
57 72
 /** Raised when a channel topic is discovered (not changed). Usually followed by [ChannelTopicMetadataDiscovered] if the [topic] is non-null. */
58
-class ChannelTopicDiscovered(time: LocalDateTime, val channel: String, val topic: String?) : IrcEvent(time)
73
+class ChannelTopicDiscovered(metadata: EventMetadata, val channel: String, val topic: String?) : IrcEvent(metadata)
59 74
 
60 75
 /** Raised when a channel topic's metadata is discovered. */
61
-class ChannelTopicMetadataDiscovered(time: LocalDateTime, val channel: String, val user: User, val setTime: LocalDateTime) : IrcEvent(time)
76
+class ChannelTopicMetadataDiscovered(metadata: EventMetadata, val channel: String, val user: User, val setTime: LocalDateTime) : IrcEvent(metadata)
62 77
 
63 78
 /**
64 79
  * Raised when a channel's topic is changed.
65 80
  *
66 81
  * If the topic has been unset (cleared), [topic] will be `null`
67 82
  */
68
-class ChannelTopicChanged(time: LocalDateTime, val user: User, val channel: String, val topic: String?) : IrcEvent(time)
83
+class ChannelTopicChanged(metadata: EventMetadata, val user: User, val channel: String, val topic: String?) : IrcEvent(metadata)
69 84
 
70 85
 /** Raised when a message is received. */
71
-class MessageReceived(time: LocalDateTime, val user: User, val target: String, val message: String, val messageId: String? = null) : IrcEvent(time)
86
+class MessageReceived(metadata: EventMetadata, val user: User, val target: String, val message: String, val messageId: String? = null) : IrcEvent(metadata)
72 87
 
73 88
 /**
74 89
  * Raised when a notice is received.
75 90
  *
76 91
  * The [user] may in fact be a server, or have a nickname of `*` while connecting.
77 92
  */
78
-class NoticeReceived(time: LocalDateTime, val user: User, val target: String, val message: String) : IrcEvent(time)
93
+class NoticeReceived(metadata: EventMetadata, val user: User, val target: String, val message: String) : IrcEvent(metadata)
79 94
 
80 95
 /** Raised when an action is received. */
81
-class ActionReceived(time: LocalDateTime, val user: User, val target: String, val action: String, val messageId: String? = null) : IrcEvent(time)
96
+class ActionReceived(metadata: EventMetadata, val user: User, val target: String, val action: String, val messageId: String? = null) : IrcEvent(metadata)
82 97
 
83 98
 /** Raised when a CTCP is received. */
84
-class CtcpReceived(time: LocalDateTime, val user: User, val target: String, val type: String, val content: String) : IrcEvent(time)
99
+class CtcpReceived(metadata: EventMetadata, val user: User, val target: String, val type: String, val content: String) : IrcEvent(metadata)
85 100
 
86 101
 /** Raised when a CTCP reply is received. */
87
-class CtcpReplyReceived(time: LocalDateTime, val user: User, val target: String, val type: String, val content: String) : IrcEvent(time)
102
+class CtcpReplyReceived(metadata: EventMetadata, val user: User, val target: String, val type: String, val content: String) : IrcEvent(metadata)
88 103
 
89 104
 /** Raised when a user quits. */
90
-class UserQuit(time: LocalDateTime, val user: User, val reason: String = "") : IrcEvent(time)
105
+class UserQuit(metadata: EventMetadata, val user: User, val reason: String = "") : IrcEvent(metadata)
91 106
 
92 107
 /** Raised when a user changes nickname. */
93
-class UserNickChanged(time: LocalDateTime, val user: User, val newNick: String) : IrcEvent(time)
108
+class UserNickChanged(metadata: EventMetadata, val user: User, val newNick: String) : IrcEvent(metadata)
94 109
 
95 110
 /**
96 111
  * Raised when a user's account changes (i.e., they auth'd or deauth'd with services).
97 112
  *
98 113
  * This event is only raised if the server supports the `account-notify` capability.
99 114
  */
100
-class UserAccountChanged(time: LocalDateTime, val user: User, val newAccount: String?) : IrcEvent(time)
115
+class UserAccountChanged(metadata: EventMetadata, val user: User, val newAccount: String?) : IrcEvent(metadata)
101 116
 
102 117
 /** Raised when available server capabilities are received. More batches may follow. */
103
-class ServerCapabilitiesReceived(time: LocalDateTime, val capabilities: Map<Capability, String>) : IrcEvent(time)
118
+class ServerCapabilitiesReceived(metadata: EventMetadata, val capabilities: Map<Capability, String>) : IrcEvent(metadata)
104 119
 
105 120
 /** Raised when our requested capabilities are acknowledged. More batches may follow. */
106
-class ServerCapabilitiesAcknowledged(time: LocalDateTime, val capabilities: Map<Capability, String>) : IrcEvent(time)
121
+class ServerCapabilitiesAcknowledged(metadata: EventMetadata, val capabilities: Map<Capability, String>) : IrcEvent(metadata)
107 122
 
108 123
 /** Raised when the server has finished sending us capabilities. */
109
-class ServerCapabilitiesFinished(time: LocalDateTime) : IrcEvent(time)
124
+class ServerCapabilitiesFinished(metadata: EventMetadata) : IrcEvent(metadata)
110 125
 
111 126
 /** Raised when a line of the Message Of the Day has been received. */
112
-class MotdLineReceived(time: LocalDateTime, val line: String, val first: Boolean = false) : IrcEvent(time)
127
+class MotdLineReceived(metadata: EventMetadata, val line: String, val first: Boolean = false) : IrcEvent(metadata)
113 128
 
114 129
 /** Raised when a Message Of the Day has completed. */
115
-class MotdFinished(time: LocalDateTime, val missing: Boolean = false) : IrcEvent(time)
130
+class MotdFinished(metadata: EventMetadata, val missing: Boolean = false) : IrcEvent(metadata)
116 131
 
117 132
 /**
118 133
  * Raised when a mode change occurs.
@@ -121,13 +136,19 @@ class MotdFinished(time: LocalDateTime, val missing: Boolean = false) : IrcEvent
121 136
  * and the given modes are thus exhaustive. Otherwise, the modes are a sequence of changes to apply to the existing
122 137
  * state.
123 138
  */
124
-class ModeChanged(time: LocalDateTime, val target: String, val modes: String, val arguments: Array<String>, val discovered: Boolean = false) : IrcEvent(time)
139
+class ModeChanged(metadata: EventMetadata, val target: String, val modes: String, val arguments: Array<String>, val discovered: Boolean = false) : IrcEvent(metadata)
125 140
 
126 141
 /** Raised when an AUTHENTICATION message is received. [argument] is `null` if the server sent an empty reply ("+") */
127
-class AuthenticationMessage(time: LocalDateTime, val argument: String?) : IrcEvent(time)
142
+class AuthenticationMessage(metadata: EventMetadata, val argument: String?) : IrcEvent(metadata)
128 143
 
129 144
 /** Raised when a SASL attempt finishes, successfully or otherwise. */
130
-class SaslFinished(time: LocalDateTime, var success: Boolean) : IrcEvent(time)
145
+class SaslFinished(metadata: EventMetadata, var success: Boolean) : IrcEvent(metadata)
131 146
 
132 147
 /** Raised when the server says our SASL mechanism isn't available, but gives us a list of others. */
133
-class SaslMechanismNotAvailableError(time: LocalDateTime, var mechanisms: Collection<String>) : IrcEvent(time)
148
+class SaslMechanismNotAvailableError(metadata: EventMetadata, var mechanisms: Collection<String>) : IrcEvent(metadata)
149
+
150
+/** Indicates a batch of messages has begun. */
151
+class BatchStarted(metadata: EventMetadata, val referenceId: String, val batchType: String, val params: Array<String>) : IrcEvent(metadata)
152
+
153
+/** Indicates a batch of messages has finished. */
154
+class BatchFinished(metadata: EventMetadata, val referenceId: String) : IrcEvent(metadata)

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/events/handlers/ChannelStateHandler.kt View File

@@ -105,7 +105,7 @@ internal class ChannelStateHandler : EventHandler {
105 105
 
106 106
     private fun handleTopicChanged(client: IrcClient, event: ChannelTopicChanged) {
107 107
         client.channelState[event.channel]?.let {
108
-            it.topic = ChannelTopic(event.topic, event.user, event.time)
108
+            it.topic = ChannelTopic(event.topic, event.user, event.metadata.time)
109 109
         }
110 110
     }
111 111
 

+ 2
- 2
src/main/kotlin/com/dmdirc/ktirc/events/mutators/ChannelFanOutMutator.kt View File

@@ -19,7 +19,7 @@ internal class ChannelFanOutMutator : EventMutator {
19 19
     private suspend fun SequenceScope<IrcEvent>.handleQuit(client: IrcClient, event: UserQuit) {
20 20
         client.channelState.forEach {
21 21
             if (it.users.contains(event.user.nickname)) {
22
-                yield(ChannelQuit(event.time, event.user, it.name, event.reason))
22
+                yield(ChannelQuit(event.metadata, event.user, it.name, event.reason))
23 23
             }
24 24
         }
25 25
     }
@@ -28,7 +28,7 @@ internal class ChannelFanOutMutator : EventMutator {
28 28
         client.channelState.forEach {
29 29
             it.users[event.user.nickname]?.let { chanUser ->
30 30
                 chanUser.nickname = event.newNick
31
-                yield(ChannelNickChanged(event.time, event.user, it.name, event.newNick))
31
+                yield(ChannelNickChanged(event.metadata, event.user, it.name, event.newNick))
32 32
             }
33 33
         }
34 34
     }

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/events/mutators/ServerReadyMutator.kt View File

@@ -28,7 +28,7 @@ internal class ServerReadyMutator : EventMutator {
28 28
         if (client.serverState.receivedWelcome
29 29
                 && client.serverState.status == ServerStatus.Negotiating
30 30
                 && event::class !in excludedEvents) {
31
-            yield(ServerReady(event.time))
31
+            yield(ServerReady(event.metadata))
32 32
         }
33 33
         yield(event)
34 34
     }.toList()

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/AccountProcessor.kt View File

@@ -8,7 +8,7 @@ internal class AccountProcessor : MessageProcessor {
8 8
     override val commands = arrayOf("ACCOUNT")
9 9
 
10 10
     override fun process(message: IrcMessage) = message.sourceUser?.let { user ->
11
-        listOf(UserAccountChanged(message.time, user, message.accountName))
11
+        listOf(UserAccountChanged(message.metadata, user, message.accountName))
12 12
     } ?: emptyList()
13 13
 
14 14
     private val IrcMessage.accountName

+ 4
- 4
src/main/kotlin/com/dmdirc/ktirc/messages/AuthenticationProcessor.kt View File

@@ -10,10 +10,10 @@ internal class AuthenticationProcessor : MessageProcessor {
10 10
     override val commands = arrayOf("AUTHENTICATE", RPL_SASLSUCCESS, ERR_SASLFAIL, RPL_SASLMECHS)
11 11
 
12 12
     override fun process(message: IrcMessage) = when(message.command) {
13
-        "AUTHENTICATE" -> listOf(AuthenticationMessage(message.time, message.authenticateArgument))
14
-        RPL_SASLSUCCESS -> listOf(SaslFinished(message.time, true))
15
-        ERR_SASLFAIL -> listOf(SaslFinished(message.time, false))
16
-        RPL_SASLMECHS -> listOf(SaslMechanismNotAvailableError(message.time, message.mechanisms))
13
+        "AUTHENTICATE" -> listOf(AuthenticationMessage(message.metadata, message.authenticateArgument))
14
+        RPL_SASLSUCCESS -> listOf(SaslFinished(message.metadata, true))
15
+        ERR_SASLFAIL -> listOf(SaslFinished(message.metadata, false))
16
+        RPL_SASLMECHS -> listOf(SaslMechanismNotAvailableError(message.metadata, message.mechanisms))
17 17
         else -> emptyList()
18 18
     }
19 19
 

+ 14
- 0
src/main/kotlin/com/dmdirc/ktirc/messages/BatchProcessor.kt View File

@@ -0,0 +1,14 @@
1
+package com.dmdirc.ktirc.messages
2
+
3
+import com.dmdirc.ktirc.events.IrcEvent
4
+import com.dmdirc.ktirc.model.IrcMessage
5
+
6
+internal class BatchProcessor : MessageProcessor {
7
+
8
+    override val commands = arrayOf("BATCH")
9
+
10
+    override fun process(message: IrcMessage): List<IrcEvent> {
11
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
12
+    }
13
+
14
+}

+ 6
- 6
src/main/kotlin/com/dmdirc/ktirc/messages/CapabilityProcessor.kt View File

@@ -1,12 +1,12 @@
1 1
 package com.dmdirc.ktirc.messages
2 2
 
3
+import com.dmdirc.ktirc.events.EventMetadata
3 4
 import com.dmdirc.ktirc.events.ServerCapabilitiesAcknowledged
4 5
 import com.dmdirc.ktirc.events.ServerCapabilitiesFinished
5 6
 import com.dmdirc.ktirc.events.ServerCapabilitiesReceived
6 7
 import com.dmdirc.ktirc.model.IrcMessage
7 8
 import com.dmdirc.ktirc.model.capabilities
8 9
 import com.dmdirc.ktirc.util.logger
9
-import java.time.LocalDateTime
10 10
 
11 11
 internal class CapabilityProcessor : MessageProcessor {
12 12
 
@@ -15,15 +15,15 @@ internal class CapabilityProcessor : MessageProcessor {
15 15
     override val commands = arrayOf("CAP")
16 16
 
17 17
     override fun process(message: IrcMessage) = when (message.subCommand) {
18
-        "LS" -> handleList(message.time, message.subCommandArguments)
19
-        "ACK" -> listOf(ServerCapabilitiesAcknowledged(message.time, message.params.capabilities))
18
+        "LS" -> handleList(message.metadata, message.subCommandArguments)
19
+        "ACK" -> listOf(ServerCapabilitiesAcknowledged(message.metadata, message.params.capabilities))
20 20
         else -> emptyList()
21 21
     }
22 22
 
23
-    private fun handleList(time: LocalDateTime, lsParams: List<ByteArray>) = sequence {
24
-        yield(ServerCapabilitiesReceived(time, lsParams.capabilities))
23
+    private fun handleList(metadata: EventMetadata, lsParams: List<ByteArray>) = sequence {
24
+        yield(ServerCapabilitiesReceived(metadata, lsParams.capabilities))
25 25
         if (lsParams.size < 2 || String(lsParams[0]) != "*") {
26
-            yield(ServerCapabilitiesFinished(time))
26
+            yield(ServerCapabilitiesFinished(metadata))
27 27
         }
28 28
     }.toList()
29 29
 

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/ISupportProcessor.kt View File

@@ -15,7 +15,7 @@ internal class ISupportProcessor : MessageProcessor {
15 15
 
16 16
     override val commands = arrayOf(RPL_ISUPPORT)
17 17
 
18
-    override fun process(message: IrcMessage) = listOf(ServerFeaturesUpdated(message.time, ServerFeatureMap().apply {
18
+    override fun process(message: IrcMessage) = listOf(ServerFeaturesUpdated(message.metadata, ServerFeatureMap().apply {
19 19
         // Ignore the first (nickname) and last ("are supported by this server") params
20 20
         for (i in 1 until message.params.size - 1) {
21 21
             parseParam(message.params[i])

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/JoinProcessor.kt View File

@@ -10,7 +10,7 @@ internal class JoinProcessor : MessageProcessor {
10 10
 
11 11
     override fun process(message: IrcMessage) = message.sourceUser?.let { user ->
12 12
         user.addExtendedJoinFields(message.params)
13
-        listOf(ChannelJoined(message.time, user, String(message.params[0])))
13
+        listOf(ChannelJoined(message.metadata, user, String(message.params[0])))
14 14
     } ?: emptyList()
15 15
 
16 16
     private fun User.addExtendedJoinFields(params: List<ByteArray>) {

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/KickProcessor.kt View File

@@ -8,7 +8,7 @@ internal class KickProcessor : MessageProcessor {
8 8
     override val commands = arrayOf("KICK")
9 9
 
10 10
     override fun process(message: IrcMessage) = message.sourceUser?.let { user ->
11
-        listOf(ChannelUserKicked(message.time, user, message.channel, message.victim, message.reason))
11
+        listOf(ChannelUserKicked(message.metadata, user, message.channel, message.victim, message.reason))
12 12
     } ?: emptyList()
13 13
 
14 14
     private val IrcMessage.channel

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/ModeProcessor.kt View File

@@ -11,7 +11,7 @@ internal class ModeProcessor : MessageProcessor {
11 11
         val isDiscovery = message.command == RPL_CHANNELMODEIS || message.command == RPL_UMODEIS
12 12
         val paramOffset = if (message.command == RPL_CHANNELMODEIS) 1 else 0
13 13
         return listOf(ModeChanged(
14
-                message.time,
14
+                message.metadata,
15 15
                 target = String(message.params[paramOffset]),
16 16
                 modes = String(message.params[paramOffset + 1]),
17 17
                 arguments = message.params.takeLast(message.params.size - paramOffset - 2).map { String(it) }.toTypedArray(),

+ 4
- 4
src/main/kotlin/com/dmdirc/ktirc/messages/MotdProcessor.kt View File

@@ -10,10 +10,10 @@ internal class MotdProcessor : MessageProcessor {
10 10
 
11 11
     override fun process(message: IrcMessage) = sequence {
12 12
         when (message.command) {
13
-            RPL_MOTDSTART -> yield(MotdLineReceived(message.time, String(message.params[1]), true))
14
-            RPL_MOTD -> yield(MotdLineReceived(message.time, String(message.params[1])))
15
-            ERR_NOMOTD -> yield(MotdFinished(message.time, missing = true))
16
-            RPL_ENDOFMOTD -> yield(MotdFinished(message.time))
13
+            RPL_MOTDSTART -> yield(MotdLineReceived(message.metadata, String(message.params[1]), true))
14
+            RPL_MOTD -> yield(MotdLineReceived(message.metadata, String(message.params[1])))
15
+            ERR_NOMOTD -> yield(MotdFinished(message.metadata, missing = true))
16
+            RPL_ENDOFMOTD -> yield(MotdFinished(message.metadata))
17 17
         }
18 18
     }.toList()
19 19
 

+ 2
- 2
src/main/kotlin/com/dmdirc/ktirc/messages/NamesProcessor.kt View File

@@ -9,8 +9,8 @@ internal class NamesProcessor : MessageProcessor {
9 9
     override val commands = arrayOf("353", "366")
10 10
 
11 11
     override fun process(message: IrcMessage) = when (message.command) {
12
-        "353" -> listOf(ChannelNamesReceived(message.time, String(message.params[2]), String(message.params[3]).split(' ')))
13
-        "366" -> listOf(ChannelNamesFinished(message.time, String(message.params[1])))
12
+        "353" -> listOf(ChannelNamesReceived(message.metadata, String(message.params[2]), String(message.params[3]).split(' ')))
13
+        "366" -> listOf(ChannelNamesFinished(message.metadata, String(message.params[1])))
14 14
         else -> emptyList()
15 15
     }
16 16
 

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/NickProcessor.kt View File

@@ -8,7 +8,7 @@ internal class NickProcessor : MessageProcessor {
8 8
     override val commands = arrayOf("NICK")
9 9
 
10 10
     override fun process(message: IrcMessage) =
11
-            message.sourceUser?.let { listOf(UserNickChanged(message.time, it, String(message.params[0]))) }
11
+            message.sourceUser?.let { listOf(UserNickChanged(message.metadata, it, String(message.params[0]))) }
12 12
                     ?: emptyList()
13 13
 
14 14
 }

+ 2
- 2
src/main/kotlin/com/dmdirc/ktirc/messages/NoticeProcessor.kt View File

@@ -12,7 +12,7 @@ internal class NoticeProcessor : MessageProcessor {
12 12
 
13 13
     override fun process(message: IrcMessage) = when {
14 14
             message.isCtcp() -> handleCtcp(message,  message.sourceUser)
15
-            else -> listOf(NoticeReceived(message.time,  message.sourceUser ?: User("*"), String(message.params[0]), String(message.params[1])))
15
+            else -> listOf(NoticeReceived(message.metadata,  message.sourceUser ?: User("*"), String(message.params[0]), String(message.params[1])))
16 16
         }
17 17
 
18 18
     private fun handleCtcp(message: IrcMessage, user: User?): List<IrcEvent> {
@@ -20,7 +20,7 @@ internal class NoticeProcessor : MessageProcessor {
20 20
         val content = String(message.params[1]).substring(1 until message.params[1].size - 1)
21 21
         val parts = content.split(' ', limit=2)
22 22
         val body = if (parts.size == 2) parts[1] else ""
23
-        return listOf(CtcpReplyReceived(message.time, user, String(message.params[0]), parts[0], body))
23
+        return listOf(CtcpReplyReceived(message.metadata, user, String(message.params[0]), parts[0], body))
24 24
     }
25 25
 
26 26
     private fun IrcMessage.isCtcp() = params[1].size > 2 && params[1][0] == CTCP_BYTE && params[1][params[1].size - 1] == CTCP_BYTE

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/PartProcessor.kt View File

@@ -8,7 +8,7 @@ internal class PartProcessor : MessageProcessor {
8 8
     override val commands = arrayOf("PART")
9 9
 
10 10
     override fun process(message: IrcMessage) = message.sourceUser?.let { user ->
11
-        listOf(ChannelParted(message.time, user, message.channel, message.reason))
11
+        listOf(ChannelParted(message.metadata, user, message.channel, message.reason))
12 12
     } ?: emptyList()
13 13
 
14 14
     private val IrcMessage.channel

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/PingProcessor.kt View File

@@ -7,6 +7,6 @@ internal class PingProcessor : MessageProcessor {
7 7
 
8 8
     override val commands = arrayOf("PING")
9 9
 
10
-    override fun process(message: IrcMessage) = listOf(PingReceived(message.time, message.params[0]))
10
+    override fun process(message: IrcMessage) = listOf(PingReceived(message.metadata, message.params[0]))
11 11
 
12 12
 }

+ 3
- 3
src/main/kotlin/com/dmdirc/ktirc/messages/PrivmsgProcessor.kt View File

@@ -15,7 +15,7 @@ internal class PrivmsgProcessor : MessageProcessor {
15 15
     override fun process(message: IrcMessage) = message.sourceUser?.let { user ->
16 16
         listOf(when {
17 17
             message.isCtcp() -> handleCtcp(message, user)
18
-            else -> MessageReceived(message.time, user, String(message.params[0]), String(message.params[1]), message.messageId)
18
+            else -> MessageReceived(message.metadata, user, String(message.params[0]), String(message.params[1]), message.messageId)
19 19
         })
20 20
     } ?: emptyList()
21 21
 
@@ -24,8 +24,8 @@ internal class PrivmsgProcessor : MessageProcessor {
24 24
         val parts = content.split(' ', limit=2)
25 25
         val body = if (parts.size == 2) parts[1] else ""
26 26
         return when (parts[0].toUpperCase()) {
27
-            "ACTION" -> ActionReceived(message.time, user, String(message.params[0]), body, message.messageId)
28
-            else -> CtcpReceived(message.time, user, String(message.params[0]), parts[0], body)
27
+            "ACTION" -> ActionReceived(message.metadata, user, String(message.params[0]), body, message.messageId)
28
+            else -> CtcpReceived(message.metadata, user, String(message.params[0]), parts[0], body)
29 29
         }
30 30
     }
31 31
 

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/QuitProcessor.kt View File

@@ -8,7 +8,7 @@ internal class QuitProcessor : MessageProcessor {
8 8
     override val commands = arrayOf("QUIT")
9 9
 
10 10
     override fun process(message: IrcMessage) = message.sourceUser?.let { user ->
11
-        listOf(UserQuit(message.time, user, message.reason))
11
+        listOf(UserQuit(message.metadata, user, message.reason))
12 12
     } ?: emptyList()
13 13
 
14 14
     private val IrcMessage.reason

+ 4
- 4
src/main/kotlin/com/dmdirc/ktirc/messages/TopicProcessor.kt View File

@@ -15,11 +15,11 @@ internal class TopicProcessor : MessageProcessor {
15 15
 
16 16
     override fun process(message: IrcMessage) = sequence {
17 17
         when (message.command) {
18
-            RPL_TOPIC -> yield(ChannelTopicDiscovered(message.time, message.channel, String(message.params[2])))
19
-            RPL_NOTOPIC -> yield(ChannelTopicDiscovered(message.time, message.channel, null))
18
+            RPL_TOPIC -> yield(ChannelTopicDiscovered(message.metadata, message.channel, String(message.params[2])))
19
+            RPL_NOTOPIC -> yield(ChannelTopicDiscovered(message.metadata, message.channel, null))
20 20
             RPL_TOPICWHOTIME -> yield(ChannelTopicMetadataDiscovered(
21
-                    message.time, message.channel, message.params[2].asUser(), message.topicSetTime))
22
-            "TOPIC" -> message.sourceUser?.let { yield(ChannelTopicChanged(message.time, it, String(message.params[0]), String(message.params[1]))) }
21
+                    message.metadata, message.channel, message.params[2].asUser(), message.topicSetTime))
22
+            "TOPIC" -> message.sourceUser?.let { yield(ChannelTopicChanged(message.metadata, it, String(message.params[0]), String(message.params[1]))) }
23 23
         }
24 24
     }.toList()
25 25
 

+ 1
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/WelcomeProcessor.kt View File

@@ -7,7 +7,7 @@ internal class WelcomeProcessor : MessageProcessor {
7 7
 
8 8
     override val commands = arrayOf(RPL_WELCOME)
9 9
 
10
-    override fun process(message: IrcMessage) = listOf(ServerWelcome(message.time, message.serverName(), String(message.params[0])))
10
+    override fun process(message: IrcMessage) = listOf(ServerWelcome(message.metadata, message.serverName(), String(message.params[0])))
11 11
 
12 12
     private fun IrcMessage.serverName() = prefix?.let { String(it) } ?: ""
13 13
 

+ 3
- 0
src/main/kotlin/com/dmdirc/ktirc/model/CapabilitiesState.kt View File

@@ -83,6 +83,9 @@ sealed class Capability(val name: String) {
83 83
     /** Messages sent by the client are echo'd back on successful delivery. */
84 84
     object EchoMessages : Capability("echo-message")
85 85
 
86
+    /** Messages can be sent in batches, and potentially handled differently by the client. */
87
+    object Batch : Capability("batch")
88
+
86 89
     // Capabilities that notify us of changes to other clients:
87 90
     /** Receive a notification when a user's account changes. */
88 91
     object AccountChangeMessages : Capability("account-notify")

+ 21
- 6
src/main/kotlin/com/dmdirc/ktirc/model/IrcMessage.kt View File

@@ -1,5 +1,6 @@
1 1
 package com.dmdirc.ktirc.model
2 2
 
3
+import com.dmdirc.ktirc.events.EventMetadata
3 4
 import com.dmdirc.ktirc.util.currentTimeProvider
4 5
 import com.dmdirc.ktirc.util.currentTimeZoneProvider
5 6
 import java.time.Instant
@@ -8,14 +9,10 @@ import java.time.LocalDateTime
8 9
 /**
9 10
  * Represents an IRC protocol message.
10 11
  */
11
-class IrcMessage(val tags: Map<MessageTag, String>, val prefix: ByteArray?, val command: String, val params: List<ByteArray>) {
12
+internal class IrcMessage(val tags: Map<MessageTag, String>, val prefix: ByteArray?, val command: String, val params: List<ByteArray>) {
12 13
 
13 14
     /** The time at which the message was sent, or our best guess at it. */
14
-    val time: LocalDateTime = if (MessageTag.ServerTime in tags) {
15
-        LocalDateTime.ofInstant(Instant.parse(tags[MessageTag.ServerTime]), currentTimeZoneProvider())
16
-    } else {
17
-        currentTimeProvider()
18
-    }
15
+    val metadata = EventMetadata(time, batchId)
19 16
 
20 17
     /** The user that generated the message, if any. */
21 18
     val sourceUser by lazy {
@@ -24,20 +21,38 @@ class IrcMessage(val tags: Map<MessageTag, String>, val prefix: ByteArray?, val
24 21
         }
25 22
     }
26 23
 
24
+    private val time
25
+        get() = if (MessageTag.ServerTime in tags) {
26
+            LocalDateTime.ofInstant(Instant.parse(tags[MessageTag.ServerTime]), currentTimeZoneProvider())
27
+        } else {
28
+            currentTimeProvider()
29
+        }
30
+
31
+    private val batchId
32
+        get() = tags[MessageTag.Batch]
33
+
27 34
 }
28 35
 
29 36
 /**
30 37
  * Supported tags that may be applied to messages.
31 38
  */
39
+@Suppress("unused")
32 40
 sealed class MessageTag(val name: String) {
33 41
     /** Specifies the account name of the user, if the `account-tag` capability is negotiated. */
34 42
     object AccountName : MessageTag("account")
43
+
44
+    /** Specifies the ID that a batch message belongs to. */
45
+    object Batch : MessageTag("batch")
46
+
35 47
     /** Specifies the time the server received the message, if the `server-time` capability is negotiated. */
36 48
     object ServerTime : MessageTag("time")
49
+
37 50
     /** A unique ID for the message, used to reply, react, edit, delete, etc. */
38 51
     object MessageId : MessageTag("draft/msgid")
52
+
39 53
     /** Used to identify a message ID that was replied to, to enable threaded conversations. */
40 54
     object Reply : MessageTag("+draft/reply")
55
+
41 56
     /** Used to specify a slack-like reaction to another message. */
42 57
     object React : MessageTag("+draft/react")
43 58
 }

+ 2
- 2
src/test/kotlin/com/dmdirc/ktirc/IrcClientImplTest.kt View File

@@ -111,10 +111,10 @@ internal class IrcClientImplTest {
111 111
         verify(mockEventHandler, timeout(500).atLeast(2)).invoke(captor.capture())
112 112
 
113 113
         assertTrue(captor.firstValue is ServerConnecting)
114
-        assertEquals(TestConstants.time, captor.firstValue.time)
114
+        assertEquals(TestConstants.time, captor.firstValue.metadata.time)
115 115
 
116 116
         assertTrue(captor.secondValue is ServerConnected)
117
-        assertEquals(TestConstants.time, captor.secondValue.time)
117
+        assertEquals(TestConstants.time, captor.secondValue.metadata.time)
118 118
     }
119 119
 
120 120
     @Test

+ 10
- 10
src/test/kotlin/com/dmdirc/ktirc/events/EventUtilsTest.kt View File

@@ -29,7 +29,7 @@ internal class EventUtilsTest {
29 29
 
30 30
     @Test
31 31
     fun `ChannelNamesReceived#toModesAndUsers parses nicknames and mode prefixes`() {
32
-        val event = ChannelNamesReceived(TestConstants.time, "#thegibson", listOf(
32
+        val event = ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf(
33 33
                 "@+acidBurn", "@zeroCool", "thePlague"
34 34
         ))
35 35
 
@@ -48,7 +48,7 @@ internal class EventUtilsTest {
48 48
 
49 49
     @Test
50 50
     fun `ChannelNamesReceived#toModesAndUsers parses extended joins with prefixes`() {
51
-        val event = ChannelNamesReceived(TestConstants.time, "#thegibson", listOf(
51
+        val event = ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf(
52 52
                 "@+acidBurn!libby@root.localhost", "zeroCool!dade@root.localhost"
53 53
         ))
54 54
 
@@ -69,7 +69,7 @@ internal class EventUtilsTest {
69 69
     @Test
70 70
     fun `reply sends response to user when message is private`() {
71 71
         serverState.localNickname = "zeroCool"
72
-        val message = MessageReceived(TestConstants.time, User("acidBurn"), "Zerocool", "Hack the planet!")
72
+        val message = MessageReceived(EventMetadata(TestConstants.time), User("acidBurn"), "Zerocool", "Hack the planet!")
73 73
 
74 74
         ircClient.reply(message, "OK")
75 75
         verify(ircClient).send("PRIVMSG acidBurn :OK")
@@ -77,7 +77,7 @@ internal class EventUtilsTest {
77 77
 
78 78
     @Test
79 79
     fun `reply sends unprefixed response to user when message is in a channel`() {
80
-        val message = MessageReceived(TestConstants.time, User("acidBurn"), "#TheGibson", "Hack the planet!")
80
+        val message = MessageReceived(EventMetadata(TestConstants.time), User("acidBurn"), "#TheGibson", "Hack the planet!")
81 81
 
82 82
         ircClient.reply(message, "OK")
83 83
         verify(ircClient).send("PRIVMSG #TheGibson :OK")
@@ -85,7 +85,7 @@ internal class EventUtilsTest {
85 85
 
86 86
     @Test
87 87
     fun `reply sends prefixed response to user when message is in a channel`() {
88
-        val message = MessageReceived(TestConstants.time, User("acidBurn"), "#TheGibson", "Hack the planet!")
88
+        val message = MessageReceived(EventMetadata(TestConstants.time), User("acidBurn"), "#TheGibson", "Hack the planet!")
89 89
 
90 90
         ircClient.reply(message, "OK", prefixWithNickname = true)
91 91
         verify(ircClient).send("PRIVMSG #TheGibson :acidBurn: OK")
@@ -94,7 +94,7 @@ internal class EventUtilsTest {
94 94
     @Test
95 95
     fun `reply sends response with message ID to user when message is private`() {
96 96
         serverState.localNickname = "zeroCool"
97
-        val message = MessageReceived(TestConstants.time, User("acidBurn"), "Zerocool", "Hack the planet!", "abc123")
97
+        val message = MessageReceived(EventMetadata(TestConstants.time), User("acidBurn"), "Zerocool", "Hack the planet!", "abc123")
98 98
 
99 99
         ircClient.reply(message, "OK")
100 100
         verify(ircClient).send("@+draft/reply=abc123 PRIVMSG acidBurn :OK")
@@ -102,7 +102,7 @@ internal class EventUtilsTest {
102 102
 
103 103
     @Test
104 104
     fun `reply sends unprefixed response with message ID to user when message is in a channel`() {
105
-        val message = MessageReceived(TestConstants.time, User("acidBurn"), "#TheGibson", "Hack the planet!", "abc123")
105
+        val message = MessageReceived(EventMetadata(TestConstants.time), User("acidBurn"), "#TheGibson", "Hack the planet!", "abc123")
106 106
 
107 107
         ircClient.reply(message, "OK")
108 108
         verify(ircClient).send("@+draft/reply=abc123 PRIVMSG #TheGibson :OK")
@@ -110,7 +110,7 @@ internal class EventUtilsTest {
110 110
 
111 111
     @Test
112 112
     fun `reply sends prefixed response with message ID to user when message is in a channel`() {
113
-        val message = MessageReceived(TestConstants.time, User("acidBurn"), "#TheGibson", "Hack the planet!", "abc123")
113
+        val message = MessageReceived(EventMetadata(TestConstants.time), User("acidBurn"), "#TheGibson", "Hack the planet!", "abc123")
114 114
 
115 115
         ircClient.reply(message, "OK", prefixWithNickname = true)
116 116
         verify(ircClient).send("@+draft/reply=abc123 PRIVMSG #TheGibson :acidBurn: OK")
@@ -120,7 +120,7 @@ internal class EventUtilsTest {
120 120
     @Test
121 121
     fun `react sends response to user when message is private`() {
122 122
         serverState.localNickname = "zeroCool"
123
-        val message = MessageReceived(TestConstants.time, User("acidBurn"), "Zerocool", "Hack the planet!", "msgId")
123
+        val message = MessageReceived(EventMetadata(TestConstants.time), User("acidBurn"), "Zerocool", "Hack the planet!", "msgId")
124 124
 
125 125
         ircClient.react(message, ":P")
126 126
         verify(ircClient).send("@+draft/react=:P;+draft/reply=msgId TAGMSG acidBurn")
@@ -128,7 +128,7 @@ internal class EventUtilsTest {
128 128
 
129 129
     @Test
130 130
     fun `react sends unprefixed response to user when message is in a channel`() {
131
-        val message = MessageReceived(TestConstants.time, User("acidBurn"), "#TheGibson", "Hack the planet!", "msgId")
131
+        val message = MessageReceived(EventMetadata(TestConstants.time), User("acidBurn"), "#TheGibson", "Hack the planet!", "msgId")
132 132
 
133 133
         ircClient.react(message, ":P")
134 134
         verify(ircClient).send("@+draft/react=:P;+draft/reply=msgId TAGMSG #TheGibson")

+ 27
- 27
src/test/kotlin/com/dmdirc/ktirc/events/handlers/CapabilitiesHandlerTest.kt View File

@@ -38,7 +38,7 @@ internal class CapabilitiesHandlerTest {
38 38
 
39 39
     @Test
40 40
     fun `adds new capabilities to the state`() {
41
-        handler.processEvent(ircClient, ServerCapabilitiesReceived(TestConstants.time, hashMapOf(
41
+        handler.processEvent(ircClient, ServerCapabilitiesReceived(EventMetadata(TestConstants.time), hashMapOf(
42 42
                 Capability.EchoMessages to "",
43 43
                 Capability.HostsInNamesReply to "123"
44 44
         )))
@@ -52,7 +52,7 @@ internal class CapabilitiesHandlerTest {
52 52
     fun `updates negotiation state when capabilities finished`() {
53 53
         serverState.capabilities.advertisedCapabilities[Capability.EchoMessages] = ""
54 54
 
55
-        handler.processEvent(ircClient, ServerCapabilitiesFinished(TestConstants.time))
55
+        handler.processEvent(ircClient, ServerCapabilitiesFinished(EventMetadata(TestConstants.time)))
56 56
 
57 57
         assertEquals(CapabilitiesNegotiationState.AWAITING_ACK, serverState.capabilities.negotiationState)
58 58
     }
@@ -62,28 +62,28 @@ internal class CapabilitiesHandlerTest {
62 62
         serverState.capabilities.advertisedCapabilities[Capability.EchoMessages] = ""
63 63
         serverState.capabilities.advertisedCapabilities[Capability.AccountChangeMessages] = ""
64 64
 
65
-        handler.processEvent(ircClient, ServerCapabilitiesFinished(TestConstants.time))
65
+        handler.processEvent(ircClient, ServerCapabilitiesFinished(EventMetadata(TestConstants.time)))
66 66
 
67 67
         verify(ircClient).send(argThat { equals("CAP REQ :echo-message account-notify") || equals("CAP REQ :account-notify echo-message") })
68 68
     }
69 69
 
70 70
     @Test
71 71
     fun `sends END when blank capabilities received`() {
72
-        handler.processEvent(ircClient, ServerCapabilitiesFinished(TestConstants.time))
72
+        handler.processEvent(ircClient, ServerCapabilitiesFinished(EventMetadata(TestConstants.time)))
73 73
 
74 74
         verify(ircClient).send("CAP END")
75 75
     }
76 76
 
77 77
     @Test
78 78
     fun `updates negotiation when blank capabilities received`() {
79
-        handler.processEvent(ircClient, ServerCapabilitiesFinished(TestConstants.time))
79
+        handler.processEvent(ircClient, ServerCapabilitiesFinished(EventMetadata(TestConstants.time)))
80 80
 
81 81
         assertEquals(CapabilitiesNegotiationState.FINISHED, serverState.capabilities.negotiationState)
82 82
     }
83 83
 
84 84
     @Test
85 85
     fun `sends END when capabilities acknowledged and no enabled mechanisms`() {
86
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
86
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
87 87
                 Capability.EchoMessages to "",
88 88
                 Capability.HostsInNamesReply to ""
89 89
         )))
@@ -94,7 +94,7 @@ internal class CapabilitiesHandlerTest {
94 94
     @Test
95 95
     fun `sends END when capabilities acknowledged and no sasl state`() {
96 96
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
97
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
97
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
98 98
                 Capability.EchoMessages to "",
99 99
                 Capability.HostsInNamesReply to ""
100 100
         )))
@@ -106,7 +106,7 @@ internal class CapabilitiesHandlerTest {
106 106
     fun `sends END when capabilities acknowledged and no shared mechanism`() {
107 107
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
108 108
         serverState.capabilities.advertisedCapabilities[Capability.SaslAuthentication] = "fake1,fake2"
109
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
109
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
110 110
                 Capability.SaslAuthentication to "",
111 111
                 Capability.HostsInNamesReply to ""
112 112
         )))
@@ -118,7 +118,7 @@ internal class CapabilitiesHandlerTest {
118 118
     fun `sets current SASL mechanism when capabilities acknowledged with shared mechanism`() {
119 119
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
120 120
         serverState.capabilities.advertisedCapabilities[Capability.SaslAuthentication] = "mech1,fake2"
121
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
121
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
122 122
                 Capability.SaslAuthentication to "",
123 123
                 Capability.HostsInNamesReply to ""
124 124
         )))
@@ -130,7 +130,7 @@ internal class CapabilitiesHandlerTest {
130 130
     fun `sets current SASL mechanism when capabilities acknowledged with no declared mechanisms`() {
131 131
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
132 132
         serverState.capabilities.advertisedCapabilities[Capability.SaslAuthentication] = ""
133
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
133
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
134 134
                 Capability.SaslAuthentication to "",
135 135
                 Capability.HostsInNamesReply to ""
136 136
         )))
@@ -142,7 +142,7 @@ internal class CapabilitiesHandlerTest {
142 142
     fun `sends authenticate when capabilities acknowledged with shared mechanism`() {
143 143
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
144 144
         serverState.capabilities.advertisedCapabilities[Capability.SaslAuthentication] = "mech1,fake2"
145
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
145
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
146 146
                 Capability.SaslAuthentication to "",
147 147
                 Capability.HostsInNamesReply to ""
148 148
         )))
@@ -154,7 +154,7 @@ internal class CapabilitiesHandlerTest {
154 154
     fun `sends authenticate when capabilities acknowledged with no declared mechanisms`() {
155 155
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
156 156
         serverState.capabilities.advertisedCapabilities[Capability.SaslAuthentication] = ""
157
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
157
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
158 158
                 Capability.SaslAuthentication to "",
159 159
                 Capability.HostsInNamesReply to ""
160 160
         )))
@@ -166,7 +166,7 @@ internal class CapabilitiesHandlerTest {
166 166
     fun `updates negotiation state when capabilities acknowledged with shared mechanism`() {
167 167
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
168 168
         serverState.capabilities.advertisedCapabilities[Capability.SaslAuthentication] = "mech1,fake2"
169
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
169
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
170 170
                 Capability.SaslAuthentication to "",
171 171
                 Capability.HostsInNamesReply to ""
172 172
         )))
@@ -176,7 +176,7 @@ internal class CapabilitiesHandlerTest {
176 176
 
177 177
     @Test
178 178
     fun `updates negotiation state when capabilities acknowledged`() {
179
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
179
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
180 180
                 Capability.EchoMessages to "",
181 181
                 Capability.HostsInNamesReply to "123"
182 182
         )))
@@ -186,7 +186,7 @@ internal class CapabilitiesHandlerTest {
186 186
 
187 187
     @Test
188 188
     fun `stores enabled caps when capabilities acknowledged`() {
189
-        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(TestConstants.time, hashMapOf(
189
+        handler.processEvent(ircClient, ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), hashMapOf(
190 190
                 Capability.EchoMessages to "",
191 191
                 Capability.HostsInNamesReply to "123"
192 192
         )))
@@ -199,7 +199,7 @@ internal class CapabilitiesHandlerTest {
199 199
     @Test
200 200
     fun `aborts authentication attempt if not expecting one`() {
201 201
         serverState.sasl.currentMechanism = null
202
-        handler.processEvent(ircClient, AuthenticationMessage(TestConstants.time, "+"))
202
+        handler.processEvent(ircClient, AuthenticationMessage(EventMetadata(TestConstants.time), "+"))
203 203
 
204 204
         verify(ircClient).send("AUTHENTICATE *")
205 205
     }
@@ -209,7 +209,7 @@ internal class CapabilitiesHandlerTest {
209 209
         serverState.sasl.currentMechanism = saslMech1
210 210
 
211 211
         val argument = "ABC"
212
-        handler.processEvent(ircClient, AuthenticationMessage(TestConstants.time, argument))
212
+        handler.processEvent(ircClient, AuthenticationMessage(EventMetadata(TestConstants.time), argument))
213 213
 
214 214
         verify(saslMech1).handleAuthenticationEvent(ircClient, argument.fromBase64())
215 215
     }
@@ -219,7 +219,7 @@ internal class CapabilitiesHandlerTest {
219 219
         serverState.sasl.currentMechanism = saslMech1
220 220
 
221 221
         val argument = "A".repeat(400)
222
-        handler.processEvent(ircClient, AuthenticationMessage(TestConstants.time, argument))
222
+        handler.processEvent(ircClient, AuthenticationMessage(EventMetadata(TestConstants.time), argument))
223 223
 
224 224
         assertEquals(argument, serverState.sasl.saslBuffer)
225 225
         verify(saslMech1, never()).handleAuthenticationEvent(any(), any())
@@ -230,7 +230,7 @@ internal class CapabilitiesHandlerTest {
230 230
         serverState.sasl.currentMechanism = saslMech1
231 231
 
232 232
         serverState.sasl.saslBuffer = "A".repeat(400)
233
-        handler.processEvent(ircClient, AuthenticationMessage(TestConstants.time, "B".repeat(400)))
233
+        handler.processEvent(ircClient, AuthenticationMessage(EventMetadata(TestConstants.time), "B".repeat(400)))
234 234
 
235 235
         assertEquals("A".repeat(400) + "B".repeat(400), serverState.sasl.saslBuffer)
236 236
         verify(saslMech1, never()).handleAuthenticationEvent(any(), any())
@@ -243,7 +243,7 @@ internal class CapabilitiesHandlerTest {
243 243
         serverState.sasl.saslBuffer = "A".repeat(400)
244 244
 
245 245
         val argument = "ABCD"
246
-        handler.processEvent(ircClient, AuthenticationMessage(TestConstants.time, argument))
246
+        handler.processEvent(ircClient, AuthenticationMessage(EventMetadata(TestConstants.time), argument))
247 247
 
248 248
         val captor = argumentCaptor<ByteArray>()
249 249
         verify(saslMech1).handleAuthenticationEvent(same(ircClient), captor.capture())
@@ -256,7 +256,7 @@ internal class CapabilitiesHandlerTest {
256 256
 
257 257
         serverState.sasl.saslBuffer = "A".repeat(400)
258 258
 
259
-        handler.processEvent(ircClient, AuthenticationMessage(TestConstants.time, null))
259
+        handler.processEvent(ircClient, AuthenticationMessage(EventMetadata(TestConstants.time), null))
260 260
 
261 261
         val captor = argumentCaptor<ByteArray>()
262 262
         verify(saslMech1).handleAuthenticationEvent(same(ircClient), captor.capture())
@@ -265,14 +265,14 @@ internal class CapabilitiesHandlerTest {
265 265
 
266 266
     @Test
267 267
     fun `sends END when SASL auth finished`() {
268
-        handler.processEvent(ircClient, SaslFinished(TestConstants.time, true))
268
+        handler.processEvent(ircClient, SaslFinished(EventMetadata(TestConstants.time), true))
269 269
 
270 270
         verify(ircClient).send("CAP END")
271 271
     }
272 272
 
273 273
     @Test
274 274
     fun `sets negotiation state when SASL auth finished`() {
275
-        handler.processEvent(ircClient, SaslFinished(TestConstants.time, true))
275
+        handler.processEvent(ircClient, SaslFinished(EventMetadata(TestConstants.time), true))
276 276
 
277 277
         assertEquals(CapabilitiesNegotiationState.FINISHED, serverState.capabilities.negotiationState)
278 278
     }
@@ -285,7 +285,7 @@ internal class CapabilitiesHandlerTest {
285 285
             mechanismState = "root@thegibson"
286 286
         }
287 287
 
288
-        handler.processEvent(ircClient, SaslFinished(TestConstants.time, true))
288
+        handler.processEvent(ircClient, SaslFinished(EventMetadata(TestConstants.time), true))
289 289
 
290 290
         with (serverState.sasl) {
291 291
             assertNull(currentMechanism)
@@ -297,7 +297,7 @@ internal class CapabilitiesHandlerTest {
297 297
     @Test
298 298
     fun `sends a new authenticate request when sasl mechanism rejected and new one is acceptable`() {
299 299
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
300
-        handler.processEvent(ircClient, SaslMechanismNotAvailableError(TestConstants.time, listOf("mech1", "fake2")))
300
+        handler.processEvent(ircClient, SaslMechanismNotAvailableError(EventMetadata(TestConstants.time), listOf("mech1", "fake2")))
301 301
 
302 302
         verify(ircClient).send("AUTHENTICATE mech1")
303 303
     }
@@ -305,7 +305,7 @@ internal class CapabilitiesHandlerTest {
305 305
     @Test
306 306
     fun `sends cap end when sasl mechanism rejected and no new one is acceptable`() {
307 307
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
308
-        handler.processEvent(ircClient, SaslMechanismNotAvailableError(TestConstants.time, listOf("fake1", "fake2")))
308
+        handler.processEvent(ircClient, SaslMechanismNotAvailableError(EventMetadata(TestConstants.time), listOf("fake1", "fake2")))
309 309
 
310 310
         verify(ircClient).send("CAP END")
311 311
     }
@@ -313,7 +313,7 @@ internal class CapabilitiesHandlerTest {
313 313
     @Test
314 314
     fun `sets negotiation state when sasl mechanism rejected and no new one is acceptable`() {
315 315
         serverState.sasl.mechanisms.addAll(listOf(saslMech1, saslMech2, saslMech3))
316
-        handler.processEvent(ircClient, SaslMechanismNotAvailableError(TestConstants.time, listOf("fake1", "fake2")))
316
+        handler.processEvent(ircClient, SaslMechanismNotAvailableError(EventMetadata(TestConstants.time), listOf("fake1", "fake2")))
317 317
 
318 318
         assertEquals(CapabilitiesNegotiationState.FINISHED, serverState.capabilities.negotiationState)
319 319
     }

+ 45
- 45
src/test/kotlin/com/dmdirc/ktirc/events/handlers/ChannelStateHandlerTest.kt View File

@@ -29,13 +29,13 @@ internal class ChannelStateHandlerTest {
29 29
 
30 30
     @Test
31 31
     fun `creates new state object for local joins`() {
32
-        handler.processEvent(ircClient, ChannelJoined(TestConstants.time, User("acidburn", "libby", "root.localhost"), "#thegibson"))
32
+        handler.processEvent(ircClient, ChannelJoined(EventMetadata(TestConstants.time), User("acidburn", "libby", "root.localhost"), "#thegibson"))
33 33
         assertTrue("#thegibson" in channelStateMap)
34 34
     }
35 35
 
36 36
     @Test
37 37
     fun `does not create new state object for remote joins`() {
38
-        handler.processEvent(ircClient, ChannelJoined(TestConstants.time, User("zerocool", "dade", "root.localhost"), "#thegibson"))
38
+        handler.processEvent(ircClient, ChannelJoined(EventMetadata(TestConstants.time), User("zerocool", "dade", "root.localhost"), "#thegibson"))
39 39
         assertFalse("#thegibson" in channelStateMap)
40 40
     }
41 41
 
@@ -43,7 +43,7 @@ internal class ChannelStateHandlerTest {
43 43
     fun `adds joiners to channel state`() {
44 44
         channelStateMap += ChannelState("#thegibson") { CaseMapping.Rfc }
45 45
 
46
-        handler.processEvent(ircClient, ChannelJoined(TestConstants.time, User("zerocool", "dade", "root.localhost"), "#thegibson"))
46
+        handler.processEvent(ircClient, ChannelJoined(EventMetadata(TestConstants.time), User("zerocool", "dade", "root.localhost"), "#thegibson"))
47 47
 
48 48
         assertTrue("zerocool" in channelStateMap["#thegibson"]?.users!!)
49 49
     }
@@ -55,7 +55,7 @@ internal class ChannelStateHandlerTest {
55 55
         channel.users += ChannelUser("thePlague")
56 56
         channelStateMap += channel
57 57
 
58
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("zeroCool")))
58
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("zeroCool")))
59 59
 
60 60
         assertEquals(1, channel.users.count())
61 61
         assertNotNull(channel.users["zeroCool"])
@@ -66,9 +66,9 @@ internal class ChannelStateHandlerTest {
66 66
         val channel = ChannelState("#thegibson") { CaseMapping.Rfc }
67 67
         channelStateMap += channel
68 68
 
69
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("zeroCool")))
70
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("acidBurn")))
71
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("thePlague")))
69
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("zeroCool")))
70
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("acidBurn")))
71
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("thePlague")))
72 72
 
73 73
         assertEquals(3, channel.users.count())
74 74
         assertNotNull(channel.users["zeroCool"])
@@ -81,10 +81,10 @@ internal class ChannelStateHandlerTest {
81 81
         val channel = ChannelState("#thegibson") { CaseMapping.Rfc }
82 82
         channelStateMap += channel
83 83
 
84
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("zeroCool")))
85
-        handler.processEvent(ircClient, ChannelNamesFinished(TestConstants.time, "#thegibson"))
86
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("acidBurn")))
87
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("thePlague")))
84
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("zeroCool")))
85
+        handler.processEvent(ircClient, ChannelNamesFinished(EventMetadata(TestConstants.time), "#thegibson"))
86
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("acidBurn")))
87
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("thePlague")))
88 88
 
89 89
         assertEquals(2, channel.users.count())
90 90
         assertNotNull(channel.users["acidBurn"])
@@ -97,8 +97,8 @@ internal class ChannelStateHandlerTest {
97 97
         channelStateMap += channel
98 98
         serverState.features[ServerFeature.ModePrefixes] = ModePrefixMapping("ov", "@+")
99 99
 
100
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("@zeroCool", "@+acidBurn", "+thePlague", "cerealKiller")))
101
-        handler.processEvent(ircClient, ChannelNamesFinished(TestConstants.time, "#thegibson"))
100
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("@zeroCool", "@+acidBurn", "+thePlague", "cerealKiller")))
101
+        handler.processEvent(ircClient, ChannelNamesFinished(EventMetadata(TestConstants.time), "#thegibson"))
102 102
 
103 103
         assertEquals(4, channel.users.count())
104 104
         assertEquals("o", channel.users["zeroCool"]?.modes)
@@ -113,8 +113,8 @@ internal class ChannelStateHandlerTest {
113 113
         channelStateMap += channel
114 114
         serverState.features[ServerFeature.ModePrefixes] = ModePrefixMapping("ov", "@+")
115 115
 
116
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("@zeroCool!dade@root.localhost", "+acidBurn!libby@root.localhost")))
117
-        handler.processEvent(ircClient, ChannelNamesFinished(TestConstants.time, "#thegibson"))
116
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("@zeroCool!dade@root.localhost", "+acidBurn!libby@root.localhost")))
117
+        handler.processEvent(ircClient, ChannelNamesFinished(EventMetadata(TestConstants.time), "#thegibson"))
118 118
 
119 119
         assertEquals(2, channel.users.count())
120 120
         assertEquals("o", channel.users["zeroCool"]?.modes)
@@ -127,11 +127,11 @@ internal class ChannelStateHandlerTest {
127 127
         channelStateMap += channel
128 128
         serverState.features[ServerFeature.ModePrefixes] = ModePrefixMapping("ov", "@+")
129 129
 
130
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("@zeroCool!dade@root.localhost", "+acidBurn!libby@root.localhost")))
130
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("@zeroCool!dade@root.localhost", "+acidBurn!libby@root.localhost")))
131 131
 
132 132
         assertTrue(channel.receivingUserList)
133 133
 
134
-        handler.processEvent(ircClient, ChannelNamesFinished(TestConstants.time, "#thegibson"))
134
+        handler.processEvent(ircClient, ChannelNamesFinished(EventMetadata(TestConstants.time), "#thegibson"))
135 135
 
136 136
         assertFalse(channel.receivingUserList)
137 137
     }
@@ -143,7 +143,7 @@ internal class ChannelStateHandlerTest {
143 143
         serverState.features[ServerFeature.ModePrefixes] = ModePrefixMapping("ov", "@+")
144 144
         behaviour.requestModesOnJoin = true
145 145
 
146
-        handler.processEvent(ircClient, ChannelNamesFinished(TestConstants.time, "#thegibson"))
146
+        handler.processEvent(ircClient, ChannelNamesFinished(EventMetadata(TestConstants.time), "#thegibson"))
147 147
 
148 148
         verify(ircClient).send("MODE :#thegibson")
149 149
     }
@@ -156,7 +156,7 @@ internal class ChannelStateHandlerTest {
156 156
         behaviour.requestModesOnJoin = true
157 157
         channel.modesDiscovered = true
158 158
 
159
-        handler.processEvent(ircClient, ChannelNamesFinished(TestConstants.time, "#thegibson"))
159
+        handler.processEvent(ircClient, ChannelNamesFinished(EventMetadata(TestConstants.time), "#thegibson"))
160 160
 
161 161
         verify(ircClient, never()).send("MODE :#thegibson")
162 162
     }
@@ -168,7 +168,7 @@ internal class ChannelStateHandlerTest {
168 168
         serverState.features[ServerFeature.ModePrefixes] = ModePrefixMapping("ov", "@+")
169 169
         behaviour.requestModesOnJoin = false
170 170
 
171
-        handler.processEvent(ircClient, ChannelNamesFinished(TestConstants.time, "#thegibson"))
171
+        handler.processEvent(ircClient, ChannelNamesFinished(EventMetadata(TestConstants.time), "#thegibson"))
172 172
 
173 173
         verify(ircClient, never()).send("MODE :#thegibson")
174 174
     }
@@ -178,7 +178,7 @@ internal class ChannelStateHandlerTest {
178 178
         val channel = ChannelState("#thegibson") { CaseMapping.Rfc }
179 179
         channelStateMap += channel
180 180
 
181
-        handler.processEvent(ircClient, ChannelParted(TestConstants.time, User("acidburn", "libby", "root.localhost"), "#thegibson"))
181
+        handler.processEvent(ircClient, ChannelParted(EventMetadata(TestConstants.time), User("acidburn", "libby", "root.localhost"), "#thegibson"))
182 182
 
183 183
         assertFalse("#thegibson" in channelStateMap)
184 184
     }
@@ -189,7 +189,7 @@ internal class ChannelStateHandlerTest {
189 189
         channel.users += ChannelUser("ZeroCool")
190 190
         channelStateMap += channel
191 191
 
192
-        handler.processEvent(ircClient, ChannelParted(TestConstants.time, User("zerocool", "dade", "root.localhost"), "#thegibson"))
192
+        handler.processEvent(ircClient, ChannelParted(EventMetadata(TestConstants.time), User("zerocool", "dade", "root.localhost"), "#thegibson"))
193 193
 
194 194
         assertFalse("zerocool" in channel.users)
195 195
     }
@@ -199,7 +199,7 @@ internal class ChannelStateHandlerTest {
199 199
         val channel = ChannelState("#thegibson") { CaseMapping.Rfc }
200 200
         channelStateMap += channel
201 201
 
202
-        handler.processEvent(ircClient, ChannelUserKicked(TestConstants.time, User("zerocool", "dade", "root.localhost"), "#thegibson", "acidburn", "Bye!"))
202
+        handler.processEvent(ircClient, ChannelUserKicked(EventMetadata(TestConstants.time), User("zerocool", "dade", "root.localhost"), "#thegibson", "acidburn", "Bye!"))
203 203
 
204 204
         assertFalse("#thegibson" in channelStateMap)
205 205
     }
@@ -210,7 +210,7 @@ internal class ChannelStateHandlerTest {
210 210
         channel.users += ChannelUser("ZeroCool")
211 211
         channelStateMap += channel
212 212
 
213
-        handler.processEvent(ircClient, ChannelUserKicked(TestConstants.time, User("acidburn", "libby", "root.localhost"), "#thegibson", "zerocool", "Bye!"))
213
+        handler.processEvent(ircClient, ChannelUserKicked(EventMetadata(TestConstants.time), User("acidburn", "libby", "root.localhost"), "#thegibson", "zerocool", "Bye!"))
214 214
 
215 215
         assertFalse("zerocool" in channel.users)
216 216
     }
@@ -232,8 +232,8 @@ internal class ChannelStateHandlerTest {
232 232
             channelStateMap += this
233 233
         }
234 234
 
235
-        handler.processEvent(ircClient, ChannelQuit(TestConstants.time, User("zerocool", "dade", "root.localhost"), "#thegibson"))
236
-        handler.processEvent(ircClient, ChannelQuit(TestConstants.time, User("zerocool", "dade", "root.localhost"), "#dumpsterdiving"))
235
+        handler.processEvent(ircClient, ChannelQuit(EventMetadata(TestConstants.time), User("zerocool", "dade", "root.localhost"), "#thegibson"))
236
+        handler.processEvent(ircClient, ChannelQuit(EventMetadata(TestConstants.time), User("zerocool", "dade", "root.localhost"), "#dumpsterdiving"))
237 237
 
238 238
         assertFalse("zerocool" in channelStateMap["#thegibson"]!!.users)
239 239
         assertFalse("zerocool" in channelStateMap["#dumpsterdiving"]!!.users)
@@ -247,8 +247,8 @@ internal class ChannelStateHandlerTest {
247 247
         channel.users += ChannelUser("acidBurn")
248 248
         channelStateMap += channel
249 249
 
250
-        handler.processEvent(ircClient, ChannelNickChanged(TestConstants.time, User("acidburn", "libby", "root.localhost"), "#thegibson", "acidB"))
251
-        handler.processEvent(ircClient, ChannelNickChanged(TestConstants.time, User("acidburn", "libby", "root.localhost"), "#dumpsterdiving", "acidB"))
250
+        handler.processEvent(ircClient, ChannelNickChanged(EventMetadata(TestConstants.time), User("acidburn", "libby", "root.localhost"), "#thegibson", "acidB"))
251
+        handler.processEvent(ircClient, ChannelNickChanged(EventMetadata(TestConstants.time), User("acidburn", "libby", "root.localhost"), "#dumpsterdiving", "acidB"))
252 252
 
253 253
         assertFalse("acidBurn" in channel.users)
254 254
         assertTrue("acidB" in channel.users)
@@ -261,7 +261,7 @@ internal class ChannelStateHandlerTest {
261 261
         channelStateMap += channel
262 262
         serverState.features[ServerFeature.ChannelModes] = arrayOf("ab", "cd", "ef", "gh")
263 263
 
264
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "+", emptyArray(), true))
264
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "+", emptyArray(), true))
265 265
 
266 266
         assertTrue(channel.modesDiscovered)
267 267
     }
@@ -272,7 +272,7 @@ internal class ChannelStateHandlerTest {
272 272
         channelStateMap += channel
273 273
         serverState.features[ServerFeature.ChannelModes] = arrayOf("ab", "cd", "ef", "gh")
274 274
 
275
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "+ceg", arrayOf("CCC", "EEE"), true))
275
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "+ceg", arrayOf("CCC", "EEE"), true))
276 276
 
277 277
         assertEquals("CCC", channel.modes['c'])
278 278
         assertEquals("EEE", channel.modes['e'])
@@ -288,7 +288,7 @@ internal class ChannelStateHandlerTest {
288 288
         channelStateMap += channel
289 289
         serverState.features[ServerFeature.ChannelModes] = arrayOf("ab", "cd", "ef", "gh")
290 290
 
291
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "-c+d-eh+fg", arrayOf("CCC", "DDD", "FFF"), true))
291
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "-c+d-eh+fg", arrayOf("CCC", "DDD", "FFF"), true))
292 292
 
293 293
         assertNull(channel.modes['c'])
294 294
         assertEquals("DDD", channel.modes['d'])
@@ -305,7 +305,7 @@ internal class ChannelStateHandlerTest {
305 305
             channelStateMap += this
306 306
         }
307 307
 
308
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "+o", arrayOf("zeroCool")))
308
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "+o", arrayOf("zeroCool")))
309 309
 
310 310
         assertEquals("o", channelStateMap["#thegibson"]?.users?.get("zeroCool")?.modes)
311 311
     }
@@ -317,7 +317,7 @@ internal class ChannelStateHandlerTest {
317 317
             channelStateMap += this
318 318
         }
319 319
 
320
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "+v", arrayOf("zeroCool")))
320
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "+v", arrayOf("zeroCool")))
321 321
 
322 322
         assertEquals("ov", channelStateMap["#thegibson"]?.users?.get("zeroCool")?.modes)
323 323
     }
@@ -329,7 +329,7 @@ internal class ChannelStateHandlerTest {
329 329
             channelStateMap += this
330 330
         }
331 331
 
332
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "+o", arrayOf("zeroCool")))
332
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "+o", arrayOf("zeroCool")))
333 333
 
334 334
         assertEquals("ov", channelStateMap["#thegibson"]?.users?.get("zeroCool")?.modes)
335 335
     }
@@ -341,7 +341,7 @@ internal class ChannelStateHandlerTest {
341 341
             channelStateMap += this
342 342
         }
343 343
 
344
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "+vo", arrayOf("zeroCool", "zeroCool")))
344
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "+vo", arrayOf("zeroCool", "zeroCool")))
345 345
 
346 346
         assertEquals("ov", channelStateMap["#thegibson"]?.users?.get("zeroCool")?.modes)
347 347
     }
@@ -353,7 +353,7 @@ internal class ChannelStateHandlerTest {
353 353
             channelStateMap += this
354 354
         }
355 355
 
356
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "-vo", arrayOf("zeroCool", "zeroCool")))
356
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "-vo", arrayOf("zeroCool", "zeroCool")))
357 357
 
358 358
         assertEquals("", channelStateMap["#thegibson"]?.users?.get("zeroCool")?.modes)
359 359
     }
@@ -366,7 +366,7 @@ internal class ChannelStateHandlerTest {
366 366
         }
367 367
         serverState.features[ServerFeature.ChannelModes] = arrayOf("ab", "cd", "ef", "gh")
368 368
 
369
-        handler.processEvent(ircClient, ModeChanged(TestConstants.time, "#thegibson", "oa-v+b", arrayOf("zeroCool", "aaa", "zeroCool", "bbb")))
369
+        handler.processEvent(ircClient, ModeChanged(EventMetadata(TestConstants.time), "#thegibson", "oa-v+b", arrayOf("zeroCool", "aaa", "zeroCool", "bbb")))
370 370
 
371 371
         assertEquals("o", channelStateMap["#thegibson"]?.users?.get("zeroCool")?.modes)
372 372
         assertEquals("aaa", channelStateMap["#thegibson"]?.modes?.get('a'))
@@ -378,8 +378,8 @@ internal class ChannelStateHandlerTest {
378 378
         val state = ChannelState("#thegibson") { CaseMapping.Rfc }
379 379
         channelStateMap += state
380 380
 
381
-        handler.processEvent(ircClient, ChannelTopicDiscovered(TestConstants.time, "#thegibson", "Hack the planet!"))
382
-        handler.processEvent(ircClient, ChannelTopicMetadataDiscovered(TestConstants.time, "#thegibson", User("acidBurn"), TestConstants.otherTime))
381
+        handler.processEvent(ircClient, ChannelTopicDiscovered(EventMetadata(TestConstants.time), "#thegibson", "Hack the planet!"))
382
+        handler.processEvent(ircClient, ChannelTopicMetadataDiscovered(EventMetadata(TestConstants.time), "#thegibson", User("acidBurn"), TestConstants.otherTime))
383 383
 
384 384
         assertTrue(state.topicDiscovered)
385 385
         assertEquals(ChannelTopic("Hack the planet!", User("acidBurn"), TestConstants.otherTime), state.topic)
@@ -390,7 +390,7 @@ internal class ChannelStateHandlerTest {
390 390
         val state = ChannelState("#thegibson") { CaseMapping.Rfc }
391 391
         channelStateMap += state
392 392
 
393
-        handler.processEvent(ircClient, ChannelTopicDiscovered(TestConstants.time, "#thegibson", null))
393
+        handler.processEvent(ircClient, ChannelTopicDiscovered(EventMetadata(TestConstants.time), "#thegibson", null))
394 394
 
395 395
         assertTrue(state.topicDiscovered)
396 396
         assertEquals(ChannelTopic(), state.topic)
@@ -403,8 +403,8 @@ internal class ChannelStateHandlerTest {
403 403
         state.topicDiscovered = true
404 404
         channelStateMap += state
405 405
 
406
-        handler.processEvent(ircClient, ChannelTopicDiscovered(TestConstants.time, "#thegibson", "Hack the planet"))
407
-        handler.processEvent(ircClient, ChannelTopicMetadataDiscovered(TestConstants.time, "#thegibson", User("zeroCool"), TestConstants.time))
406
+        handler.processEvent(ircClient, ChannelTopicDiscovered(EventMetadata(TestConstants.time), "#thegibson", "Hack the planet"))
407
+        handler.processEvent(ircClient, ChannelTopicMetadataDiscovered(EventMetadata(TestConstants.time), "#thegibson", User("zeroCool"), TestConstants.time))
408 408
 
409 409
         assertTrue(state.topicDiscovered)
410 410
         assertEquals(ChannelTopic("Hack the planet!", User("acidBurn"), TestConstants.otherTime), state.topic)
@@ -415,7 +415,7 @@ internal class ChannelStateHandlerTest {
415 415
         val state = ChannelState("#thegibson") { CaseMapping.Rfc }
416 416
         channelStateMap += state
417 417
 
418
-        handler.processEvent(ircClient, ChannelTopicChanged(TestConstants.time, User("acidBurn"), "#thegibson", "Hack the planet!"))
418
+        handler.processEvent(ircClient, ChannelTopicChanged(EventMetadata(TestConstants.time), User("acidBurn"), "#thegibson", "Hack the planet!"))
419 419
 
420 420
         assertEquals(ChannelTopic("Hack the planet!", User("acidBurn"), TestConstants.time), state.topic)
421 421
     }
@@ -425,7 +425,7 @@ internal class ChannelStateHandlerTest {
425 425
         val state = ChannelState("#thegibson") { CaseMapping.Rfc }
426 426
         channelStateMap += state
427 427
 
428
-        handler.processEvent(ircClient, ChannelTopicChanged(TestConstants.time, User("acidBurn"), "#thegibson", null))
428
+        handler.processEvent(ircClient, ChannelTopicChanged(EventMetadata(TestConstants.time), User("acidBurn"), "#thegibson", null))
429 429
 
430 430
         assertEquals(ChannelTopic(null, User("acidBurn"), TestConstants.time), state.topic)
431 431
     }
@@ -435,7 +435,7 @@ internal class ChannelStateHandlerTest {
435 435
         val state = ChannelState("#thegibson") { CaseMapping.Rfc }
436 436
         channelStateMap += state
437 437
 
438
-        handler.processEvent(ircClient, ChannelTopicChanged(TestConstants.time, User("acidBurn"), "#dumpsterdiving", "Hack the planet!"))
438
+        handler.processEvent(ircClient, ChannelTopicChanged(EventMetadata(TestConstants.time), User("acidBurn"), "#dumpsterdiving", "Hack the planet!"))
439 439
 
440 440
         assertEquals(ChannelTopic(), state.topic)
441 441
     }

+ 2
- 1
src/test/kotlin/com/dmdirc/ktirc/events/handlers/PingHandlerTest.kt View File

@@ -2,6 +2,7 @@ package com.dmdirc.ktirc.events.handlers
2 2
 
3 3
 import com.dmdirc.ktirc.IrcClient
4 4
 import com.dmdirc.ktirc.TestConstants
5
+import com.dmdirc.ktirc.events.EventMetadata
5 6
 import com.dmdirc.ktirc.events.PingReceived
6 7
 import com.nhaarman.mockitokotlin2.mock
7 8
 import com.nhaarman.mockitokotlin2.verify
@@ -16,7 +17,7 @@ internal class PingHandlerTest {
16 17
 
17 18
     @Test
18 19
     fun `PingHandler responses to pings with a pong`() = runBlocking {
19
-        handler.processEvent(ircClient, PingReceived(TestConstants.time, "the_plague".toByteArray()))
20
+        handler.processEvent(ircClient, PingReceived(EventMetadata(TestConstants.time), "the_plague".toByteArray()))
20 21
         verify(ircClient).send("PONG :the_plague")
21 22
     }
22 23
 

+ 8
- 8
src/test/kotlin/com/dmdirc/ktirc/events/handlers/ServerStateHandlerTest.kt View File

@@ -23,44 +23,44 @@ internal class ServerStateHandlerTest {
23 23
 
24 24
     @Test
25 25
     fun `sets local nickname on welcome event`() {
26
-        handler.processEvent(ircClient, ServerWelcome(TestConstants.time, "the.gibson", "acidBurn"))
26
+        handler.processEvent(ircClient, ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn"))
27 27
         assertEquals("acidBurn", serverState.localNickname)
28 28
     }
29 29
 
30 30
     @Test
31 31
     fun `sets server name on welcome event`() {
32
-        handler.processEvent(ircClient, ServerWelcome(TestConstants.time, "the.gibson", "acidBurn"))
32
+        handler.processEvent(ircClient, ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn"))
33 33
         assertEquals("the.gibson", serverState.serverName)
34 34
     }
35 35
 
36 36
     @Test
37 37
     fun `sets receivedWelcome on welcome event`() {
38
-        handler.processEvent(ircClient, ServerWelcome(TestConstants.time, "the.gibson", "acidBurn"))
38
+        handler.processEvent(ircClient, ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn"))
39 39
         assertTrue(serverState.receivedWelcome)
40 40
     }
41 41
 
42 42
     @Test
43 43
     fun `sets state to connecting on event`() {
44
-        handler.processEvent(ircClient, ServerConnecting(TestConstants.time))
44
+        handler.processEvent(ircClient, ServerConnecting(EventMetadata(TestConstants.time)))
45 45
         assertEquals(ServerStatus.Connecting, serverState.status)
46 46
     }
47 47
 
48 48
     @Test
49 49
     fun `sets state to disconnected on event`() {
50 50
         serverState.status = ServerStatus.Ready
51
-        handler.processEvent(ircClient, ServerDisconnected(TestConstants.time))
51
+        handler.processEvent(ircClient, ServerDisconnected(EventMetadata(TestConstants.time)))
52 52
         assertEquals(ServerStatus.Disconnected, serverState.status)
53 53
     }
54 54
 
55 55
     @Test
56 56
     fun `sets state to negotiating on connected`() {
57
-        handler.processEvent(ircClient, ServerConnected(TestConstants.time))
57
+        handler.processEvent(ircClient, ServerConnected(EventMetadata(TestConstants.time)))
58 58
         assertEquals(ServerStatus.Negotiating, serverState.status)
59 59
     }
60 60
 
61 61
     @Test
62 62
     fun `sets state to ready on ServerReady`() {
63
-        handler.processEvent(ircClient, ServerReady(TestConstants.time))
63
+        handler.processEvent(ircClient, ServerReady(EventMetadata(TestConstants.time)))
64 64
         assertEquals(ServerStatus.Ready, serverState.status)
65 65
     }
66 66
 
@@ -70,7 +70,7 @@ internal class ServerStateHandlerTest {
70 70
         features[ServerFeature.ChannelModes] = arrayOf("abc", "def")
71 71
         features[ServerFeature.WhoxSupport] = true
72 72
 
73
-        handler.processEvent(ircClient, ServerFeaturesUpdated(TestConstants.time, features))
73
+        handler.processEvent(ircClient, ServerFeaturesUpdated(EventMetadata(TestConstants.time), features))
74 74
 
75 75
         assertArrayEquals(arrayOf("abc", "def"), serverState.features[ServerFeature.ChannelModes])
76 76
         assertEquals(true, serverState.features[ServerFeature.WhoxSupport])

+ 18
- 18
src/test/kotlin/com/dmdirc/ktirc/events/handlers/UserStateHandlerTest.kt View File

@@ -36,7 +36,7 @@ internal class UserStateHandlerTest {
36 36
     fun `adds channel to user on join`() {
37 37
         userState += User("acidBurn")
38 38
 
39
-        handler.processEvent(ircClient, ChannelJoined(TestConstants.time, User("acidBurn", "libby", "root.localhost"), "#thegibson"))
39
+        handler.processEvent(ircClient, ChannelJoined(EventMetadata(TestConstants.time), User("acidBurn", "libby", "root.localhost"), "#thegibson"))
40 40
 
41 41
         assertEquals(listOf("#thegibson"), userState["acidBurn"]?.channels?.toList())
42 42
     }
@@ -45,7 +45,7 @@ internal class UserStateHandlerTest {
45 45
     fun `updates user info on join`() {
46 46
         userState += User("acidBurn")
47 47
 
48
-        handler.processEvent(ircClient, ChannelJoined(TestConstants.time, User("acidBurn", "libby", "root.localhost"), "#thegibson"))
48
+        handler.processEvent(ircClient, ChannelJoined(EventMetadata(TestConstants.time), User("acidBurn", "libby", "root.localhost"), "#thegibson"))
49 49
 
50 50
         val details = userState["acidBurn"]?.details!!
51 51
         assertEquals("libby", details.ident)
@@ -58,7 +58,7 @@ internal class UserStateHandlerTest {
58 58
         userState.addToChannel(User("acidBurn"), "#thegibson")
59 59
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
60 60
 
61
-        handler.processEvent(ircClient, ChannelParted(TestConstants.time, User("acidBurn", "libby", "root.localhost"), "#dumpsterdiving"))
61
+        handler.processEvent(ircClient, ChannelParted(EventMetadata(TestConstants.time), User("acidBurn", "libby", "root.localhost"), "#dumpsterdiving"))
62 62
 
63 63
         assertEquals(listOf("#thegibson"), userState["acidBurn"]?.channels?.toList())
64 64
     }
@@ -68,7 +68,7 @@ internal class UserStateHandlerTest {
68 68
         userState += User("acidBurn")
69 69
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
70 70
 
71
-        handler.processEvent(ircClient, ChannelParted(TestConstants.time, User("acidBurn", "libby", "root.localhost"), "#dumpsterdiving"))
71
+        handler.processEvent(ircClient, ChannelParted(EventMetadata(TestConstants.time), User("acidBurn", "libby", "root.localhost"), "#dumpsterdiving"))
72 72
 
73 73
         assertNull(userState["acidBurn"])
74 74
     }
@@ -83,7 +83,7 @@ internal class UserStateHandlerTest {
83 83
         userState.addToChannel(User("zeroCool"), "#dumpsterdiving")
84 84
         userState.addToChannel(User("zeroCool"), "#thegibson")
85 85
 
86
-        handler.processEvent(ircClient, ChannelParted(TestConstants.time, User("zeroCool", "dade", "root.localhost"), "#dumpsterdiving"))
86
+        handler.processEvent(ircClient, ChannelParted(EventMetadata(TestConstants.time), User("zeroCool", "dade", "root.localhost"), "#dumpsterdiving"))
87 87
 
88 88
         assertEquals(listOf("#thegibson"), userState["acidBurn"]?.channels?.toList())
89 89
         assertEquals(listOf("#thegibson"), userState["zeroCool"]?.channels?.toList())
@@ -94,7 +94,7 @@ internal class UserStateHandlerTest {
94 94
         userState += User("acidBurn")
95 95
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
96 96
 
97
-        handler.processEvent(ircClient, ChannelParted(TestConstants.time, User("zeroCool", "dade", "root.localhost"), "#dumpsterdiving"))
97
+        handler.processEvent(ircClient, ChannelParted(EventMetadata(TestConstants.time), User("zeroCool", "dade", "root.localhost"), "#dumpsterdiving"))
98 98
 
99 99
         assertNull(userState["acidBurn"])
100 100
     }
@@ -104,7 +104,7 @@ internal class UserStateHandlerTest {
104 104
         userState += User("zeroCool")
105 105
         userState.addToChannel(User("zeroCool"), "#dumpsterdiving")
106 106
 
107
-        handler.processEvent(ircClient, ChannelParted(TestConstants.time, User("zeroCool", "dade", "root.localhost"), "#dumpsterdiving"))
107
+        handler.processEvent(ircClient, ChannelParted(EventMetadata(TestConstants.time), User("zeroCool", "dade", "root.localhost"), "#dumpsterdiving"))
108 108
 
109 109
         assertNotNull(userState["zeroCool"])
110 110
     }
@@ -116,7 +116,7 @@ internal class UserStateHandlerTest {
116 116
         userState.addToChannel(User("acidBurn"), "#thegibson")
117 117
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
118 118
 
119
-        handler.processEvent(ircClient, ChannelUserKicked(TestConstants.time, User("thePlague"), "#dumpsterdiving", "acidBurn"))
119
+        handler.processEvent(ircClient, ChannelUserKicked(EventMetadata(TestConstants.time), User("thePlague"), "#dumpsterdiving", "acidBurn"))
120 120
 
121 121
         assertEquals(listOf("#thegibson"), userState["acidBurn"]?.channels?.toList())
122 122
     }
@@ -126,7 +126,7 @@ internal class UserStateHandlerTest {
126 126
         userState += User("acidBurn")
127 127
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
128 128
 
129
-        handler.processEvent(ircClient, ChannelUserKicked(TestConstants.time, User("thePlague"), "#dumpsterdiving", "acidBurn"))
129
+        handler.processEvent(ircClient, ChannelUserKicked(EventMetadata(TestConstants.time), User("thePlague"), "#dumpsterdiving", "acidBurn"))
130 130
 
131 131
         assertNull(userState["acidBurn"])
132 132
     }
@@ -141,7 +141,7 @@ internal class UserStateHandlerTest {
141 141
         userState.addToChannel(User("zeroCool"), "#dumpsterdiving")
142 142
         userState.addToChannel(User("zeroCool"), "#thegibson")
143 143
 
144
-        handler.processEvent(ircClient, ChannelUserKicked(TestConstants.time, User("thePlague"), "#dumpsterdiving", "zeroCool"))
144
+        handler.processEvent(ircClient, ChannelUserKicked(EventMetadata(TestConstants.time), User("thePlague"), "#dumpsterdiving", "zeroCool"))
145 145
 
146 146
         assertEquals(listOf("#thegibson"), userState["acidBurn"]?.channels?.toList())
147 147
         assertEquals(listOf("#thegibson"), userState["zeroCool"]?.channels?.toList())
@@ -152,7 +152,7 @@ internal class UserStateHandlerTest {
152 152
         userState += User("acidBurn")
153 153
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
154 154
 
155
-        handler.processEvent(ircClient, ChannelUserKicked(TestConstants.time, User("thePlague"), "#dumpsterdiving", "zeroCool"))
155
+        handler.processEvent(ircClient, ChannelUserKicked(EventMetadata(TestConstants.time), User("thePlague"), "#dumpsterdiving", "zeroCool"))
156 156
 
157 157
         assertNull(userState["acidBurn"])
158 158
     }
@@ -162,7 +162,7 @@ internal class UserStateHandlerTest {
162 162
         userState += User("zeroCool")
163 163
         userState.addToChannel(User("zeroCool"), "#dumpsterdiving")
164 164
 
165
-        handler.processEvent(ircClient, ChannelUserKicked(TestConstants.time, User("thePlague"), "#dumpsterdiving", "zeroCool"))
165
+        handler.processEvent(ircClient, ChannelUserKicked(EventMetadata(TestConstants.time), User("thePlague"), "#dumpsterdiving", "zeroCool"))
166 166
 
167 167
         assertNotNull(userState["zeroCool"])
168 168
     }
@@ -172,7 +172,7 @@ internal class UserStateHandlerTest {
172 172
         userState += User("acidBurn")
173 173
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
174 174
 
175
-        handler.processEvent(ircClient, UserQuit(TestConstants.time, User("acidBurn", "libby", "root.localhost")))
175
+        handler.processEvent(ircClient, UserQuit(EventMetadata(TestConstants.time), User("acidBurn", "libby", "root.localhost")))
176 176
 
177 177
         assertNull(userState["acidBurn"])
178 178
     }
@@ -182,7 +182,7 @@ internal class UserStateHandlerTest {
182 182
         userState += User("acidBurn")
183 183
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
184 184
 
185
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("@acidBurn")))
185
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("@acidBurn")))
186 186
 
187 187
         assertEquals(listOf("#dumpsterdiving", "#thegibson"), userState["acidBurn"]?.channels?.toList())
188 188
     }
@@ -192,7 +192,7 @@ internal class UserStateHandlerTest {
192 192
         userState += User("acidBurn")
193 193
         userState.addToChannel(User("acidBurn"), "#dumpsterdiving")
194 194
 
195
-        handler.processEvent(ircClient, ChannelNamesReceived(TestConstants.time, "#thegibson", listOf("@acidBurn!libby@root.localhost")))
195
+        handler.processEvent(ircClient, ChannelNamesReceived(EventMetadata(TestConstants.time), "#thegibson", listOf("@acidBurn!libby@root.localhost")))
196 196
 
197 197
         val details = userState["acidBurn"]?.details!!
198 198
         assertEquals("libby", details.ident)
@@ -203,7 +203,7 @@ internal class UserStateHandlerTest {
203 203
     fun `updates user info on account change`() {
204 204
         userState += User("acidBurn")
205 205
 
206
-        handler.processEvent(ircClient, UserAccountChanged(TestConstants.time, User("acidBurn", "libby", "root.localhost"), "acidBurn"))
206
+        handler.processEvent(ircClient, UserAccountChanged(EventMetadata(TestConstants.time), User("acidBurn", "libby", "root.localhost"), "acidBurn"))
207 207
 
208 208
         val details = userState["acidBurn"]?.details!!
209 209
         assertEquals("acidBurn", details.account)
@@ -214,7 +214,7 @@ internal class UserStateHandlerTest {
214 214
         val user = User("acidBurn", "libby", "root.localhost")
215 215
         whenever(ircClient.isLocalUser(user)).doReturn(true)
216 216
 
217
-        handler.processEvent(ircClient, UserNickChanged(TestConstants.time, user, "acid~"))
217
+        handler.processEvent(ircClient, UserNickChanged(EventMetadata(TestConstants.time), user, "acid~"))
218 218
 
219 219
         assertEquals("acid~", serverState.localNickname)
220 220
     }
@@ -224,7 +224,7 @@ internal class UserStateHandlerTest {
224 224
         val user = User("acidBurn", "libby", "root.localhost")
225 225
         userState += User("AcidBurn")
226 226
 
227
-        handler.processEvent(ircClient, UserNickChanged(TestConstants.time, user, "acid~"))
227
+        handler.processEvent(ircClient, UserNickChanged(EventMetadata(TestConstants.time), user, "acid~"))
228 228
 
229 229
         assertNotNull(userState["acid~"])
230 230
         assertNull(userState["AcidBurn"])

+ 5
- 8
src/test/kotlin/com/dmdirc/ktirc/events/mutators/ChannelFanOutMutatorTest.kt View File

@@ -3,10 +3,7 @@ package com.dmdirc.ktirc.events.mutators
3 3
 import com.dmdirc.ktirc.BehaviourConfig
4 4
 import com.dmdirc.ktirc.IrcClient
5 5
 import com.dmdirc.ktirc.TestConstants
6
-import com.dmdirc.ktirc.events.ChannelNickChanged
7
-import com.dmdirc.ktirc.events.ChannelQuit
8
-import com.dmdirc.ktirc.events.UserNickChanged
9
-import com.dmdirc.ktirc.events.UserQuit
6
+import com.dmdirc.ktirc.events.*
10 7
 import com.dmdirc.ktirc.io.CaseMapping
11 8
 import com.dmdirc.ktirc.model.*
12 9
 import com.nhaarman.mockitokotlin2.doReturn
@@ -45,7 +42,7 @@ internal class ChannelFanOutMutatorTest {
45 42
             channelStateMap += this
46 43
         }
47 44
 
48
-        val quitEvent = UserQuit(TestConstants.time, User("zerocool", "dade", "root.localhost"), "Hack the planet!")
45
+        val quitEvent = UserQuit(EventMetadata(TestConstants.time), User("zerocool", "dade", "root.localhost"), "Hack the planet!")
49 46
         val events = mutator.mutateEvent(ircClient, quitEvent)
50 47
 
51 48
         val names = mutableListOf<String>()
@@ -53,7 +50,7 @@ internal class ChannelFanOutMutatorTest {
53 50
         Assertions.assertSame(quitEvent, events[0])
54 51
         events.subList(1, events.size).forEach { event ->
55 52
             (event as ChannelQuit).let {
56
-                Assertions.assertEquals(TestConstants.time, it.time)
53
+                Assertions.assertEquals(TestConstants.time, it.metadata.time)
57 54
                 Assertions.assertEquals("zerocool", it.user.nickname)
58 55
                 Assertions.assertEquals("Hack the planet!", it.reason)
59 56
                 names.add(it.channel)
@@ -81,7 +78,7 @@ internal class ChannelFanOutMutatorTest {
81 78
             channelStateMap += this
82 79
         }
83 80
 
84
-        val nickEvent = UserNickChanged(TestConstants.time, User("zerocool", "dade", "root.localhost"), "zer0c00l")
81
+        val nickEvent = UserNickChanged(EventMetadata(TestConstants.time), User("zerocool", "dade", "root.localhost"), "zer0c00l")
85 82
         val events = mutator.mutateEvent(ircClient, nickEvent)
86 83
 
87 84
         val names = mutableListOf<String>()
@@ -89,7 +86,7 @@ internal class ChannelFanOutMutatorTest {
89 86
         Assertions.assertSame(nickEvent, events[0])
90 87
         events.subList(1, events.size).forEach { event ->
91 88
             (event as ChannelNickChanged).let {
92
-                Assertions.assertEquals(TestConstants.time, it.time)
89
+                Assertions.assertEquals(TestConstants.time, it.metadata.time)
93 90
                 Assertions.assertEquals("zerocool", it.user.nickname)
94 91
                 Assertions.assertEquals("zer0c00l", it.newNick)
95 92
                 names.add(it.channel)

+ 6
- 6
src/test/kotlin/com/dmdirc/ktirc/events/mutators/ServerReadyMutatorTest.kt View File

@@ -27,16 +27,16 @@ internal class ServerReadyMutatorTest {
27 27
         ircClient.serverState.status = ServerStatus.Negotiating
28 28
 
29 29
         listOf(
30
-                ServerWelcome(TestConstants.time, "the.gibson", "acidBurn"),
31
-                PingReceived(TestConstants.time, "1234".toByteArray()),
32
-                ServerCapabilitiesReceived(TestConstants.time, emptyMap()),
33
-                ServerCapabilitiesAcknowledged(TestConstants.time, emptyMap()),
34
-                ServerCapabilitiesFinished(TestConstants.time)
30
+                ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn"),
31
+                PingReceived(EventMetadata(TestConstants.time), "1234".toByteArray()),
32
+                ServerCapabilitiesReceived(EventMetadata(TestConstants.time), emptyMap()),
33
+                ServerCapabilitiesAcknowledged(EventMetadata(TestConstants.time), emptyMap()),
34
+                ServerCapabilitiesFinished(EventMetadata(TestConstants.time))
35 35
         ).forEach {
36 36
             assertEquals(1, mutator.mutateEvent(ircClient, it).size)
37 37
         }
38 38
 
39
-        val event = MessageReceived(TestConstants.time, User("zeroCool"), "acidBurn", "Welcome!")
39
+        val event = MessageReceived(EventMetadata(TestConstants.time), User("zeroCool"), "acidBurn", "Welcome!")
40 40
         val events = mutator.mutateEvent(ircClient, event)
41 41
         assertEquals(2, events.size)
42 42
         assertSame(event, events[1])

+ 12
- 11
src/test/kotlin/com/dmdirc/ktirc/io/MessageHandlerTest.kt View File

@@ -2,6 +2,7 @@ package com.dmdirc.ktirc.io
2 2
 
3 3
 import com.dmdirc.ktirc.IrcClient
4 4
 import com.dmdirc.ktirc.TestConstants
5
+import com.dmdirc.ktirc.events.EventMetadata
5 6
 import com.dmdirc.ktirc.events.ServerConnected
6 7
 import com.dmdirc.ktirc.events.ServerReady
7 8
 import com.dmdirc.ktirc.events.ServerWelcome
@@ -67,7 +68,7 @@ internal class MessageHandlerTest {
67 68
         val eventHandler2 = mock<EventHandler>()
68 69
         val handler = MessageHandler(listOf(joinProcessor, nickProcessor), emptyList(), mutableListOf(eventHandler1, eventHandler2))
69 70
         val joinMessage = IrcMessage(emptyMap(), null, "JOIN", emptyList())
70
-        whenever(joinProcessor.process(any())).thenReturn(listOf(ServerConnected(TestConstants.time), ServerWelcome(TestConstants.time, "the.gibson", "acidBurn")))
71
+        whenever(joinProcessor.process(any())).thenReturn(listOf(ServerConnected(EventMetadata(TestConstants.time)), ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn")))
71 72
 
72 73
         with(Channel<IrcMessage>(1)) {
73 74
             send(joinMessage)
@@ -86,7 +87,7 @@ internal class MessageHandlerTest {
86 87
         val eventHandler1 = mock<EventHandler>()
87 88
         val eventHandler2 = mock<EventHandler>()
88 89
         val handler = MessageHandler(emptyList(), emptyList(), mutableListOf(eventHandler1, eventHandler2))
89
-        handler.emitEvent(ircClient, ServerWelcome(TestConstants.time, "the.gibson", "acidBurn"))
90
+        handler.emitEvent(ircClient, ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn"))
90 91
 
91 92
         verify(eventHandler1).processEvent(same(ircClient), isA<ServerWelcome>())
92 93
         verify(eventHandler2).processEvent(same(ircClient), isA<ServerWelcome>())
@@ -95,15 +96,15 @@ internal class MessageHandlerTest {
95 96
     @Test
96 97
     fun `mutates events in order`() {
97 98
         val eventMutator1 = mock<EventMutator> {
98
-            on { mutateEvent(any(), isA<ServerWelcome>()) } doReturn listOf(ServerReady(TestConstants.time))
99
+            on { mutateEvent(any(), isA<ServerWelcome>()) } doReturn listOf(ServerReady(EventMetadata(TestConstants.time)))
99 100
         }
100 101
         val eventMutator2 = mock<EventMutator> {
101
-            on { mutateEvent(any(), isA<ServerReady>()) } doReturn listOf(ServerConnected(TestConstants.time))
102
+            on { mutateEvent(any(), isA<ServerReady>()) } doReturn listOf(ServerConnected(EventMetadata(TestConstants.time)))
102 103
         }
103 104
         val eventHandler = mock<EventHandler>()
104 105
 
105 106
         val handler = MessageHandler(emptyList(), listOf(eventMutator1, eventMutator2), mutableListOf(eventHandler))
106
-        handler.emitEvent(ircClient, ServerWelcome(TestConstants.time, "the.gibson", "acidBurn"))
107
+        handler.emitEvent(ircClient, ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn"))
107 108
 
108 109
         verify(eventMutator1).mutateEvent(same(ircClient), isA<ServerWelcome>())
109 110
         verify(eventMutator2).mutateEvent(same(ircClient), isA<ServerReady>())
@@ -115,18 +116,18 @@ internal class MessageHandlerTest {
115 116
     fun `allows mutators to fan out events`() {
116 117
         val eventMutator1 = mock<EventMutator> {
117 118
             on { mutateEvent(any(), isA<ServerWelcome>()) } doReturn listOf(
118
-                    ServerReady(TestConstants.time),
119
-                    ServerConnected(TestConstants.time)
119
+                    ServerReady(EventMetadata(TestConstants.time)),
120
+                    ServerConnected(EventMetadata(TestConstants.time))
120 121
             )
121 122
         }
122 123
         val eventMutator2 = mock<EventMutator> {
123
-            on { mutateEvent(any(), isA<ServerReady>()) } doReturn listOf(ServerReady(TestConstants.time))
124
-            on { mutateEvent(any(), isA<ServerConnected>()) } doReturn listOf(ServerConnected(TestConstants.time))
124
+            on { mutateEvent(any(), isA<ServerReady>()) } doReturn listOf(ServerReady(EventMetadata(TestConstants.time)))
125
+            on { mutateEvent(any(), isA<ServerConnected>()) } doReturn listOf(ServerConnected(EventMetadata(TestConstants.time)))
125 126
         }
126 127
         val eventHandler = mock<EventHandler>()
127 128
 
128 129
         val handler = MessageHandler(emptyList(), listOf(eventMutator1, eventMutator2), mutableListOf(eventHandler))
129
-        handler.emitEvent(ircClient, ServerWelcome(TestConstants.time, "the.gibson", "acidBurn"))
130
+        handler.emitEvent(ircClient, ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn"))
130 131
 
131 132
         with (inOrder(eventMutator2, eventHandler)) {
132 133
             verify(eventMutator2).mutateEvent(same(ircClient), isA<ServerReady>())
@@ -145,7 +146,7 @@ internal class MessageHandlerTest {
145 146
         val eventHandler = mock<EventHandler>()
146 147
 
147 148
         val handler = MessageHandler(emptyList(), listOf(eventMutator1, eventMutator2), mutableListOf(eventHandler))
148
-        handler.emitEvent(ircClient, ServerWelcome(TestConstants.time, "the.gibson", "acidBurn"))
149
+        handler.emitEvent(ircClient, ServerWelcome(EventMetadata(TestConstants.time), "the.gibson", "acidBurn"))
149 150
 
150 151
         verify(eventMutator2, never()).mutateEvent(any(), any())
151 152
         verify(eventHandler, never()).processEvent(any(), any())

+ 2
- 2
src/test/kotlin/com/dmdirc/ktirc/messages/AccountProcessorTest.kt View File

@@ -22,7 +22,7 @@ internal class AccountProcessorTest {
22 22
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "ACCOUNT", params("acidBurn")))
23 23
         assertEquals(1, events.size)
24 24
 
25
-        assertEquals(TestConstants.time, events[0].time)
25
+        assertEquals(TestConstants.time, events[0].metadata.time)
26 26
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
27 27
         assertEquals("acidBurn", events[0].newAccount)
28 28
     }
@@ -33,7 +33,7 @@ internal class AccountProcessorTest {
33 33
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "ACCOUNT", params("*")))
34 34
         assertEquals(1, events.size)
35 35
 
36
-        assertEquals(TestConstants.time, events[0].time)
36
+        assertEquals(TestConstants.time, events[0].metadata.time)
37 37
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
38 38
         assertEquals(null, events[0].newAccount)
39 39
     }

+ 7
- 7
src/test/kotlin/com/dmdirc/ktirc/messages/AuthenticationProcessorTest.kt View File

@@ -26,7 +26,7 @@ internal class AuthenticationProcessorTest {
26 26
 
27 27
         assertEquals(1, events.size)
28 28
         val event = events[0] as AuthenticationMessage
29
-        assertEquals(TestConstants.time, event.time)
29
+        assertEquals(TestConstants.time, event.metadata.time)
30 30
         assertNull(event.argument)
31 31
     }
32 32
 
@@ -36,7 +36,7 @@ internal class AuthenticationProcessorTest {
36 36
 
37 37
         assertEquals(1, events.size)
38 38
         val event = events[0] as AuthenticationMessage
39
-        assertEquals(TestConstants.time, event.time)
39
+        assertEquals(TestConstants.time, event.metadata.time)
40 40
         assertNull(event.argument)
41 41
     }
42 42
 
@@ -46,7 +46,7 @@ internal class AuthenticationProcessorTest {
46 46
 
47 47
         assertEquals(1, events.size)
48 48
         val event = events[0] as AuthenticationMessage
49
-        assertEquals(TestConstants.time, event.time)
49
+        assertEquals(TestConstants.time, event.metadata.time)
50 50
         assertEquals("HackThePlanet", event.argument)
51 51
     }
52 52
 
@@ -56,7 +56,7 @@ internal class AuthenticationProcessorTest {
56 56
 
57 57
         assertEquals(1, events.size)
58 58
         val event = events[0] as SaslFinished
59
-        assertEquals(TestConstants.time, event.time)
59
+        assertEquals(TestConstants.time, event.metadata.time)
60 60
         assertTrue(event.success)
61 61
     }
62 62
 
@@ -66,7 +66,7 @@ internal class AuthenticationProcessorTest {
66 66
 
67 67
         assertEquals(1, events.size)
68 68
         val event = events[0] as SaslFinished
69
-        assertEquals(TestConstants.time, event.time)
69
+        assertEquals(TestConstants.time, event.metadata.time)
70 70
         assertFalse(event.success)
71 71
     }
72 72
 
@@ -76,7 +76,7 @@ internal class AuthenticationProcessorTest {
76 76
 
77 77
         assertEquals(1, events.size)
78 78
         val event = events[0] as SaslMechanismNotAvailableError
79
-        assertEquals(TestConstants.time, event.time)
79
+        assertEquals(TestConstants.time, event.metadata.time)
80 80
         assertEquals(listOf("PLAIN", "EXTERNAL", "MAGIC"), event.mechanisms)
81 81
     }
82 82
 
@@ -86,7 +86,7 @@ internal class AuthenticationProcessorTest {
86 86
 
87 87
         assertEquals(1, events.size)
88 88
         val event = events[0] as SaslMechanismNotAvailableError
89
-        assertEquals(TestConstants.time, event.time)
89
+        assertEquals(TestConstants.time, event.metadata.time)
90 90
         assertTrue(event.mechanisms.isEmpty())
91 91
     }
92 92
 

+ 3
- 3
src/test/kotlin/com/dmdirc/ktirc/messages/JoinProcessorTest.kt View File

@@ -22,7 +22,7 @@ internal class JoinProcessorTest {
22 22
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "JOIN", params("#crashandburn")))
23 23
         assertEquals(1, events.size)
24 24
 
25
-        assertEquals(TestConstants.time, events[0].time)
25
+        assertEquals(TestConstants.time, events[0].metadata.time)
26 26
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
27 27
         assertEquals("#crashandburn", events[0].channel)
28 28
     }
@@ -40,7 +40,7 @@ internal class JoinProcessorTest {
40 40
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "JOIN", params("#crashandburn", "acidBurn", "Libby")))
41 41
         assertEquals(1, events.size)
42 42
 
43
-        assertEquals(TestConstants.time, events[0].time)
43
+        assertEquals(TestConstants.time, events[0].metadata.time)
44 44
         assertEquals(User("acidburn", "libby", "root.localhost", account = "acidBurn", realName = "Libby"), events[0].user)
45 45
         assertEquals("#crashandburn", events[0].channel)
46 46
     }
@@ -51,7 +51,7 @@ internal class JoinProcessorTest {
51 51
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "JOIN", params("#crashandburn", "*", "Libby")))
52 52
         assertEquals(1, events.size)
53 53
 
54
-        assertEquals(TestConstants.time, events[0].time)
54
+        assertEquals(TestConstants.time, events[0].metadata.time)
55 55
         assertEquals(User("acidburn", "libby", "root.localhost", realName = "Libby"), events[0].user)
56 56
         assertEquals("#crashandburn", events[0].channel)
57 57
     }

+ 2
- 2
src/test/kotlin/com/dmdirc/ktirc/messages/KickProcessorTest.kt View File

@@ -22,7 +22,7 @@ internal class KickProcessorTest {
22 22
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "KICK", params("#crashandburn", "zeroCool")))
23 23
         assertEquals(1, events.size)
24 24
 
25
-        assertEquals(TestConstants.time, events[0].time)
25
+        assertEquals(TestConstants.time, events[0].metadata.time)
26 26
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
27 27
         assertEquals("#crashandburn", events[0].channel)
28 28
         assertEquals("zeroCool", events[0].victim)
@@ -35,7 +35,7 @@ internal class KickProcessorTest {
35 35
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "KICK", params("#crashandburn", "zeroCool", "Hack the planet!")))
36 36
         assertEquals(1, events.size)
37 37
 
38
-        assertEquals(TestConstants.time, events[0].time)
38
+        assertEquals(TestConstants.time, events[0].metadata.time)
39 39
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
40 40
         assertEquals("#crashandburn", events[0].channel)
41 41
         assertEquals("zeroCool", events[0].victim)

+ 8
- 8
src/test/kotlin/com/dmdirc/ktirc/messages/ModeProcessorTest.kt View File

@@ -21,7 +21,7 @@ internal class ModeProcessorTest {
21 21
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "221", params("acidBurn", "+hax")))
22 22
         assertEquals(1, events.size)
23 23
 
24
-        assertEquals(TestConstants.time, events[0].time)
24
+        assertEquals(TestConstants.time, events[0].metadata.time)
25 25
         assertEquals("acidBurn", events[0].target)
26 26
         assertEquals("+hax", events[0].modes)
27 27
         assertEquals(0, events[0].arguments.size)
@@ -34,7 +34,7 @@ internal class ModeProcessorTest {
34 34
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "221", params("acidBurn", "+hax", "123", "467")))
35 35
         assertEquals(1, events.size)
36 36
 
37
-        assertEquals(TestConstants.time, events[0].time)
37
+        assertEquals(TestConstants.time, events[0].metadata.time)
38 38
         assertEquals("acidBurn", events[0].target)
39 39
         assertEquals("+hax", events[0].modes)
40 40
         assertEquals(2, events[0].arguments.size)
@@ -49,7 +49,7 @@ internal class ModeProcessorTest {
49 49
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "MODE", params("acidBurn", "+hax")))
50 50
         assertEquals(1, events.size)
51 51
 
52
-        assertEquals(TestConstants.time, events[0].time)
52
+        assertEquals(TestConstants.time, events[0].metadata.time)
53 53
         assertEquals("acidBurn", events[0].target)
54 54
         assertEquals("+hax", events[0].modes)
55 55
         assertEquals(0, events[0].arguments.size)
@@ -62,7 +62,7 @@ internal class ModeProcessorTest {
62 62
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "MODE", params("acidBurn", "+hax", "123", "467")))
63 63
         assertEquals(1, events.size)
64 64
 
65
-        assertEquals(TestConstants.time, events[0].time)
65
+        assertEquals(TestConstants.time, events[0].metadata.time)
66 66
         assertEquals("acidBurn", events[0].target)
67 67
         assertEquals("+hax", events[0].modes)
68 68
         assertEquals(2, events[0].arguments.size)
@@ -77,7 +77,7 @@ internal class ModeProcessorTest {
77 77
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "324", params("acidBurn", "#thegibson", "+hax")))
78 78
         assertEquals(1, events.size)
79 79
 
80
-        assertEquals(TestConstants.time, events[0].time)
80
+        assertEquals(TestConstants.time, events[0].metadata.time)
81 81
         assertEquals("#thegibson", events[0].target)
82 82
         assertEquals("+hax", events[0].modes)
83 83
         assertEquals(0, events[0].arguments.size)
@@ -90,7 +90,7 @@ internal class ModeProcessorTest {
90 90
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "324", params("acidBurn", "#thegibson", "+hax", "123", "467")))
91 91
         assertEquals(1, events.size)
92 92
 
93
-        assertEquals(TestConstants.time, events[0].time)
93
+        assertEquals(TestConstants.time, events[0].metadata.time)
94 94
         assertEquals("#thegibson", events[0].target)
95 95
         assertEquals("+hax", events[0].modes)
96 96
         assertEquals(2, events[0].arguments.size)
@@ -105,7 +105,7 @@ internal class ModeProcessorTest {
105 105
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "MODE", params("#thegibson", "+hax")))
106 106
         assertEquals(1, events.size)
107 107
 
108
-        assertEquals(TestConstants.time, events[0].time)
108
+        assertEquals(TestConstants.time, events[0].metadata.time)
109 109
         assertEquals("#thegibson", events[0].target)
110 110
         assertEquals("+hax", events[0].modes)
111 111
         assertEquals(0, events[0].arguments.size)
@@ -118,7 +118,7 @@ internal class ModeProcessorTest {
118 118
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "MODE", params("#thegibson", "+hax", "123", "467")))
119 119
         assertEquals(1, events.size)
120 120
 
121
-        assertEquals(TestConstants.time, events[0].time)
121
+        assertEquals(TestConstants.time, events[0].metadata.time)
122 122
         assertEquals("#thegibson", events[0].target)
123 123
         assertEquals("+hax", events[0].modes)
124 124
         assertEquals(2, events[0].arguments.size)

+ 4
- 4
src/test/kotlin/com/dmdirc/ktirc/messages/MotdProcessorTest.kt View File

@@ -24,7 +24,7 @@ internal class MotdProcessorTest {
24 24
         assertEquals(1, events.size)
25 25
 
26 26
         val event = events[0] as MotdFinished
27
-        assertEquals(TestConstants.time, events[0].time)
27
+        assertEquals(TestConstants.time, events[0].metadata.time)
28 28
         assertTrue(event.missing)
29 29
     }
30 30
 
@@ -35,7 +35,7 @@ internal class MotdProcessorTest {
35 35
         assertEquals(1, events.size)
36 36
 
37 37
         val event = events[0] as MotdFinished
38
-        assertEquals(TestConstants.time, events[0].time)
38
+        assertEquals(TestConstants.time, events[0].metadata.time)
39 39
         assertFalse(event.missing)
40 40
     }
41 41
 
@@ -46,7 +46,7 @@ internal class MotdProcessorTest {
46 46
         assertEquals(1, events.size)
47 47
 
48 48
         val event = events[0] as MotdLineReceived
49
-        assertEquals(TestConstants.time, event.time)
49
+        assertEquals(TestConstants.time, event.metadata.time)
50 50
         assertEquals("- the.gibson MOTD -", event.line)
51 51
         assertTrue(event.first)
52 52
     }
@@ -58,7 +58,7 @@ internal class MotdProcessorTest {
58 58
         assertEquals(1, events.size)
59 59
 
60 60
         val event = events[0] as MotdLineReceived
61
-        assertEquals(TestConstants.time, event.time)
61
+        assertEquals(TestConstants.time, event.metadata.time)
62 62
         assertEquals("Hack the planet!", event.line)
63 63
         assertFalse(event.first)
64 64
     }

+ 4
- 4
src/test/kotlin/com/dmdirc/ktirc/messages/NoticeProcessorTest.kt View File

@@ -25,7 +25,7 @@ internal class NoticeProcessorTest {
25 25
         assertEquals(1, events.size)
26 26
 
27 27
         val event = events[0] as NoticeReceived
28
-        assertEquals(TestConstants.time, event.time)
28
+        assertEquals(TestConstants.time, event.metadata.time)
29 29
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
30 30
         assertEquals("#crashandburn", event.target)
31 31
         assertEquals("hack the planet!", event.message)
@@ -38,7 +38,7 @@ internal class NoticeProcessorTest {
38 38
         assertEquals(1, events.size)
39 39
 
40 40
         val event = events[0] as NoticeReceived
41
-        assertEquals(TestConstants.time, event.time)
41
+        assertEquals(TestConstants.time, event.metadata.time)
42 42
         assertEquals(User("*"), event.user)
43 43
         assertEquals("#crashandburn", event.target)
44 44
         assertEquals("hack the planet!", event.message)
@@ -51,7 +51,7 @@ internal class NoticeProcessorTest {
51 51
         assertEquals(1, events.size)
52 52
 
53 53
         val event = events[0] as CtcpReplyReceived
54
-        assertEquals(TestConstants.time, event.time)
54
+        assertEquals(TestConstants.time, event.metadata.time)
55 55
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
56 56
         assertEquals("#crashandburn", event.target)
57 57
         assertEquals("PING", event.type)
@@ -65,7 +65,7 @@ internal class NoticeProcessorTest {
65 65
         assertEquals(1, events.size)
66 66
 
67 67
         val event = events[0] as CtcpReplyReceived
68
-        assertEquals(TestConstants.time, event.time)
68
+        assertEquals(TestConstants.time, event.metadata.time)
69 69
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
70 70
         assertEquals("#crashandburn", event.target)
71 71
         assertEquals("PING", event.type)

+ 2
- 2
src/test/kotlin/com/dmdirc/ktirc/messages/PartProcessorTest.kt View File

@@ -22,7 +22,7 @@ internal class PartProcessorTest {
22 22
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PART", params("#crashandburn")))
23 23
         assertEquals(1, events.size)
24 24
 
25
-        assertEquals(TestConstants.time, events[0].time)
25
+        assertEquals(TestConstants.time, events[0].metadata.time)
26 26
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
27 27
         assertEquals("#crashandburn", events[0].channel)
28 28
         assertEquals("", events[0].reason)
@@ -34,7 +34,7 @@ internal class PartProcessorTest {
34 34
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PART", params("#crashandburn", "Hack the planet!")))
35 35
         assertEquals(1, events.size)
36 36
 
37
-        assertEquals(TestConstants.time, events[0].time)
37
+        assertEquals(TestConstants.time, events[0].metadata.time)
38 38
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
39 39
         assertEquals("#crashandburn", events[0].channel)
40 40
         assertEquals("Hack the planet!", events[0].reason)

+ 8
- 8
src/test/kotlin/com/dmdirc/ktirc/messages/PrivmsgProcessorTest.kt View File

@@ -28,7 +28,7 @@ internal class PrivmsgProcessorTest {
28 28
         assertEquals(1, events.size)
29 29
 
30 30
         val event = events[0] as MessageReceived
31
-        assertEquals(TestConstants.time, event.time)
31
+        assertEquals(TestConstants.time, event.metadata.time)
32 32
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
33 33
         assertEquals("#crashandburn", event.target)
34 34
         assertEquals("hack the planet!", event.message)
@@ -42,7 +42,7 @@ internal class PrivmsgProcessorTest {
42 42
         assertEquals(1, events.size)
43 43
 
44 44
         val event = events[0] as MessageReceived
45
-        assertEquals(TestConstants.time, event.time)
45
+        assertEquals(TestConstants.time, event.metadata.time)
46 46
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
47 47
         assertEquals("#crashandburn", event.target)
48 48
         assertEquals("hack the planet!", event.message)
@@ -56,7 +56,7 @@ internal class PrivmsgProcessorTest {
56 56
         assertEquals(1, events.size)
57 57
 
58 58
         val event = events[0] as ActionReceived
59
-        assertEquals(TestConstants.time, event.time)
59
+        assertEquals(TestConstants.time, event.metadata.time)
60 60
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
61 61
         assertEquals("#crashandburn", event.target)
62 62
         assertEquals("hacks the planet", event.action)
@@ -70,7 +70,7 @@ internal class PrivmsgProcessorTest {
70 70
         assertEquals(1, events.size)
71 71
 
72 72
         val event = events[0] as ActionReceived
73
-        assertEquals(TestConstants.time, event.time)
73
+        assertEquals(TestConstants.time, event.metadata.time)
74 74
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
75 75
         assertEquals("#crashandburn", event.target)
76 76
         assertEquals("hacks the planet", event.action)
@@ -84,7 +84,7 @@ internal class PrivmsgProcessorTest {
84 84
         assertEquals(1, events.size)
85 85
 
86 86
         val event = events[0] as ActionReceived
87
-        assertEquals(TestConstants.time, event.time)
87
+        assertEquals(TestConstants.time, event.metadata.time)
88 88
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
89 89
         assertEquals("#crashandburn", event.target)
90 90
         assertEquals("", event.action)
@@ -98,7 +98,7 @@ internal class PrivmsgProcessorTest {
98 98
         assertEquals(1, events.size)
99 99
 
100 100
         val event = events[0] as ActionReceived
101
-        assertEquals(TestConstants.time, event.time)
101
+        assertEquals(TestConstants.time, event.metadata.time)
102 102
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
103 103
         assertEquals("#crashandburn", event.target)
104 104
         assertEquals("hacks the planet", event.action)
@@ -112,7 +112,7 @@ internal class PrivmsgProcessorTest {
112 112
         assertEquals(1, events.size)
113 113
 
114 114
         val event = events[0] as CtcpReceived
115
-        assertEquals(TestConstants.time, event.time)
115
+        assertEquals(TestConstants.time, event.metadata.time)
116 116
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
117 117
         assertEquals("#crashandburn", event.target)
118 118
         assertEquals("PING", event.type)
@@ -126,7 +126,7 @@ internal class PrivmsgProcessorTest {
126 126
         assertEquals(1, events.size)
127 127
 
128 128
         val event = events[0] as CtcpReceived
129
-        assertEquals(TestConstants.time, event.time)
129
+        assertEquals(TestConstants.time, event.metadata.time)
130 130
         assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
131 131
         assertEquals("#crashandburn", event.target)
132 132
         assertEquals("PING", event.type)

+ 2
- 2
src/test/kotlin/com/dmdirc/ktirc/messages/QuitProcessorTest.kt View File

@@ -22,7 +22,7 @@ internal class QuitProcessorTest {
22 22
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "QUIT", emptyList()))
23 23
         assertEquals(1, events.size)
24 24
 
25
-        assertEquals(TestConstants.time, events[0].time)
25
+        assertEquals(TestConstants.time, events[0].metadata.time)
26 26
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
27 27
         assertEquals("", events[0].reason)
28 28
     }
@@ -33,7 +33,7 @@ internal class QuitProcessorTest {
33 33
                 IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "QUIT", params("Hack the planet!")))
34 34
         assertEquals(1, events.size)
35 35
 
36
-        assertEquals(TestConstants.time, events[0].time)
36
+        assertEquals(TestConstants.time, events[0].metadata.time)
37 37
         assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
38 38
         assertEquals("Hack the planet!", events[0].reason)
39 39
     }

+ 4
- 4
src/test/kotlin/com/dmdirc/ktirc/messages/TopicProcessorTest.kt View File

@@ -29,7 +29,7 @@ internal class TopicProcessorTest {
29 29
         assertEquals(1, events.size)
30 30
 
31 31
         val event = events[0] as ChannelTopicDiscovered
32
-        assertEquals(TestConstants.time, event.time)
32
+        assertEquals(TestConstants.time, event.metadata.time)
33 33
         assertEquals("#thegibson", event.channel)
34 34
         assertEquals("Hack the planet!", event.topic)
35 35
     }
@@ -40,7 +40,7 @@ internal class TopicProcessorTest {
40 40
         assertEquals(1, events.size)
41 41
 
42 42
         val event = events[0] as ChannelTopicDiscovered
43
-        assertEquals(TestConstants.time, event.time)
43
+        assertEquals(TestConstants.time, event.metadata.time)
44 44
         assertEquals("#thegibson", event.channel)
45 45
         assertNull(event.topic)
46 46
     }
@@ -51,7 +51,7 @@ internal class TopicProcessorTest {
51 51
         assertEquals(1, events.size)
52 52
 
53 53
         val event = events[0] as ChannelTopicMetadataDiscovered
54
-        assertEquals(TestConstants.time, event.time)
54
+        assertEquals(TestConstants.time, event.metadata.time)
55 55
         assertEquals("#thegibson", event.channel)
56 56
         assertEquals("zeroCool", event.user.nickname)
57 57
         assertEquals(TestConstants.otherTime, event.setTime)
@@ -63,7 +63,7 @@ internal class TopicProcessorTest {
63 63
         assertEquals(1, events.size)
64 64
 
65 65
         val event = events[0] as ChannelTopicChanged
66
-        assertEquals(TestConstants.time, event.time)
66
+        assertEquals(TestConstants.time, event.metadata.time)
67 67
         assertEquals(User("acidBurn", "acidB", "the.gibson"), event.user)
68 68
         assertEquals("#thegibson", event.channel)
69 69
         assertEquals("Hack the planet!", event.topic)

+ 1
- 1
src/test/kotlin/com/dmdirc/ktirc/messages/WelcomeProcessorTest.kt View File

@@ -22,7 +22,7 @@ internal class WelcomeProcessorTest {
22 22
         val events = processor.process(IrcMessage(emptyMap(), "thegibson.com".toByteArray(), "001", params(
23 23
                 "acidBurn", "Welcome to the Internet Relay Network, acidBurn!burn@hacktheplanet.com")))
24 24
         assertEquals(1, events.size)
25
-        assertEquals(TestConstants.time, events[0].time)
25
+        assertEquals(TestConstants.time, events[0].metadata.time)
26 26
         assertEquals("acidBurn", events[0].localNick)
27 27
         assertEquals("thegibson.com", events[0].server)
28 28
     }

+ 10
- 3
src/test/kotlin/com/dmdirc/ktirc/model/IrcMessageTest.kt View File

@@ -15,21 +15,28 @@ internal class IrcMessageTest {
15 15
     fun `Gets UTC time from ServerTime tag if present`() {
16 16
         currentTimeZoneProvider = { ZoneId.of("Z") }
17 17
         val message = IrcMessage(hashMapOf(MessageTag.ServerTime to "1995-09-15T09:00:00.0000Z"), null, "", emptyList())
18
-        assertEquals(LocalDateTime.parse("1995-09-15T09:00:00"), message.time)
18
+        assertEquals(LocalDateTime.parse("1995-09-15T09:00:00"), message.metadata.time)
19 19
     }
20 20
 
21 21
     @Test
22 22
     fun `Converts time in ServerTime tag to local timezone`() {
23 23
         currentTimeZoneProvider = { ZoneId.of("America/New_York") }
24 24
         val message = IrcMessage(hashMapOf(MessageTag.ServerTime to "1995-09-15T09:00:00.0000Z"), null, "", emptyList())
25
-        assertEquals(LocalDateTime.parse("1995-09-15T05:00:00"), message.time)
25
+        assertEquals(LocalDateTime.parse("1995-09-15T05:00:00"), message.metadata.time)
26 26
     }
27 27
 
28 28
     @Test
29 29
     fun `Uses current local time if no tag present`() {
30 30
         currentTimeProvider = { TestConstants.time }
31 31
         val message = IrcMessage(emptyMap(), null, "", emptyList())
32
-        assertEquals(LocalDateTime.parse("1995-09-15T09:00:00"), message.time)
32
+        assertEquals(LocalDateTime.parse("1995-09-15T09:00:00"), message.metadata.time)
33
+    }
34
+
35
+    @Test
36
+    fun `populates batch field if present`() {
37
+        currentTimeProvider = { TestConstants.time }
38
+        val message = IrcMessage(hashMapOf(MessageTag.Batch to "abc123"), null, "", emptyList())
39
+        assertEquals("abc123", message.metadata.batchId)
33 40
     }
34 41
 
35 42
     @Test

Loading…
Cancel
Save