forked from asyncapi/jasyncapi
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(2.6.0): check correctness of realisation by reading AsyncAPI exa…
…mple - Simple Example asyncapi#165
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
asyncapi-core/src/test/kotlin/com/asyncapi/examples/v2/_6_0/Simple.kt
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,64 @@ | ||
package com.asyncapi.examples.v2._6_0 | ||
|
||
import com.asyncapi.v2.Reference | ||
import com.asyncapi.v2._6_0.model.channel.ChannelItem | ||
import com.asyncapi.v2._6_0.model.channel.message.Message | ||
import com.asyncapi.v2._6_0.model.channel.operation.Operation | ||
import com.asyncapi.v2._6_0.model.component.Components | ||
import com.asyncapi.v2._6_0.model.info.Info | ||
import com.asyncapi.v2.schema.Schema | ||
|
||
class Simple: AbstractExampleValidationTest() { | ||
|
||
override fun specificationLocation(): String = "/examples/v2.6.0/simple.yml" | ||
|
||
override fun expectedInfo(): Info { | ||
return Info.builder() | ||
.title("Account Service") | ||
.version("1.0.0") | ||
.description("This service is in charge of processing user signups") | ||
.build() | ||
} | ||
|
||
override fun expectedServers(): Map<String, Any>? = null | ||
|
||
override fun expectedChannels(): Map<String, Any> { | ||
return mapOf( | ||
Pair("user/signedup", ChannelItem.builder() | ||
.subscribe(Operation.builder() | ||
.message(Reference("#/components/messages/UserSignedUp")) | ||
.build() | ||
) | ||
.build() | ||
), | ||
) | ||
} | ||
|
||
override fun expectedComponents(): Components { | ||
return Components.builder() | ||
.messages(mapOf( | ||
Pair("UserSignedUp", Message.builder() | ||
.payload(Schema.builder() | ||
.type("object") | ||
.properties(mapOf( | ||
Pair("displayName", Schema.builder() | ||
.type("string") | ||
.description("Name of the user") | ||
.build() | ||
), | ||
Pair("email", Schema.builder() | ||
.type("string") | ||
.format("email") | ||
.description("Email of the user") | ||
.build() | ||
) | ||
)) | ||
.build() | ||
) | ||
.build() | ||
) | ||
)) | ||
.build() | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
asyncapi-core/src/test/resources/examples/v2.6.0/simple.yml
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,23 @@ | ||
asyncapi: "2.6.0" | ||
info: | ||
title: Account Service | ||
version: 1.0.0 | ||
description: This service is in charge of processing user signups | ||
channels: | ||
user/signedup: | ||
subscribe: | ||
message: | ||
$ref: '#/components/messages/UserSignedUp' | ||
components: | ||
messages: | ||
UserSignedUp: | ||
payload: | ||
type: object | ||
properties: | ||
displayName: | ||
type: string | ||
description: Name of the user | ||
email: | ||
type: string | ||
format: email | ||
description: Email of the user |