From 67cb9545b2e02ab8091f3030e1247fada0d7d651 Mon Sep 17 00:00:00 2001 From: Pavel Bodiachevskii Date: Sun, 25 Feb 2024 16:16:32 +0400 Subject: [PATCH] test(2.6.0): check correctness of realisation by reading AsyncAPI example - Not Example https://github.com/asyncapi/jasyncapi/issues/165 --- .../com/asyncapi/examples/v2/_6_0/Not.kt | 59 +++++++++++++++++++ .../test/resources/examples/v2.6.0/not.yml | 24 ++++++++ 2 files changed, 83 insertions(+) create mode 100644 asyncapi-core/src/test/kotlin/com/asyncapi/examples/v2/_6_0/Not.kt create mode 100644 asyncapi-core/src/test/resources/examples/v2.6.0/not.yml diff --git a/asyncapi-core/src/test/kotlin/com/asyncapi/examples/v2/_6_0/Not.kt b/asyncapi-core/src/test/kotlin/com/asyncapi/examples/v2/_6_0/Not.kt new file mode 100644 index 00000000..3a108e11 --- /dev/null +++ b/asyncapi-core/src/test/kotlin/com/asyncapi/examples/v2/_6_0/Not.kt @@ -0,0 +1,59 @@ +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 Not: AbstractExampleValidationTest() { + + override fun specificationLocation(): String = "/examples/v2.6.0/not.yml" + + override fun expectedInfo(): Info { + return Info.builder() + .title("Not example") + .version("1.0.0") + .build() + } + + override fun expectedServers(): Map? = null + + override fun expectedChannels(): Map { + return mapOf( + Pair("test", ChannelItem.builder() + .publish(Operation.builder() + .message(Reference("#/components/messages/testMessages")) + .build() + ) + .build() + ) + ) + } + + override fun expectedComponents(): Components? { + return Components.builder() + .messages(mapOf( + Pair("testMessages", Message.builder() + .payload(Schema.builder().ref("#/components/schemas/testSchema").build()) + .build() + ) + )) + .schemas(mapOf( + Pair("testSchema", Schema.builder() + .type("object") + .properties(mapOf( + Pair("key", Schema.builder() + .not(Schema.builder().type("integer").build()) + .build() + ) + )) + .build() + ) + )) + .build() + } + +} \ No newline at end of file diff --git a/asyncapi-core/src/test/resources/examples/v2.6.0/not.yml b/asyncapi-core/src/test/resources/examples/v2.6.0/not.yml new file mode 100644 index 00000000..8bca9380 --- /dev/null +++ b/asyncapi-core/src/test/resources/examples/v2.6.0/not.yml @@ -0,0 +1,24 @@ +asyncapi: "2.6.0" +info: + title: Not example + version: '1.0.0' + +channels: + test: + publish: + message: + $ref: '#/components/messages/testMessages' + +components: + messages: + testMessages: + payload: + $ref: "#/components/schemas/testSchema" + + schemas: + testSchema: + type: object + properties: + key: + not: + type: integer \ No newline at end of file