-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(3.0.0): check correctness of realisation by reading AsyncAPI exa…
…mple - Gemini Market Data Websocket API
- Loading branch information
Showing
4 changed files
with
806 additions
and
0 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
82 changes: 82 additions & 0 deletions
82
asyncapi-core/src/test/kotlin/com/asyncapi/examples/v3/_0_0/AbstractExampleValidationTest.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,82 @@ | ||
package com.asyncapi.examples.v3._0_0 | ||
|
||
import com.asyncapi.v3.ClasspathUtils | ||
import com.asyncapi.v3._0_0.model.AsyncAPI | ||
import com.asyncapi.v3._0_0.model.component.Components | ||
import com.asyncapi.v3._0_0.model.info.Info | ||
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 | ||
import org.junit.jupiter.api.Test | ||
|
||
abstract class AbstractExampleValidationTest { | ||
|
||
private val objectMapper = ObjectMapper(YAMLFactory()) | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL) | ||
|
||
abstract fun specificationLocation(): String | ||
|
||
private fun specification(): AsyncAPI { | ||
return objectMapper.readValue( | ||
ClasspathUtils.readAsString(specificationLocation()), | ||
AsyncAPI::class.java | ||
) | ||
} | ||
|
||
abstract fun expectedInfo(): Info | ||
|
||
@Test | ||
fun `ensure that info was read correctly`() { | ||
Assertions.assertEquals( | ||
specification().info, | ||
expectedInfo(), | ||
"Info must be read correctly" | ||
) | ||
} | ||
|
||
abstract fun expectedServers(): Map<String, Any> | ||
|
||
@Test | ||
fun `ensure that servers were read correctly`() { | ||
Assertions.assertEquals( | ||
specification().servers, | ||
expectedServers(), | ||
"Servers must be read correctly" | ||
) | ||
} | ||
|
||
abstract fun expectedChannels(): Map<String, Any> | ||
|
||
@Test | ||
fun `ensure that channels were read correctly`() { | ||
Assertions.assertEquals( | ||
specification().channels, | ||
expectedChannels(), | ||
"Channels must be read correctly" | ||
) | ||
} | ||
|
||
abstract fun expectedOperations(): Map<String, Any> | ||
|
||
@Test | ||
fun `ensure that operations were read correctly`() { | ||
Assertions.assertEquals( | ||
specification().operations, | ||
expectedOperations(), | ||
"Operations must be read correctly" | ||
) | ||
} | ||
|
||
abstract fun expectedComponents(): Components | ||
|
||
@Test | ||
fun `ensure that components were read correctly`() { | ||
Assertions.assertEquals( | ||
specification().components, | ||
expectedComponents(), | ||
"Components must be read correctly" | ||
) | ||
} | ||
|
||
} |
Oops, something went wrong.