diff --git a/asyncapi-core/src/test/kotlin/com/asyncapi/examples/v2/_0_0/RpcServer.kt b/asyncapi-core/src/test/kotlin/com/asyncapi/examples/v2/_0_0/RpcServer.kt new file mode 100644 index 00000000..01f305a7 --- /dev/null +++ b/asyncapi-core/src/test/kotlin/com/asyncapi/examples/v2/_0_0/RpcServer.kt @@ -0,0 +1,129 @@ +package com.asyncapi.examples.v2._0_0 + +import com.asyncapi.v2._0_0.model.channel.ChannelItem +import com.asyncapi.v2._0_0.model.channel.Parameter +import com.asyncapi.v2._0_0.model.channel.message.CorrelationId +import com.asyncapi.v2._0_0.model.channel.message.Message +import com.asyncapi.v2._0_0.model.channel.operation.Operation +import com.asyncapi.v2._0_0.model.component.Components +import com.asyncapi.v2._0_0.model.info.Info +import com.asyncapi.v2._0_0.model.server.Server +import com.asyncapi.v2.binding.channel.amqp.AMQPChannelBinding +import com.asyncapi.v2.binding.channel.amqp.AMQPChannelType +import com.asyncapi.v2.binding.channel.amqp.queue.AMQPChannelQueueProperties +import com.asyncapi.v2.binding.operation.amqp.AMQPOperationBinding +import com.asyncapi.v2.schema.Schema + +class RpcServer: AbstractExampleValidationTest() { + + override fun specificationLocation(): String = "/examples/v2.0.0/rpc-server.yml" + + override fun expectedId(): String = "urn:example:rpcserver" + + override fun expectedDefaultContentType(): String = "application/json" + + override fun expectedInfo(): Info { + return Info.builder() + .title("RPC Server Example") + .version("1.0.0") + .description("This example demonstrates how to define an RPC server." + ) + .build() + } + + override fun expectedServers(): Map { + return mapOf( + Pair("production", Server.builder() + .url("rabbitmq.example.org") + .protocol("amqp") + .build() + ) + ) + } + + override fun expectedChannels(): Map { + return mapOf( + Pair("{queue}", ChannelItem.builder() + .parameters(mapOf( + Pair("queue", Parameter.builder() + .schema(Schema.builder() + .type("string") + .pattern("^amq\\\\.gen\\\\-.+\$") + .build()) + .build() + ), + )) + .bindings(mapOf( + Pair("amqp", AMQPChannelBinding.builder() + .`is`(AMQPChannelType.QUEUE) + .queue(AMQPChannelQueueProperties.builder() + .exclusive(true) + .build() + ) + .build() + ) + )) + .subscribe(Operation.builder() + .operationId("sendSumResult") + .bindings(mapOf( + Pair("amqp", AMQPOperationBinding.builder() + .ack(true) + .build() + ) + )) + .message(Message.builder() + .correlationId(CorrelationId(null, "\$message.header#/correlation_id")) + .payload(Schema.builder() + .type("object") + .properties(mapOf( + Pair("result", Schema.builder() + .type("number") + .examples(listOf(7)) + .build()) + )) + .build() + ) + .build() + ) + .build() + ) + .build() + ), + Pair("rpc_queue", ChannelItem.builder() + .bindings(mapOf( + Pair("amqp", AMQPChannelBinding.builder() + .`is`(AMQPChannelType.QUEUE) + .queue(AMQPChannelQueueProperties.builder() + .durable(false) + .build() + ) + .build() + ) + )) + .publish(Operation.builder() + .operationId("sum") + .message(Message.builder() + .correlationId(CorrelationId(null, "\$message.header#/correlation_id")) + .payload(Schema.builder() + .type("object") + .properties(mapOf( + Pair("numbers", Schema.builder() + .type("array") + .items(Schema.builder().type("number").build()) + .examples(listOf(listOf(4, 3))) + .build()) + )) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + ) + } + + override fun expectedComponents(): Components? = null + +} \ No newline at end of file diff --git a/asyncapi-core/src/test/resources/examples/v2.0.0/rpc-server.yml b/asyncapi-core/src/test/resources/examples/v2.0.0/rpc-server.yml new file mode 100644 index 00000000..4794b5f9 --- /dev/null +++ b/asyncapi-core/src/test/resources/examples/v2.0.0/rpc-server.yml @@ -0,0 +1,62 @@ +asyncapi: "2.0.0" +id: 'urn:example:rpcserver' +defaultContentType: application/json + +info: + title: RPC Server Example + description: This example demonstrates how to define an RPC server. + version: '1.0.0' + +servers: + production: + url: rabbitmq.example.org + protocol: amqp + +channels: + '{queue}': + parameters: + queue: + schema: + type: string + pattern: '^amq\\.gen\\-.+$' + bindings: + amqp: + is: queue + queue: + exclusive: true + subscribe: + operationId: sendSumResult + bindings: + amqp: + ack: true + message: + correlationId: + location: $message.header#/correlation_id + payload: + type: object + properties: + result: + type: number + examples: + - 7 + + rpc_queue: + bindings: + amqp: + is: queue + queue: + durable: false + publish: + operationId: sum + message: + correlationId: + location: $message.header#/correlation_id + payload: + type: object + properties: + numbers: + type: array + items: + type: number + examples: + - [4,3] \ No newline at end of file