diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 00f350f1f..334059ea1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,6 +43,7 @@ Contributing follows mostly the following steps: - Add/Adapt tests as necessary 4. Run the tests - Run tests locally via `./gradlew test` (includes `unitTest` and `integrationTest` targets, which executes faster) + - In case there are expected changes to the generated asyncapi artifacts, run `./gradlew test updateAsyncApiJson` to update them using the current (actual) files 5. Run the code formatter - We use the palantir code style and disallow wildcard imports - Run `./gradlew spotlessApply` to fix most things automatically diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/AsyncApiDocumentIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/ApplicationIntegrationTest.java similarity index 51% rename from springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/AsyncApiDocumentIntegrationTest.java rename to springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/ApplicationIntegrationTest.java index 2f613ac34..2897ca7f8 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/AsyncApiDocumentIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/ApplicationIntegrationTest.java @@ -1,13 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.core.integrationtests; +package io.github.springwolf.core.integrationtests.application; import io.github.springwolf.asyncapi.v3.jackson.AsyncApiSerializerService; import io.github.springwolf.asyncapi.v3.model.AsyncAPI; import io.github.springwolf.asyncapi.v3.model.channel.message.Message; -import io.github.springwolf.asyncapi.v3.model.channel.message.MessageObject; import io.github.springwolf.asyncapi.v3.model.components.ComponentSchema; -import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; -import io.github.springwolf.asyncapi.v3.model.schema.SchemaReference; import io.github.springwolf.core.asyncapi.AsyncApiService; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersNotDocumented; import io.github.springwolf.core.fixtures.MinimalIntegrationTestContextConfiguration; @@ -15,7 +12,7 @@ import io.github.springwolf.core.integrationtests.application.listener.ListenerApplication; import io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication; import io.github.springwolf.core.integrationtests.application.publisher.PublisherApplication; -import io.github.springwolf.core.integrationtests.application.schema.SchemaEnumAsRefApplication; +import io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication; import io.github.springwolf.core.standalone.DefaultStandaloneApplication; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -25,11 +22,13 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.context.TestPropertySource; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -public class AsyncApiDocumentIntegrationTest { +public class ApplicationIntegrationTest { @Nested @SpringBootTest(classes = ListenerApplication.class) @@ -48,57 +47,22 @@ class ListenerAnnotationTest { @Autowired private AsyncApiService asyncApiService; + @Autowired + private AsyncApiSerializerService asyncApiSerializerService; + @Test - void asyncListenerAnnotationIsFound() { + void asyncListenerAnnotationIsFound() throws Exception { + // when AsyncAPI asyncAPI = asyncApiService.getAsyncAPI(); - assertThat(asyncAPI).isNotNull(); - assertThat(asyncAPI.getChannels().keySet()) - .containsExactlyInAnyOrder("listener-channel", "listener-class-channel"); - assertThat(asyncAPI.getChannels().get("listener-channel").getMessages()) - .containsOnlyKeys( - "java.lang.String", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(asyncAPI.getChannels().get("listener-class-channel").getMessages()) - .containsOnlyKeys("java.lang.Integer"); - assertThat(asyncAPI.getOperations()) - .containsOnlyKeys( - "listener-channel_receive_listen", - "listener-channel_receive_listen2", - "listener-channel_receive_listen3", - "listener-channel_receive_listen4", - "listener-class-channel_receive_listen"); - assertThat(asyncAPI.getComponents().getMessages()) - .containsOnlyKeys( - "java.lang.String", - "java.lang.Integer", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(asyncAPI.getComponents().getSchemas()) - .containsOnlyKeys( - "HeadersNotDocumented", - "java.lang.String", - "java.lang.Integer", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Bar", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - - MessageObject stringMessage = - (MessageObject) asyncAPI.getComponents().getMessages().get("java.lang.String"); - assertThat(stringMessage.getPayload().getMultiFormatSchema().getSchema()) - .isInstanceOf(SchemaObject.class); - SchemaObject inlineStringSchema = (SchemaObject) - stringMessage.getPayload().getMultiFormatSchema().getSchema(); - assertThat(inlineStringSchema.getType()).containsExactly("string"); - - MessageObject fooMessage = (MessageObject) asyncAPI.getComponents() - .getMessages() - .get("io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(fooMessage.getPayload().getMultiFormatSchema().getSchema()) - .isInstanceOf(SchemaReference.class); - SchemaReference fooSchemaRef = (SchemaReference) - fooMessage.getPayload().getMultiFormatSchema().getSchema(); - assertThat(fooSchemaRef.getRef()) - .isEqualTo( - "#/components/schemas/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); + // then + String actual = asyncApiSerializerService.toJsonString(asyncAPI); + Files.writeString( + Path.of("src", "test", "resources", "application", "asyncapi.listener.actual.json"), actual); + + String expected = + Files.readString(Path.of("src", "test", "resources", "application", "asyncapi.listener.json")); + assertThat(expected).isEqualToIgnoringWhitespace(actual); } @Test @@ -131,57 +95,22 @@ class PublisherAnnotationTest { @Autowired private AsyncApiService asyncApiService; + @Autowired + private AsyncApiSerializerService asyncApiSerializerService; + @Test - void asyncPublisherAnnotationIsFound() { + void asyncPublisherAnnotationIsFound() throws Exception { + // when AsyncAPI asyncAPI = asyncApiService.getAsyncAPI(); - assertThat(asyncAPI).isNotNull(); - assertThat(asyncAPI.getChannels().keySet()) - .containsExactlyInAnyOrder("publisher-channel", "publisher-class-channel"); - assertThat(asyncAPI.getChannels().get("publisher-channel").getMessages()) - .containsOnlyKeys( - "java.lang.String", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(asyncAPI.getChannels().get("publisher-class-channel").getMessages()) - .containsOnlyKeys("java.lang.Integer"); - assertThat(asyncAPI.getOperations()) - .containsOnlyKeys( - "publisher-channel_send_publish", - "publisher-channel_send_publish2", - "publisher-channel_send_publish3", - "publisher-channel_send_publish4", - "publisher-class-channel_send_publish"); - assertThat(asyncAPI.getComponents().getMessages()) - .containsOnlyKeys( - "java.lang.String", - "java.lang.Integer", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(asyncAPI.getComponents().getSchemas()) - .containsOnlyKeys( - "HeadersNotDocumented", - "java.lang.String", - "java.lang.Integer", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Bar", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - - MessageObject stringMessage = - (MessageObject) asyncAPI.getComponents().getMessages().get("java.lang.String"); - assertThat(stringMessage.getPayload().getMultiFormatSchema().getSchema()) - .isInstanceOf(SchemaObject.class); - SchemaObject inlineStringSchema = (SchemaObject) - stringMessage.getPayload().getMultiFormatSchema().getSchema(); - assertThat(inlineStringSchema.getType()).containsExactly("string"); - - MessageObject fooMessage = (MessageObject) asyncAPI.getComponents() - .getMessages() - .get("io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(fooMessage.getPayload().getMultiFormatSchema().getSchema()) - .isInstanceOf(SchemaReference.class); - SchemaReference fooSchemaRef = (SchemaReference) - fooMessage.getPayload().getMultiFormatSchema().getSchema(); - assertThat(fooSchemaRef.getRef()) - .isEqualTo( - "#/components/schemas/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); + // then + String actual = asyncApiSerializerService.toJsonString(asyncAPI); + Files.writeString( + Path.of("src", "test", "resources", "application", "asyncapi.publisher.actual.json"), actual); + + String expected = + Files.readString(Path.of("src", "test", "resources", "application", "asyncapi.publisher.json")); + assertThat(expected).isEqualToIgnoringWhitespace(actual); } @Test @@ -212,10 +141,22 @@ class FqnTest { @Autowired private AsyncApiSerializerService asyncApiSerializerService; + @Test + void matchesCheckedInArtifact() throws Exception { + // when + AsyncAPI asyncAPI = asyncApiService.getAsyncAPI(); + + // then + String actual = asyncApiSerializerService.toJsonString(asyncAPI); + Files.writeString(Path.of("src", "test", "resources", "application", "asyncapi.fqn.actual.json"), actual); + + String expected = Files.readString(Path.of("src", "test", "resources", "application", "asyncapi.fqn.json")); + assertThat(expected).isEqualToIgnoringWhitespace(actual); + } + @Test void allClassesHaveSimpleNameNotFullQualifiedTest() throws Exception { AsyncAPI asyncAPI = asyncApiService.getAsyncAPI(); - assertThat(asyncAPI).isNotNull(); String serialized = asyncApiSerializerService.toJsonString(asyncAPI); assertThat(serialized) @@ -244,6 +185,24 @@ class PolymorphicPayloadTest { @Autowired private AsyncApiService asyncApiService; + @Autowired + private AsyncApiSerializerService asyncApiSerializerService; + + @Test + void matchesCheckedInArtifact() throws Exception { + // when + AsyncAPI asyncAPI = asyncApiService.getAsyncAPI(); + + // then + String actual = asyncApiSerializerService.toJsonString(asyncAPI); + Files.writeString( + Path.of("src", "test", "resources", "application", "asyncapi.polymorphic.actual.json"), actual); + + String expected = + Files.readString(Path.of("src", "test", "resources", "application", "asyncapi.polymorphic.json")); + assertThat(expected).isEqualToIgnoringWhitespace(actual); + } + @Test void polymorphicDiscriminatorFieldIsHandled() { // when @@ -310,19 +269,35 @@ void polymorphicDiscriminatorFieldIsHandled() { @MinimalIntegrationTestContextConfiguration @TestPropertySource( properties = { - "springwolf.docket.base-package=io.github.springwolf.core.integrationtests.application.schema", + "springwolf.docket.base-package=io.github.springwolf.core.integrationtests.application.ref", }) class SchemaAsRefTest { @Autowired private AsyncApiService asyncApiService; + @Autowired + private AsyncApiSerializerService asyncApiSerializerService; + + @Test + void matchesCheckedInArtifact() throws Exception { + // when + AsyncAPI asyncAPI = asyncApiService.getAsyncAPI(); + + // then + String actual = asyncApiSerializerService.toJsonString(asyncAPI); + Files.writeString(Path.of("src", "test", "resources", "application", "asyncapi.ref.actual.json"), actual); + + String expected = Files.readString(Path.of("src", "test", "resources", "application", "asyncapi.ref.json")); + assertThat(expected).isEqualToIgnoringWhitespace(actual); + } + @Test void enumAsRefIsHandled() { // given String myEnumRootSchemaName = - "io.github.springwolf.core.integrationtests.application.schema.SchemaEnumAsRefApplication.Schemas.MyEnumRoot"; + "io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumRoot"; String myEnumObjectSchemaName = - "io.github.springwolf.core.integrationtests.application.schema.SchemaEnumAsRefApplication.Schemas.MyEnumObject"; + "io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumObject"; // when AsyncAPI asyncAPI = asyncApiService.getAsyncAPI(); @@ -348,76 +323,6 @@ void enumAsRefIsHandled() { } } - @Nested - @SpringBootTest(classes = ListenerApplication.class) - @MinimalIntegrationTestContextConfiguration - @TestPropertySource( - properties = { - "springwolf.docket.base-package=io.github.springwolf.core.integrationtests.application.listener", - "springwolf.docket.group-configs[0].group=FooMessage", - "springwolf.docket.group-configs[0].action-to-match=", - "springwolf.docket.group-configs[0].channel-name-to-match=", - "springwolf.docket.group-configs[0].message-name-to-match=.*Foo", - "springwolf.docket.group-configs[1].group=all & everything", - "springwolf.docket.group-configs[1].action-to-match=", - "springwolf.docket.group-configs[1].channel-name-to-match=.*", - "springwolf.docket.group-configs[1].message-name-to-match=", - }) - class GroupingTest { - @Autowired - private AsyncApiService asyncApiService; - - @Test - void shouldFindOnlyForGroupFoo() { - AsyncAPI asyncAPI = asyncApiService.getForGroupName("FooMessage").get(); - - assertThat(asyncAPI.getChannels().keySet()).containsExactlyInAnyOrder("listener-channel"); - assertThat(asyncAPI.getChannels().get("listener-channel").getMessages()) - .containsOnlyKeys( - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(asyncAPI.getOperations()) - .containsOnlyKeys("listener-channel_receive_listen3", "listener-channel_receive_listen4"); - assertThat(asyncAPI.getComponents().getMessages()) - .containsOnlyKeys( - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(asyncAPI.getComponents().getSchemas()) - .containsOnlyKeys( - "HeadersNotDocumented", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Bar", - "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - - MessageObject fooMessage = (MessageObject) asyncAPI.getComponents() - .getMessages() - .get("io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - assertThat(fooMessage.getPayload().getMultiFormatSchema().getSchema()) - .isInstanceOf(SchemaReference.class); - SchemaReference fooSchemaRef = (SchemaReference) - fooMessage.getPayload().getMultiFormatSchema().getSchema(); - assertThat(fooSchemaRef.getRef()) - .isEqualTo( - "#/components/schemas/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); - } - - @Test - void shouldFindAllForGroupAll() { - // given - AsyncAPI fullApi = asyncApiService.getAsyncAPI(); - - // when - AsyncAPI asyncAPIOpt = - asyncApiService.getForGroupName("all & everything").get(); - - // then - - // String and Integer get filtered. - // Question: Why are they in the fullApi in the first place, if not referenced? (inline schema) - fullApi.getComponents().getSchemas().remove(String.class.getName()); - fullApi.getComponents().getSchemas().remove(Integer.class.getName()); - - assertThat(asyncAPIOpt).isEqualTo(fullApi); - } - } - private AsyncApiService createStandaloneAsyncApiService(ConfigurableEnvironment environment, String basePackage) { DefaultStandaloneApplication standaloneApplication = DefaultStandaloneApplication.builder() .addScanPackage(basePackage) diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/GroupingIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/GroupingIntegrationTest.java new file mode 100644 index 000000000..c40d0d886 --- /dev/null +++ b/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/GroupingIntegrationTest.java @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: Apache-2.0 +package io.github.springwolf.core.integrationtests.application; + +import io.github.springwolf.asyncapi.v3.model.AsyncAPI; +import io.github.springwolf.asyncapi.v3.model.channel.message.MessageObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaReference; +import io.github.springwolf.core.asyncapi.AsyncApiService; +import io.github.springwolf.core.fixtures.MinimalIntegrationTestContextConfiguration; +import io.github.springwolf.core.integrationtests.application.listener.ListenerApplication; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; + +import static org.assertj.core.api.Assertions.assertThat; + +@Nested +@SpringBootTest(classes = ListenerApplication.class) +@MinimalIntegrationTestContextConfiguration +@TestPropertySource( + properties = { + "springwolf.docket.base-package=io.github.springwolf.core.integrationtests.application.listener", + "springwolf.docket.group-configs[0].group=FooMessage", + "springwolf.docket.group-configs[0].action-to-match=", + "springwolf.docket.group-configs[0].channel-name-to-match=", + "springwolf.docket.group-configs[0].message-name-to-match=.*Foo", + "springwolf.docket.group-configs[1].group=all & everything", + "springwolf.docket.group-configs[1].action-to-match=", + "springwolf.docket.group-configs[1].channel-name-to-match=.*", + "springwolf.docket.group-configs[1].message-name-to-match=", + }) +class GroupingIntegrationTest { + @Autowired + private AsyncApiService asyncApiService; + + @Test + void shouldFindOnlyForGroupFoo() { + AsyncAPI asyncAPI = asyncApiService.getForGroupName("FooMessage").get(); + + assertThat(asyncAPI.getChannels().keySet()).containsExactlyInAnyOrder("listener-channel"); + assertThat(asyncAPI.getChannels().get("listener-channel").getMessages()) + .containsOnlyKeys( + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); + assertThat(asyncAPI.getOperations()) + .containsOnlyKeys("listener-channel_receive_listen3", "listener-channel_receive_listen4"); + assertThat(asyncAPI.getComponents().getMessages()) + .containsOnlyKeys( + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); + assertThat(asyncAPI.getComponents().getSchemas()) + .containsOnlyKeys( + "HeadersNotDocumented", + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Bar", + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); + + MessageObject fooMessage = (MessageObject) asyncAPI.getComponents() + .getMessages() + .get("io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); + assertThat(fooMessage.getPayload().getMultiFormatSchema().getSchema()).isInstanceOf(SchemaReference.class); + SchemaReference fooSchemaRef = + (SchemaReference) fooMessage.getPayload().getMultiFormatSchema().getSchema(); + assertThat(fooSchemaRef.getRef()) + .isEqualTo( + "#/components/schemas/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo"); + } + + @Test + void shouldFindAllForGroupAll() { + // given + AsyncAPI fullApi = asyncApiService.getAsyncAPI(); + + // when + AsyncAPI asyncAPIOpt = + asyncApiService.getForGroupName("all & everything").get(); + + // then + + // String and Integer get filtered. + // Question: Why are they in the fullApi in the first place, if not referenced? (inline schema) + fullApi.getComponents().getSchemas().remove(String.class.getName()); + fullApi.getComponents().getSchemas().remove(Integer.class.getName()); + + assertThat(asyncAPIOpt).isEqualTo(fullApi); + } +} diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/schema/SchemaEnumAsRefApplication.java b/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/ref/SchemaEnumAsRefApplication.java similarity index 92% rename from springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/schema/SchemaEnumAsRefApplication.java rename to springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/ref/SchemaEnumAsRefApplication.java index 1a35a5e15..e27073815 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/schema/SchemaEnumAsRefApplication.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/integrationtests/application/ref/SchemaEnumAsRefApplication.java @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.core.integrationtests.application.schema; +package io.github.springwolf.core.integrationtests.application.ref; import io.github.springwolf.core.asyncapi.annotations.AsyncListener; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/standalone/DefaultStandaloneApplicationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/standalone/DefaultStandaloneApplicationTest.java index b4b21c172..8b0608c7d 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/standalone/DefaultStandaloneApplicationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/standalone/DefaultStandaloneApplicationTest.java @@ -62,7 +62,7 @@ void shouldCreateStandaloneFactoryForBasicApplicationWithProfile() { .getAsyncAPI() .getInfo() .getTitle()) - .isEqualTo("Springwolf-core-properties"); + .isEqualTo("Springwolf-core-standalone"); } @Test diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/standalone/StandaloneEnvironmentLoaderTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/standalone/StandaloneEnvironmentLoaderTest.java index bbac7c3be..36cee79b0 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/standalone/StandaloneEnvironmentLoaderTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/standalone/StandaloneEnvironmentLoaderTest.java @@ -27,6 +27,6 @@ void shouldLoadStandaloneProfileIncludingPropertyFile() { // then assertThat(environment.getActiveProfiles()).containsExactly("standalone"); - assertThat(environment.getProperty("spring.application.name")).isEqualTo("Springwolf-core-properties"); + assertThat(environment.getProperty("spring.application.name")).isEqualTo("Springwolf-core-standalone"); } } diff --git a/springwolf-core/src/test/resources/application-standalone.properties b/springwolf-core/src/test/resources/application-standalone.properties index 49738a05e..18a8f6bb9 100644 --- a/springwolf-core/src/test/resources/application-standalone.properties +++ b/springwolf-core/src/test/resources/application-standalone.properties @@ -1 +1 @@ -spring.application.name=Springwolf-core-properties \ No newline at end of file +spring.application.name=Springwolf-core-standalone \ No newline at end of file diff --git a/springwolf-core/src/test/resources/application.properties b/springwolf-core/src/test/resources/application.properties index b6d5c9b54..3b4624dd4 100644 --- a/springwolf-core/src/test/resources/application.properties +++ b/springwolf-core/src/test/resources/application.properties @@ -3,6 +3,6 @@ springwolf.enabled=true springwolf.docket.base-package=io.github.springwolf.core.integrationtests springwolf.docket.info.title=${spring.application.name} springwolf.docket.info.version=1.0.0 -springwolf.docket.info.description=Springwolf example project to demonstrate springwolfs abilities +springwolf.docket.info.description=Springwolf core integration test springwolf.docket.servers.test-protocol.protocol=property-protocol springwolf.docket.servers.test-protocol.host=some-property-server:1234 diff --git a/springwolf-core/src/test/resources/application/asyncapi.fqn.json b/springwolf-core/src/test/resources/application/asyncapi.fqn.json new file mode 100644 index 000000000..6d48d0e7b --- /dev/null +++ b/springwolf-core/src/test/resources/application/asyncapi.fqn.json @@ -0,0 +1,199 @@ +{ + "asyncapi": "3.0.0", + "id": "urn:io:github:springwolf:example", + "info": { + "title": "Info title was loaded from spring properties", + "version": "1.0.0", + "description": "Springwolf core integration test", + "x-generator": "springwolf" + }, + "defaultContentType": "application/json", + "servers": { + "test-protocol": { + "host": "some-server:1234", + "protocol": "test" + } + }, + "channels": { + "listener-channel": { + "address": "listener-channel", + "messages": { + "Foo": { + "$ref": "#/components/messages/Foo" + }, + "integer": { + "$ref": "#/components/messages/integer" + }, + "string": { + "$ref": "#/components/messages/string" + } + }, + "bindings": { } + } + }, + "components": { + "schemas": { + "Bar": { + "title": "Bar", + "type": "object", + "properties": { + "aFieldInBarRecord": { + "type": "string" + } + }, + "examples": [ + { + "aFieldInBarRecord": "string" + } + ] + }, + "Foo": { + "title": "Foo", + "type": "object", + "properties": { + "aFieldInFooRecord": { + "$ref": "#/components/schemas/Bar" + } + }, + "examples": [ + { + "aFieldInFooRecord": { + "aFieldInBarRecord": "string" + } + } + ] + }, + "HeadersNotDocumented": { + "title": "HeadersNotDocumented", + "type": "object", + "properties": { }, + "description": "There can be headers, but they are not explicitly documented.", + "examples": [ + { } + ] + }, + "integer": { + "type": "integer", + "format": "int32", + "examples": [ + 0 + ] + }, + "string": { + "type": "string", + "examples": [ + "\"string\"" + ] + } + }, + "messages": { + "Foo": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/Foo" + } + }, + "name": "Foo", + "title": "Foo", + "bindings": { } + }, + "integer": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "integer", + "format": "int32", + "examples": [ + 0 + ] + } + }, + "name": "integer", + "title": "integer", + "bindings": { } + }, + "string": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "string", + "examples": [ + "\"string\"" + ] + } + }, + "name": "string", + "title": "string", + "bindings": { } + } + } + }, + "operations": { + "listener-channel_receive_listen": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/string" + } + ] + }, + "listener-channel_receive_listen2": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/string" + } + ] + }, + "listener-channel_receive_listen3": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/Foo" + } + ] + }, + "listener-channel_receive_listen4": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/integer" + } + ] + } + } +} \ No newline at end of file diff --git a/springwolf-core/src/test/resources/application/asyncapi.listener.json b/springwolf-core/src/test/resources/application/asyncapi.listener.json new file mode 100644 index 000000000..c23d4f6f0 --- /dev/null +++ b/springwolf-core/src/test/resources/application/asyncapi.listener.json @@ -0,0 +1,219 @@ +{ + "asyncapi": "3.0.0", + "id": "urn:io:github:springwolf:example", + "info": { + "title": "Info title was loaded from spring properties", + "version": "1.0.0", + "description": "Springwolf core integration test", + "x-generator": "springwolf" + }, + "defaultContentType": "application/json", + "servers": { + "test-protocol": { + "host": "some-server:1234", + "protocol": "test" + } + }, + "channels": { + "listener-channel": { + "address": "listener-channel", + "messages": { + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo": { + "$ref": "#/components/messages/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo" + }, + "java.lang.String": { + "$ref": "#/components/messages/java.lang.String" + } + }, + "bindings": { } + }, + "listener-class-channel": { + "address": "listener-class-channel", + "messages": { + "java.lang.Integer": { + "$ref": "#/components/messages/java.lang.Integer" + } + }, + "bindings": { } + } + }, + "components": { + "schemas": { + "HeadersNotDocumented": { + "title": "HeadersNotDocumented", + "type": "object", + "properties": { }, + "description": "There can be headers, but they are not explicitly documented.", + "examples": [ + { } + ] + }, + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Bar": { + "title": "Bar", + "type": "object", + "properties": { + "aFieldInBarRecord": { + "type": "string" + } + }, + "examples": [ + { + "aFieldInBarRecord": "string" + } + ] + }, + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo": { + "title": "Foo", + "type": "object", + "properties": { + "aFieldInFooRecord": { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Bar" + } + }, + "examples": [ + { + "aFieldInFooRecord": { + "aFieldInBarRecord": "string" + } + } + ] + }, + "java.lang.Integer": { + "type": "integer", + "format": "int32", + "examples": [ + 0 + ] + }, + "java.lang.String": { + "type": "string", + "examples": [ + "\"string\"" + ] + } + }, + "messages": { + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo" + } + }, + "name": "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo", + "title": "Foo", + "bindings": { } + }, + "java.lang.Integer": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "integer", + "format": "int32", + "examples": [ + 0 + ] + } + }, + "name": "java.lang.Integer", + "title": "integer", + "bindings": { } + }, + "java.lang.String": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "string", + "examples": [ + "\"string\"" + ] + } + }, + "name": "java.lang.String", + "title": "string", + "bindings": { } + } + } + }, + "operations": { + "listener-channel_receive_listen": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/java.lang.String" + } + ] + }, + "listener-channel_receive_listen2": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/java.lang.String" + } + ] + }, + "listener-channel_receive_listen3": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo" + } + ] + }, + "listener-channel_receive_listen4": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo" + } + ] + }, + "listener-class-channel_receive_listen": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-class-channel" + }, + "title": "listener-class-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-class-channel/messages/java.lang.Integer" + } + ] + } + } +} \ No newline at end of file diff --git a/springwolf-core/src/test/resources/application/asyncapi.polymorphic.json b/springwolf-core/src/test/resources/application/asyncapi.polymorphic.json new file mode 100644 index 000000000..b07c2a6b9 --- /dev/null +++ b/springwolf-core/src/test/resources/application/asyncapi.polymorphic.json @@ -0,0 +1,158 @@ +{ + "asyncapi": "3.0.0", + "id": "urn:io:github:springwolf:example", + "info": { + "title": "Info title was loaded from spring properties", + "version": "1.0.0", + "description": "Springwolf core integration test", + "x-generator": "springwolf" + }, + "defaultContentType": "application/json", + "servers": { + "test-protocol": { + "host": "some-server:1234", + "protocol": "test" + } + }, + "channels": { + "listener-channel": { + "address": "listener-channel", + "messages": { + "io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Payload": { + "$ref": "#/components/messages/io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Payload" + } + }, + "bindings": { } + } + }, + "components": { + "schemas": { + "HeadersNotDocumented": { + "title": "HeadersNotDocumented", + "type": "object", + "properties": { }, + "description": "There can be headers, but they are not explicitly documented.", + "examples": [ + { } + ] + }, + "io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Cat": { + "type": "object", + "examples": [ + { + "catSpecificField": "string", + "type": "string" + } + ], + "allOf": [ + { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Pet" + }, + { + "type": "object", + "properties": { + "catSpecificField": { + "type": "string" + } + } + } + ] + }, + "io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Dog": { + "type": "object", + "examples": [ + { + "dogSpecificField": "string", + "type": "string" + } + ], + "allOf": [ + { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Pet" + }, + { + "type": "object", + "properties": { + "dogSpecificField": { + "type": "string" + } + } + } + ] + }, + "io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Payload": { + "title": "Payload", + "type": "object", + "properties": { + "pet": { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Pet" + } + }, + "examples": [ + { + "pet": { + "dogSpecificField": "string", + "type": "string" + } + } + ] + }, + "io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Pet": { + "discriminator": "type", + "title": "Pet", + "type": "object", + "properties": { + "type": { + "type": "string" + } + }, + "examples": [ + { + "dogSpecificField": "string", + "type": "string" + } + ], + "oneOf": [ + { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Dog" + }, + { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Cat" + } + ] + } + }, + "messages": { + "io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Payload": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Payload" + } + }, + "name": "io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Payload", + "title": "Payload", + "bindings": { } + } + } + }, + "operations": { + "listener-channel_receive_listen": { + "action": "receive", + "channel": { + "$ref": "#/channels/listener-channel" + }, + "title": "listener-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/listener-channel/messages/io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication.Payload" + } + ] + } + } +} \ No newline at end of file diff --git a/springwolf-core/src/test/resources/application/asyncapi.publisher.json b/springwolf-core/src/test/resources/application/asyncapi.publisher.json new file mode 100644 index 000000000..7cf1551b3 --- /dev/null +++ b/springwolf-core/src/test/resources/application/asyncapi.publisher.json @@ -0,0 +1,219 @@ +{ + "asyncapi": "3.0.0", + "id": "urn:io:github:springwolf:example", + "info": { + "title": "Info title was loaded from spring properties", + "version": "1.0.0", + "description": "Springwolf core integration test", + "x-generator": "springwolf" + }, + "defaultContentType": "application/json", + "servers": { + "test-protocol": { + "host": "some-server:1234", + "protocol": "test" + } + }, + "channels": { + "publisher-channel": { + "address": "publisher-channel", + "messages": { + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo": { + "$ref": "#/components/messages/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo" + }, + "java.lang.String": { + "$ref": "#/components/messages/java.lang.String" + } + }, + "bindings": { } + }, + "publisher-class-channel": { + "address": "publisher-class-channel", + "messages": { + "java.lang.Integer": { + "$ref": "#/components/messages/java.lang.Integer" + } + }, + "bindings": { } + } + }, + "components": { + "schemas": { + "HeadersNotDocumented": { + "title": "HeadersNotDocumented", + "type": "object", + "properties": { }, + "description": "There can be headers, but they are not explicitly documented.", + "examples": [ + { } + ] + }, + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Bar": { + "title": "Bar", + "type": "object", + "properties": { + "aFieldInBarRecord": { + "type": "string" + } + }, + "examples": [ + { + "aFieldInBarRecord": "string" + } + ] + }, + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo": { + "title": "Foo", + "type": "object", + "properties": { + "aFieldInFooRecord": { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Bar" + } + }, + "examples": [ + { + "aFieldInFooRecord": { + "aFieldInBarRecord": "string" + } + } + ] + }, + "java.lang.Integer": { + "type": "integer", + "format": "int32", + "examples": [ + 0 + ] + }, + "java.lang.String": { + "type": "string", + "examples": [ + "\"string\"" + ] + } + }, + "messages": { + "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo" + } + }, + "name": "io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo", + "title": "Foo", + "bindings": { } + }, + "java.lang.Integer": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "integer", + "format": "int32", + "examples": [ + 0 + ] + } + }, + "name": "java.lang.Integer", + "title": "integer", + "bindings": { } + }, + "java.lang.String": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "string", + "examples": [ + "\"string\"" + ] + } + }, + "name": "java.lang.String", + "title": "string", + "bindings": { } + } + } + }, + "operations": { + "publisher-channel_send_publish": { + "action": "send", + "channel": { + "$ref": "#/channels/publisher-channel" + }, + "title": "publisher-channel_send", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/publisher-channel/messages/java.lang.String" + } + ] + }, + "publisher-channel_send_publish2": { + "action": "send", + "channel": { + "$ref": "#/channels/publisher-channel" + }, + "title": "publisher-channel_send", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/publisher-channel/messages/java.lang.String" + } + ] + }, + "publisher-channel_send_publish3": { + "action": "send", + "channel": { + "$ref": "#/channels/publisher-channel" + }, + "title": "publisher-channel_send", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/publisher-channel/messages/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo" + } + ] + }, + "publisher-channel_send_publish4": { + "action": "send", + "channel": { + "$ref": "#/channels/publisher-channel" + }, + "title": "publisher-channel_send", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/publisher-channel/messages/io.github.springwolf.core.integrationtests.application.listener.ListenerApplication.Foo" + } + ] + }, + "publisher-class-channel_send_publish": { + "action": "send", + "channel": { + "$ref": "#/channels/publisher-class-channel" + }, + "title": "publisher-class-channel_send", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/publisher-class-channel/messages/java.lang.Integer" + } + ] + } + } +} \ No newline at end of file diff --git a/springwolf-core/src/test/resources/application/asyncapi.ref.json b/springwolf-core/src/test/resources/application/asyncapi.ref.json new file mode 100644 index 000000000..a658e0922 --- /dev/null +++ b/springwolf-core/src/test/resources/application/asyncapi.ref.json @@ -0,0 +1,98 @@ +{ + "asyncapi": "3.0.0", + "id": "urn:io:github:springwolf:example", + "info": { + "title": "Info title was loaded from spring properties", + "version": "1.0.0", + "description": "Springwolf core integration test", + "x-generator": "springwolf" + }, + "defaultContentType": "application/json", + "servers": { + "test-protocol": { + "host": "some-server:1234", + "protocol": "test" + } + }, + "channels": { + "enum-channel": { + "address": "enum-channel", + "messages": { + "io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumRoot": { + "$ref": "#/components/messages/io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumRoot" + } + }, + "bindings": { } + } + }, + "components": { + "schemas": { + "HeadersNotDocumented": { + "title": "HeadersNotDocumented", + "type": "object", + "properties": { }, + "description": "There can be headers, but they are not explicitly documented.", + "examples": [ + { } + ] + }, + "io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumObject": { + "title": "MyEnumObject", + "type": "string", + "enum": [ + "DOG", + "CAT" + ], + "examples": [ + "\"DOG\"" + ] + }, + "io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumRoot": { + "title": "MyEnumRoot", + "type": "object", + "properties": { + "myEnumObjectField": { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumObject" + } + }, + "examples": [ + { + "myEnumObjectField": "\"DOG\"" + } + ] + } + }, + "messages": { + "io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumRoot": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumRoot" + } + }, + "name": "io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumRoot", + "title": "MyEnumRoot", + "bindings": { } + } + } + }, + "operations": { + "enum-channel_receive_listen": { + "action": "receive", + "channel": { + "$ref": "#/channels/enum-channel" + }, + "title": "enum-channel_receive", + "description": "Auto-generated description", + "bindings": { }, + "messages": [ + { + "$ref": "#/channels/enum-channel/messages/io.github.springwolf.core.integrationtests.application.ref.SchemaEnumAsRefApplication.Schemas.MyEnumRoot" + } + ] + } + } +} \ No newline at end of file