Skip to content

Commit

Permalink
test(3.0.0): check correctness of realisation by reading AsyncAPI exa…
Browse files Browse the repository at this point in the history
…mple - Gemini Market Data Websocket API
  • Loading branch information
Pakisan committed Feb 3, 2024
1 parent 244e259 commit 3d11134
Show file tree
Hide file tree
Showing 4 changed files with 806 additions and 0 deletions.
5 changes: 5 additions & 0 deletions asyncapi-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
Expand Down
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"
)
}

}
Loading

0 comments on commit 3d11134

Please sign in to comment.