diff --git a/server/zally-ruleset-zalando/src/test/kotlin/org/zalando/zally/ruleset/zalando/EnumValueTypeTest.kt b/server/zally-ruleset-zalando/src/test/kotlin/org/zalando/zally/ruleset/zalando/EnumValueTypeTest.kt index 2a3c9f290..ce2075233 100644 --- a/server/zally-ruleset-zalando/src/test/kotlin/org/zalando/zally/ruleset/zalando/EnumValueTypeTest.kt +++ b/server/zally-ruleset-zalando/src/test/kotlin/org/zalando/zally/ruleset/zalando/EnumValueTypeTest.kt @@ -3,14 +3,28 @@ package org.zalando.zally.ruleset.zalando import org.assertj.core.api.Assertions import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.Arguments +import org.junit.jupiter.params.provider.MethodSource import org.zalando.zally.core.DefaultContextFactory +import java.util.stream.Stream class EnumValueTypeTest { private val rule = EnumValueTypeRule() - @Test - fun `fail validation if 'x-extensible-enum' has a 'string' type`() { + companion object { + @JvmStatic + fun nonStringTypes(): Stream = Stream.of( + Arguments.of("number", "1", "2"), + Arguments.of("integer", "1", "2"), + Arguments.of("boolean", "true", "false") + ) + } + + @ParameterizedTest + @MethodSource("nonStringTypes") + fun `fail validation if 'x-extensible-enum' has a non-'string' type`(nonStringType: String, value1: String, value2: String) { @Language("YAML") val spec = """ openapi: 3.0.1 @@ -26,11 +40,10 @@ class EnumValueTypeTest { type: object properties: prop-1: - type: integer + type: $nonStringType x-extensible-enum: - - 1 - - 2 - - 3 + - $value1 + - $value2 """.trimIndent() @@ -38,6 +51,7 @@ class EnumValueTypeTest { val violations = rule.validate(context) Assertions.assertThat(violations).hasSize(1) + Assertions.assertThat(violations[0].description).isEqualTo("Enumeration value should have \"type = string\": prop-1") } @Test diff --git a/server/zally-ruleset-zalando/src/test/kotlin/org/zalando/zally/ruleset/zalando/ExtensibleEnumRuleTest.kt b/server/zally-ruleset-zalando/src/test/kotlin/org/zalando/zally/ruleset/zalando/ExtensibleEnumRuleTest.kt index e9153a048..c549c7367 100644 --- a/server/zally-ruleset-zalando/src/test/kotlin/org/zalando/zally/ruleset/zalando/ExtensibleEnumRuleTest.kt +++ b/server/zally-ruleset-zalando/src/test/kotlin/org/zalando/zally/ruleset/zalando/ExtensibleEnumRuleTest.kt @@ -57,7 +57,7 @@ class ExtensibleEnumRuleTest { } @Test - fun `checkForEnums should return violation if no enums are used`() { + fun `checkForEnums should return no violation if no enums are used`() { val content = """ openapi: 3.0.1 components: