-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(schemaFormat): new AsyncAPI Schema tests
- Loading branch information
Showing
238 changed files
with
6,876 additions
and
555 deletions.
There are no files selected for viewing
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
530 changes: 12 additions & 518 deletions
530
asyncapi-core/src/test/kotlin/com/asyncapi/v3/schema/multiformat/MultiFormatSchemaTest.kt
Large diffs are not rendered by default.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...e/src/test/kotlin/com/asyncapi/v3/schema/multiformat/asyncapi/AsyncAPIFormatSchemaTest.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,36 @@ | ||
package com.asyncapi.v3.schema.multiformat.asyncapi | ||
|
||
import com.asyncapi.v3.ClasspathUtils | ||
import com.asyncapi.v3.schema.multiformat.AsyncAPIFormatSchema | ||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory | ||
import org.junit.jupiter.api.Assertions | ||
|
||
abstract class AsyncAPIFormatSchemaTest { | ||
|
||
private val objectMapper: ObjectMapper = ObjectMapper(YAMLFactory()) | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL) | ||
.findAndRegisterModules() | ||
|
||
fun compareSchemas( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
schemaToCheck: AsyncAPIFormatSchema | ||
) { | ||
val schemaAsJson = ClasspathUtils.readAsString(openAPIFormatSchemaToCompareWithFilePath) | ||
val schema = objectMapper.readValue(schemaAsJson, AsyncAPIFormatSchema::class.java) | ||
|
||
Assertions.assertEquals(schema, schemaToCheck) | ||
} | ||
|
||
abstract fun parseJson( | ||
asyncAPIFormatSchemaToCompareWithFilePath: String, | ||
asyncAPIFormatSchema: AsyncAPIFormatSchema | ||
) | ||
|
||
abstract fun parseYaml( | ||
asyncAPIFormatSchemaToCompareWithFilePath: String, | ||
asyncAPIFormatSchema: AsyncAPIFormatSchema | ||
) | ||
|
||
} |
164 changes: 164 additions & 0 deletions
164
...test/kotlin/com/asyncapi/v3/schema/multiformat/asyncapi/AsyncAPIFormatSchemaV2_0_0Test.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,164 @@ | ||
package com.asyncapi.v3.schema.multiformat.asyncapi | ||
|
||
import com.asyncapi.v3.schema.json.* | ||
import com.asyncapi.v3.schema.multiformat.AsyncAPIFormatSchema | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.junit.jupiter.params.provider.ArgumentsProvider | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
import java.util.stream.Stream | ||
|
||
abstract class AsyncAPIFormatSchemaV2_0_0Test: AsyncAPIFormatSchemaTest() { | ||
|
||
@ArgumentsSource(JsonFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseJson( | ||
asyncAPIFormatSchemaToCompareWithFilePath: String, | ||
asyncAPIFormatSchema: AsyncAPIFormatSchema | ||
) { | ||
compareSchemas(asyncAPIFormatSchemaToCompareWithFilePath, asyncAPIFormatSchema) | ||
} | ||
|
||
@ArgumentsSource(YamlFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseYaml( | ||
asyncAPIFormatSchemaToCompareWithFilePath: String, | ||
asyncAPIFormatSchema: AsyncAPIFormatSchema | ||
) { | ||
compareSchemas(asyncAPIFormatSchemaToCompareWithFilePath, asyncAPIFormatSchema) | ||
} | ||
|
||
class JsonFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+json/arrays.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+json;version=2.0.0", ArraysSchemaTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+json/complex-object.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+json;version=2.0.0", ComplexObjectTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+json/conditional-validation-if-else.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+json;version=2.0.0", ConditionalValidationIfElse().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+json/draft-07-core-schema-meta-schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+json;version=2.0.0", Draft07CoreSchemaMetaSchemaTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+json/enumerated-values.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+json;version=2.0.0", EnumeratedValuesTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+json/person.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+json;version=2.0.0", PersonTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+json/regex-pattern.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+json;version=2.0.0", RegexPatternTest().asyncAPISchema()) | ||
), | ||
// | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/arrays.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", ArraysSchemaTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/complex-object.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", ComplexObjectTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/conditional-validation-if-else.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", ConditionalValidationIfElse().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/draft-07-core-schema-meta-schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", Draft07CoreSchemaMetaSchemaTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/enumerated-values.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", EnumeratedValuesTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/person.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", PersonTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/regex-pattern.schema.json", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", RegexPatternTest().asyncAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
class YamlFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+yaml/arrays.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+yaml;version=2.0.0", ArraysSchemaTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+yaml/complex-object.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+yaml;version=2.0.0", ComplexObjectTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+yaml/conditional-validation-if-else.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+yaml;version=2.0.0", ConditionalValidationIfElse().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+yaml/draft-07-core-schema-meta-schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+yaml;version=2.0.0", Draft07CoreSchemaMetaSchemaTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+yaml/enumerated-values.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+yaml;version=2.0.0", EnumeratedValuesTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+yaml/person.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+yaml;version=2.0.0", PersonTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi+yaml/regex-pattern.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi+yaml;version=2.0.0", RegexPatternTest().asyncAPISchema()) | ||
), | ||
// | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/arrays.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", ArraysSchemaTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/complex-object.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", ComplexObjectTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/conditional-validation-if-else.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", ConditionalValidationIfElse().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/draft-07-core-schema-meta-schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", Draft07CoreSchemaMetaSchemaTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/enumerated-values.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", EnumeratedValuesTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/person.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", PersonTest().asyncAPISchema()) | ||
), | ||
Arguments.of( | ||
"/json/v3/schema/multiformat/asyncapi/2.0.0/vnd.aai.asyncapi/regex-pattern.schema.yaml", | ||
AsyncAPIFormatSchema("application/vnd.aai.asyncapi;version=2.0.0", RegexPatternTest().asyncAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.