Skip to content

Commit

Permalink
feat(AsyncAPI 2.6.0): Channel - Operation
Browse files Browse the repository at this point in the history
OneOfMessages test

asyncapi#126
  • Loading branch information
Pakisan committed Feb 11, 2023
1 parent 7708420 commit 5be24ee
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.asyncapi.v2._6_0.model.channel.message

import com.asyncapi.v2.ClasspathUtils
import com.asyncapi.v2._6_0.model.Reference
import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test

class OneOfMessagesTest {

private val objectMapper = ObjectMapper()

@Test
@DisplayName("Compare hand crafted model with parsed json")
fun compareModelWithParsedJson() {
val model = ClasspathUtils.readAsString("/json/2.6.0/model/channel/message/oneOfMessages.json")

Assertions.assertEquals(
objectMapper.readValue(model, OneOfMessages::class.java),
build()
)
}

companion object {
@JvmStatic
fun build(): OneOfMessages {
return OneOfMessages(listOf(
Reference("#/components/schemas/sendMessage"),
MessageTest.build()
))
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"oneOf": [
{
"$ref": "#/components/schemas/sendMessage"
},
{
"messageId": "userSignup",
"headers": {
"type": "object",
"properties": {
"correlationId": {
"description": "Correlation ID set by application",
"type": "string"
},
"applicationInstanceId": {
"description": "Unique identifier for a given instance of the publishing application",
"type": "string"
}
}
},
"payload": {
"type": "object",
"properties": {
"user": {
"$ref": "#/components/schemas/userCreate"
},
"signup": {
"$ref": "#/components/schemas/signup"
}
}
},
"correlationId": {
"description": "Default Correlation ID",
"location": "$message.header#/correlationId"
},
"schemaFormat": "application/vnd.apache.avro+json;version=1.9.0",
"contentType": "application/json",
"name": "UserSignup",
"title": "User signup",
"summary": "Action to sign a user up.",
"description": "A longer description",
"tags": [
{ "name": "user" },
{ "name": "signup" },
{ "name": "register" }
],
"externalDocs": {
"description": "User sign up rules",
"url": "messages/sign-up-rules"
},
"bindings": {
"amqp": {
"contentEncoding": "gzip",
"messageType": "user.signup",
"bindingVersion": "0.2.0"
},
"amqp1": {
"$ref": "#/components/messageBindings/amqp1"
},
"anypointmq": {
"headers": {
"type": "object",
"properties": {
"correlationId": {
"description": "Correlation ID set by application",
"type": "string"
}
}
},
"bindingVersion": "0.0.1"
},
"googlepubsub": {
"schema": {
"name": "projects/your-project/schemas/message-avro",
"type": "avro"
},
"bindingVersion": "0.1.0"
},
"http": {
"headers": {
"type": "object",
"properties": {
"Content-Type": {
"type": "string",
"enum": [
"application/json"
]
}
}
},
"bindingVersion": "0.1.0"
},
"ibmmq": {
"type": "jms",
"description": "JMS stream message",
"headers": "Content-Type: application/json",
"expiry": 0,
"bindingVersion": "0.1.0"
},
"jms": {
"$ref": "#/components/messageBindings/jms"
},
"kafka": {
"key": {
"type": "string",
"enum": [
"myKey"
]
},
"schemaIdLocation": "payload",
"schemaIdPayloadEncoding": "apicurio-new",
"schemaLookupStrategy": "TopicIdStrategy",
"bindingVersion": "0.4.0"
},
"mercure": {
"$ref": "#/components/messageBindings/mercure"
},
"mqtt": {
"bindingVersion": "0.1.0"
},
"mqtt5": {
"$ref": "#/components/messageBindings/mqtt5"
},
"nats": {
"$ref": "#/components/messageBindings/nats"
},
"pulsar": {
"$ref": "#/components/messageBindings/pulsar"
},
"redis": {
"$ref": "#/components/messageBindings/redis"
},
"sns": {
"$ref": "#/components/messageBindings/sns"
},
"solace": {
"$ref": "#/components/messageBindings/solace"
},
"sqs": {
"$ref": "#/components/messageBindings/sqs"
},
"stomp": {
"$ref": "#/components/messageBindings/stomp"
},
"ws": {
"$ref": "#/components/messageBindings/ws"
}
},
"examples": [
{
"name": "SimpleSignup",
"summary": "A simple UserSignup example message",
"headers": {
"correlationId": "my-correlation-id",
"applicationInstanceId": "myInstanceId"
},
"payload": {
"user": {
"someUserKey": "someUserValue"
},
"signup": {
"someSignupKey": "someSignupValue"
}
}
}
],
"traits": [
{ "$ref": "#/components/messageTraits/commonHeaders" }
]
}
]
}

0 comments on commit 5be24ee

Please sign in to comment.