From 78a6dc8670b7ed3146b215d9dc2dcdb734ba802f Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 10 Aug 2022 15:49:04 +1000 Subject: [PATCH] chore: move PactBrokerLoaderSpec to provider test source --- provider/build.gradle | 5 +++ .../loader/PactBrokerLoaderSpec.groovy | 45 +++++++++---------- .../loader/PactBrokerLoaderTestSupport.kt | 18 ++++++++ 3 files changed, 45 insertions(+), 23 deletions(-) rename provider/{junit/src/test/groovy/au/com/dius/pact/provider/junit => src/test/groovy/au/com/dius/pact/provider/junitsupport}/loader/PactBrokerLoaderSpec.groovy (96%) create mode 100644 provider/src/test/kotlin/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderTestSupport.kt diff --git a/provider/build.gradle b/provider/build.gradle index 70204b6895..44cbeb6b4e 100644 --- a/provider/build.gradle +++ b/provider/build.gradle @@ -35,3 +35,8 @@ compileTestGroovy { dependsOn compileTestScala classpath = classpath.plus(files(compileTestScala.destinationDir)) } + +test { + useJUnitPlatform() + maxHeapSize = "1g" +} diff --git a/provider/junit/src/test/groovy/au/com/dius/pact/provider/junit/loader/PactBrokerLoaderSpec.groovy b/provider/src/test/groovy/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderSpec.groovy similarity index 96% rename from provider/junit/src/test/groovy/au/com/dius/pact/provider/junit/loader/PactBrokerLoaderSpec.groovy rename to provider/src/test/groovy/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderSpec.groovy index bacfb232f5..01f30ee8a9 100644 --- a/provider/junit/src/test/groovy/au/com/dius/pact/provider/junit/loader/PactBrokerLoaderSpec.groovy +++ b/provider/src/test/groovy/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderSpec.groovy @@ -1,4 +1,4 @@ -package au.com.dius.pact.provider.junit.loader +package au.com.dius.pact.provider.junitsupport.loader import au.com.dius.pact.core.model.Pact import au.com.dius.pact.core.model.PactBrokerSource @@ -12,14 +12,6 @@ import au.com.dius.pact.core.support.expressions.DataType import au.com.dius.pact.core.support.expressions.ExpressionParser import au.com.dius.pact.core.support.expressions.SystemPropertyResolver import au.com.dius.pact.core.support.expressions.ValueResolver -import au.com.dius.pact.provider.junitsupport.loader.IConsumerVersionSelectors -import au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors -import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder -import au.com.dius.pact.provider.junitsupport.loader.VersionSelector -import au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException -import au.com.dius.pact.provider.junitsupport.loader.PactBroker -import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth -import au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader import com.github.michaelbull.result.Err import com.github.michaelbull.result.Ok import spock.lang.Issue @@ -1446,16 +1438,19 @@ class PactBrokerLoaderSpec extends Specification { where: - clazz | result - null | false - PactBrokerLoaderSpec | false - FullPactBrokerAnnotation | false - IncorrectTypesOnSelectorMethod | false - IncorrectTypesOnSelectorMethod2 | false - IncorrectScopeOnSelectorMethod | false - CorrectSelectorMethod | true - CorrectSelectorMethod2 | true - CorrectSelectorMethod3 | true + clazz | result + null | false + PactBrokerLoaderSpec | false + FullPactBrokerAnnotation | false + IncorrectTypesOnSelectorMethod | false + IncorrectTypesOnSelectorMethod2 | false + IncorrectScopeOnSelectorMethod | false + CorrectSelectorMethod | true + CorrectSelectorMethod2 | true + CorrectSelectorMethod3 | true + KotlinClassWithSelectorMethod | true + ExtendedFromKotlin | true + KotlinAbstractClassWithSelectorMethod | true } @Unroll @@ -1465,10 +1460,12 @@ class PactBrokerLoaderSpec extends Specification { where: - clazz | instance | result - CorrectSelectorMethod | new CorrectSelectorMethod() | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod')] - CorrectSelectorMethod2 | new CorrectSelectorMethod2() | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod2')] - CorrectSelectorMethod3 | null | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod3')] + clazz | instance | result + CorrectSelectorMethod | new CorrectSelectorMethod() | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod')] + CorrectSelectorMethod2 | new CorrectSelectorMethod2() | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod2')] + CorrectSelectorMethod3 | null | [new ConsumerVersionSelectors.Environment('CorrectSelectorMethod3')] + KotlinClassWithSelectorMethod | new KotlinClassWithSelectorMethod() | [new ConsumerVersionSelectors.Environment('KotlinSelectorMethod')] + ExtendedFromKotlin | new ExtendedFromKotlin() | [new ConsumerVersionSelectors.Environment('KotlinSelectorMethod')] } private static VersionSelector createVersionSelector(Map args = [:]) { @@ -1603,4 +1600,6 @@ class PactBrokerLoaderSpec extends Specification { new SelectorBuilder().environment('CorrectSelectorMethod3').build() } } + + static class ExtendedFromKotlin extends KotlinAbstractClassWithSelectorMethod { } } diff --git a/provider/src/test/kotlin/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderTestSupport.kt b/provider/src/test/kotlin/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderTestSupport.kt new file mode 100644 index 0000000000..ff22d7f025 --- /dev/null +++ b/provider/src/test/kotlin/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoaderTestSupport.kt @@ -0,0 +1,18 @@ +package au.com.dius.pact.provider.junitsupport.loader + +class KotlinClassWithSelectorMethod { + @PactBrokerConsumerVersionSelectors + fun consumerVersionSelectors() = SelectorBuilder().environment("KotlinSelectorMethod") +} + +abstract class KotlinAbstractClassWithSelectorMethod { + @PactBrokerConsumerVersionSelectors + fun consumerVersionSelectors() = SelectorBuilder().environment("KotlinSelectorMethod") +} + +class KotlinClassWithStaticSelectorMethod { + companion object { + @PactBrokerConsumerVersionSelectors + fun consumerVersionSelectors() = SelectorBuilder().environment("KotlinStaticSelectorMethod") + } +}