Arsnael commented on a change in pull request #391:
URL: https://github.com/apache/james-project/pull/391#discussion_r629092067
##########
File path:
server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala
##########
@@ -179,6 +229,88 @@ trait CustomMethodContract {
.build
}
+ @Test
+ def
pushShouldSupportCustomTypeNameAndIntStateWithDataTypesAreMyTypeName(server:
GuiceJamesServer): Unit = {
Review comment:
```suggestion
def
pushShouldSupportCustomTypeNameAndIntStateWhenDataTypesAreMyTypeName(server:
GuiceJamesServer): Unit = {
```
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
##########
@@ -44,10 +41,7 @@ case object MailboxTypeName extends TypeName {
case _ => None
}
- override def parseState(string: String): Either[IllegalArgumentException,
UuidState] = Try(UUID.fromString(string))
- .toEither
- .map(UuidState(_))
- .left.map(new IllegalArgumentException(_))
+ override def parseState(string: String): Either[IllegalArgumentException,
UuidState] = UuidState.parse(string)
Review comment:
You override this method with the same syntax in every of your
subclasses... Why not defining this only once as a default method instead in
your `TypeName` trait?
##########
File path:
server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala
##########
@@ -179,6 +229,88 @@ trait CustomMethodContract {
.build
}
+ @Test
+ def
pushShouldSupportCustomTypeNameAndIntStateWithDataTypesAreMyTypeName(server:
GuiceJamesServer): Unit = {
+ val accountId: AccountId = AccountId.fromUsername(BOB)
+ val intState = IntState.fromString("1")
+ val stateChangeEvent: StateChangeEvent = StateChangeEvent(eventId =
CustomMethodContract.eventId, username = BOB, map = Map(CustomTypeName ->
intState))
+ Thread.sleep(100)
+
+ val response: Either[String, String] =
+ authenticatedRequest(server)
+ .response(asWebSocket[Identity, String] {
+ ws =>
+ ws.send(WebSocketFrame.text(
+ """{
+ | "@type": "WebSocketPushEnable",
+ | "dataTypes": ["MyTypeName"]
+ |}""".stripMargin))
+
+ Thread.sleep(100)
+
+ server.getProbe(classOf[JmapEventBusProbe])
+ .emitStateChange(stateChangeEvent, accountId)
+
+ ws.receive()
+ .map { case t: Text => t.payload }
+ })
+ .send(backend)
+ .body
+
+ Thread.sleep(100)
+
+ assertThatJson(response.toOption.get)
+ .isEqualTo("""{
+ | "@type": "StateChange",
+ | "changed": {
+ |
"29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6": {
+ | "MyTypeName": "1"
+ | }
+ | }
+ |}""".stripMargin)
+ }
+
+ @Test
+ def pushShouldSupportCustomTypeNameAndIntStateWithDataTypesAreNull(server:
GuiceJamesServer): Unit = {
Review comment:
```suggestion
def pushShouldSupportCustomTypeNameAndIntStateWhenDataTypesAreNull(server:
GuiceJamesServer): Unit = {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]