Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
a test compatibility toolkit to test the json encoding/decoding implementation
- Loading branch information
1 parent
8787a08
commit cd80dc7
Showing
16 changed files
with
182 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 23 additions & 1 deletion
24
circe/src/test/scala/de/martinpallmann/gchat/circe/IntegrationTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
/* | ||
* Copyright 2020 Martin Pallmann | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package de.martinpallmann.gchat.circe | ||
|
||
import de.martinpallmann.gchat.BotRequest | ||
import de.martinpallmann.gchat.gen.Message | ||
import de.martinpallmann.gchat.tck.Tck | ||
import io.circe.Json | ||
import io.circe.parser._ | ||
|
||
import scala.util.Try | ||
|
||
class IntegrationTest extends Tck[Json] with BotRequestDecoder { | ||
class IntegrationTest | ||
extends Tck[Json] | ||
with BotRequestDecoder | ||
with MessageEncoder { | ||
|
||
def parseJson: String => Try[Json] = parse(_).toTry | ||
|
||
def decode: Json => Try[BotRequest] = _.as[BotRequest](decodeBotRequest).toTry | ||
|
||
def encode: Message => Json = encodeMessage.apply | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
added_to_space | ||
removed_from_space | ||
message |
Empty file.
27 changes: 27 additions & 0 deletions
27
tck/src/main/scala/de/martinpallmann/gchat/tck/BotRequestTestCase.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2020 Martin Pallmann | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package de.martinpallmann.gchat.tck | ||
|
||
import de.martinpallmann.gchat.BotRequest | ||
|
||
import scala.language.implicitConversions | ||
|
||
abstract private[tck] class BotRequestTestCase { | ||
protected final implicit def anyToOption[A](a: A): Option[A] = Option(a) | ||
def request: BotRequest | ||
override def toString: String = request.toString | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 0 additions & 68 deletions
68
tck/src/main/scala/de/martinpallmann/gchat/tck/event/MessageTestCase.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
tck/src/main/scala/de/martinpallmann/gchat/tck/request/MessageTestCase.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2020 Martin Pallmann | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package de.martinpallmann.gchat.tck.request | ||
|
||
import java.time.Instant | ||
|
||
import de.martinpallmann.gchat.BotRequest | ||
import de.martinpallmann.gchat.gen._ | ||
import de.martinpallmann.gchat.tck.BotRequestTestCase | ||
|
||
class MessageTestCase extends BotRequestTestCase { | ||
def request: BotRequest = | ||
BotRequest.MessageReceived( | ||
Instant.parse("2017-03-02T19:02:59.910959Z"), | ||
Space( | ||
name = "spaces/AAAAAAAAAAA", | ||
displayName = "Chuck Norris Discussion Room", | ||
`type` = SpaceType.Room | ||
), | ||
Message( | ||
name = "spaces/AAAAAAAAAAA/messages/CCCCCCCCCCC", | ||
sender = User( | ||
name = "users/12345678901234567890", | ||
displayName = "Chuck Norris" | ||
), | ||
createTime = Instant.parse("2017-03-02T19:02:59.910959Z"), | ||
text = "@TestBot Violence is my last option.", | ||
argumentText = " Violence is my last option.", | ||
thread = Thread(name = "spaces/AAAAAAAAAAA/threads/BBBBBBBBBBB"), | ||
annotations = List( | ||
Annotation( | ||
length = 8, | ||
startIndex = 0, | ||
userMention = UserMentionMetadata( | ||
`type` = UserMentionMetadataType.Mention, | ||
user = User( | ||
displayName = "TestBot", | ||
name = "users/1234567890987654321", | ||
`type` = UserType.Bot | ||
) | ||
), | ||
`type` = AnnotationType.UserMention | ||
) | ||
) | ||
), | ||
User(name = "users/12345678901234567890", displayName = "Chuck Norris") | ||
) | ||
} |
Oops, something went wrong.