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.
feat(AsyncAPI 2.6.0): Channel - Operation
OneOfMessages test asyncapi#126
- Loading branch information
Showing
2 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...capi-core/src/test/kotlin/com/asyncapi/v2/_6_0/model/channel/message/OneOfMessagesTest.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,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() | ||
)) | ||
} | ||
} | ||
|
||
} |
172 changes: 172 additions & 0 deletions
172
asyncapi-core/src/test/resources/json/2.6.0/model/channel/message/oneOfMessages.json
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,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" } | ||
] | ||
} | ||
] | ||
} |