From 0ef92e02455ec97bfcbc22f85fbfbdbe18d419ee Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 3 Dec 2024 15:59:34 +1100 Subject: [PATCH] chore: Cleanup deprecation warnings --- .../com/dius/pact/core/support/json/BaseJsonLexer.java | 3 +++ .../dius/pact/core/support/json/InputStreamSource.java | 3 +++ .../au/com/dius/pact/core/support/json/JsonSource.java | 3 +++ .../com/dius/pact/core/support/json/ReaderSource.java | 3 +++ .../com/dius/pact/core/support/json/StringSource.java | 3 +++ .../dius/pact/provider/gradle/GradleConsumerInfo.kt | 1 + .../dius/pact/provider/gradle/GradleProviderInfo.kt | 7 +++---- .../pact/provider/gradle/PactBrokerConsumerConfig.kt | 6 ++++-- .../pact/provider/gradle/PactVerificationBaseTask.kt | 2 +- .../com/dius/pact/provider/junit/InteractionRunner.kt | 10 +++++----- .../au/com/dius/pact/provider/junit/PactRunner.kt | 8 +++++--- .../au/com/dius/pact/provider/junit/RunStateChanges.kt | 6 +++--- 12 files changed, 37 insertions(+), 18 deletions(-) diff --git a/core/support/src/main/java/au/com/dius/pact/core/support/json/BaseJsonLexer.java b/core/support/src/main/java/au/com/dius/pact/core/support/json/BaseJsonLexer.java index 2294c4d3b2..5717796484 100644 --- a/core/support/src/main/java/au/com/dius/pact/core/support/json/BaseJsonLexer.java +++ b/core/support/src/main/java/au/com/dius/pact/core/support/json/BaseJsonLexer.java @@ -5,6 +5,9 @@ import java.util.function.Predicate; +/** + * Base Lexer for tokenising a JSON document + */ public class BaseJsonLexer { protected JsonSource json; diff --git a/core/support/src/main/java/au/com/dius/pact/core/support/json/InputStreamSource.java b/core/support/src/main/java/au/com/dius/pact/core/support/json/InputStreamSource.java index 37ed247f0d..389c76dc7c 100644 --- a/core/support/src/main/java/au/com/dius/pact/core/support/json/InputStreamSource.java +++ b/core/support/src/main/java/au/com/dius/pact/core/support/json/InputStreamSource.java @@ -3,6 +3,9 @@ import java.io.InputStream; import java.io.InputStreamReader; +/** + * JSON source from an Input Stream + */ public class InputStreamSource extends ReaderSource { public InputStreamSource(InputStream source) { super(new InputStreamReader(source)); diff --git a/core/support/src/main/java/au/com/dius/pact/core/support/json/JsonSource.java b/core/support/src/main/java/au/com/dius/pact/core/support/json/JsonSource.java index 915a1714b1..a38986ddc0 100644 --- a/core/support/src/main/java/au/com/dius/pact/core/support/json/JsonSource.java +++ b/core/support/src/main/java/au/com/dius/pact/core/support/json/JsonSource.java @@ -1,5 +1,8 @@ package au.com.dius.pact.core.support.json; +/** + * Abstract class that represents the source of a JSON document + */ public abstract class JsonSource { public abstract Character nextChar(); public abstract Character peekNextChar(); diff --git a/core/support/src/main/java/au/com/dius/pact/core/support/json/ReaderSource.java b/core/support/src/main/java/au/com/dius/pact/core/support/json/ReaderSource.java index 9d864f96e8..50b8fe86ef 100644 --- a/core/support/src/main/java/au/com/dius/pact/core/support/json/ReaderSource.java +++ b/core/support/src/main/java/au/com/dius/pact/core/support/json/ReaderSource.java @@ -3,6 +3,9 @@ import java.io.IOException; import java.io.Reader; +/** + * JSON source from a Reader + */ public class ReaderSource extends JsonSource { private Reader reader; private Character buffer = null; diff --git a/core/support/src/main/java/au/com/dius/pact/core/support/json/StringSource.java b/core/support/src/main/java/au/com/dius/pact/core/support/json/StringSource.java index 4f6b53583e..9128662588 100644 --- a/core/support/src/main/java/au/com/dius/pact/core/support/json/StringSource.java +++ b/core/support/src/main/java/au/com/dius/pact/core/support/json/StringSource.java @@ -1,5 +1,8 @@ package au.com.dius.pact.core.support.json; +/** + * JSON source from a String + */ public class StringSource extends JsonSource { private char[] json; private int index = 0; diff --git a/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleConsumerInfo.kt b/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleConsumerInfo.kt index 6f2df124dd..f3a232287f 100644 --- a/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleConsumerInfo.kt +++ b/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleConsumerInfo.kt @@ -15,6 +15,7 @@ open class GradleConsumerInfo( override var packagesToScan: List = emptyList(), override var verificationType: PactVerification? = null, override var pactSource: Any? = null, + @Deprecated("Replaced with auth") override var pactFileAuthentication: List = emptyList(), override val notices: List = mutableListOf(), override val pending: Boolean = false, diff --git a/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleProviderInfo.kt b/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleProviderInfo.kt index ad8e20e163..70f5197c31 100644 --- a/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleProviderInfo.kt +++ b/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/GradleProviderInfo.kt @@ -12,14 +12,15 @@ import au.com.dius.pact.provider.gradle.PactPluginBase.Companion.PACT_VERIFY import groovy.lang.Closure import io.pact.plugins.jvm.core.CatalogueEntry import io.pact.plugins.jvm.core.CatalogueManager -import io.github.oshai.kotlinlogging.KLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.gradle.api.GradleScriptException -import org.gradle.api.Project import org.gradle.api.model.ObjectFactory import java.io.File import java.net.URL import javax.inject.Inject +private val logger = KotlinLogging.logger {} + /** * Extends the provider info to be setup in a gradle build */ @@ -197,6 +198,4 @@ open class GradleProviderInfo @Inject constructor( """.trimMargin("|"), null) } } - - companion object : KLogging() } diff --git a/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/PactBrokerConsumerConfig.kt b/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/PactBrokerConsumerConfig.kt index d91482259e..9bba50c4aa 100644 --- a/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/PactBrokerConsumerConfig.kt +++ b/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/PactBrokerConsumerConfig.kt @@ -2,11 +2,13 @@ package au.com.dius.pact.provider.gradle import au.com.dius.pact.core.pactbroker.ConsumerVersionSelectors import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder -import io.github.oshai.kotlinlogging.KLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.gradle.api.Action import org.gradle.api.model.ObjectFactory import javax.inject.Inject +private val logger = KotlinLogging.logger {} + /** * Config for pact broker */ @@ -32,7 +34,7 @@ open class PactBrokerConsumerConfig @Inject constructor( selectors!!.addAll(config.selectors) } - companion object : KLogging() { + companion object { @JvmStatic @JvmOverloads @Deprecated(message = "Assigning selectors with latestTags is deprecated, use withSelectors instead") diff --git a/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/PactVerificationBaseTask.kt b/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/PactVerificationBaseTask.kt index 780d26f053..2a2a0a491e 100644 --- a/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/PactVerificationBaseTask.kt +++ b/provider/gradle/src/main/kotlin/au/com/dius/pact/provider/gradle/PactVerificationBaseTask.kt @@ -15,7 +15,7 @@ open class PactVerificationBaseTask : DefaultTask() { val nonPending = failures.filterNot { it.pending } if (nonPending.isNotEmpty()) { throw GradleScriptException( - "There were ${nonPending.sumBy { it.failures.size }} non-pending pact failures for provider ${providerToVerify.name}", null) + "There were ${nonPending.sumOf { it.failures.size }} non-pending pact failures for provider ${providerToVerify.name}", null) } } } finally { diff --git a/provider/junit/src/main/kotlin/au/com/dius/pact/provider/junit/InteractionRunner.kt b/provider/junit/src/main/kotlin/au/com/dius/pact/provider/junit/InteractionRunner.kt index 5e7ae0e709..9b952355c5 100644 --- a/provider/junit/src/main/kotlin/au/com/dius/pact/provider/junit/InteractionRunner.kt +++ b/provider/junit/src/main/kotlin/au/com/dius/pact/provider/junit/InteractionRunner.kt @@ -27,7 +27,7 @@ import au.com.dius.pact.provider.junitsupport.State import au.com.dius.pact.provider.junitsupport.TargetRequestFilter import au.com.dius.pact.provider.junitsupport.target.Target import au.com.dius.pact.provider.junitsupport.target.TestTarget -import io.github.oshai.kotlinlogging.KLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.junit.After import org.junit.Before import org.junit.Rule @@ -62,6 +62,8 @@ import kotlin.reflect.jvm.kotlinProperty import kotlin.to import org.apache.commons.lang3.tuple.Pair as TuplePair +private val logger = KotlinLogging.logger {} + /** * Internal class to support pact test running * @@ -228,7 +230,7 @@ open class InteractionRunner( } protected open fun createTest(): Any { - return testClass.javaClass.newInstance() + return testClass.javaClass.getDeclaredConstructor().newInstance() } protected fun interactionBlock( @@ -359,7 +361,7 @@ open class InteractionRunner( return if (testRules.isEmpty()) statement else RunRules(statement, testRules, describeChild(interaction)) } - companion object : KLogging() { + companion object { private fun validateStateChangeMethods(testClass: TestClass, errors: MutableList) { getAnnotatedMethods(testClass, State::class.java).forEach { method -> @@ -411,6 +413,4 @@ class MissingStateChangeMethodStatement( "for Interaction (\"${interaction.description}\") " + "and Consumer $consumerName" } } - - companion object : KLogging() } diff --git a/provider/junit/src/main/kotlin/au/com/dius/pact/provider/junit/PactRunner.kt b/provider/junit/src/main/kotlin/au/com/dius/pact/provider/junit/PactRunner.kt index 5322fe4c88..244a27e7d9 100644 --- a/provider/junit/src/main/kotlin/au/com/dius/pact/provider/junit/PactRunner.kt +++ b/provider/junit/src/main/kotlin/au/com/dius/pact/provider/junit/PactRunner.kt @@ -24,7 +24,7 @@ import au.com.dius.pact.provider.junitsupport.loader.PactLoader import au.com.dius.pact.provider.junitsupport.loader.PactSource import au.com.dius.pact.provider.junitsupport.target.Target import au.com.dius.pact.provider.junitsupport.target.TestTarget -import io.github.oshai.kotlinlogging.KLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.junit.Ignore import org.junit.runner.notification.RunNotifier import org.junit.runners.ParentRunner @@ -32,6 +32,8 @@ import org.junit.runners.model.InitializationError import org.junit.runners.model.TestClass import java.io.IOException +private val logger = KotlinLogging.logger {} + /** * JUnit Runner runs pacts against provider * To set up name of tested provider use [Provider] annotation @@ -70,7 +72,7 @@ open class PactRunner(private val clazz: Class<*>) : ParentRunner) : ParentRunner