Skip to content

Commit

Permalink
chore: Cleanup deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Dec 3, 2024
1 parent 3c780af commit 0ef92e0
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import java.util.function.Predicate;

/**
* Base Lexer for tokenising a JSON document
*/
public class BaseJsonLexer {
protected JsonSource json;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ open class GradleConsumerInfo(
override var packagesToScan: List<String> = emptyList(),
override var verificationType: PactVerification? = null,
override var pactSource: Any? = null,
@Deprecated("Replaced with auth")
override var pactFileAuthentication: List<Any?> = emptyList(),
override val notices: List<VerificationNotice> = mutableListOf(),
override val pending: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -197,6 +198,4 @@ open class GradleProviderInfo @Inject constructor(
""".trimMargin("|"), null)
}
}

companion object : KLogging()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -228,7 +230,7 @@ open class InteractionRunner(
}

protected open fun createTest(): Any {
return testClass.javaClass.newInstance()
return testClass.javaClass.getDeclaredConstructor().newInstance()
}

protected fun interactionBlock(
Expand Down Expand Up @@ -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<Throwable>) {
getAnnotatedMethods(testClass, State::class.java).forEach { method ->
Expand Down Expand Up @@ -411,6 +413,4 @@ class MissingStateChangeMethodStatement(
"for Interaction (\"${interaction.description}\") " +
"and Consumer $consumerName" }
}

companion object : KLogging()
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ 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
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
Expand Down Expand Up @@ -70,7 +72,7 @@ open class PactRunner(private val clazz: Class<*>) : ParentRunner<InteractionRun
}

if (clazz.getAnnotation(Ignore::class.java) != null) {
logger.info("Ignore annotation detected, exiting")
logger.info { "Ignore annotation detected, exiting" }
} else {
val (providerInfo, serviceName) = lookupProviderInfo()
val (consumerInfo, consumerName) = lookupConsumerInfo()
Expand Down Expand Up @@ -206,7 +208,7 @@ open class PactRunner(private val clazz: Class<*>) : ParentRunner<InteractionRun
}
}

companion object : KLogging() {
companion object {
const val WARNING_ON_IGNORED_IOERROR = """
---------------------------------------------------------------------------
| WARNING! Ignoring IO Exception received when loading Pact files as |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import au.com.dius.pact.core.model.ProviderState
import au.com.dius.pact.provider.IProviderVerifier
import au.com.dius.pact.provider.junitsupport.State
import au.com.dius.pact.provider.junitsupport.StateChangeAction
import io.github.oshai.kotlinlogging.KLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import org.junit.runners.model.FrameworkMethod
import org.junit.runners.model.Statement
import java.util.function.Supplier
import kotlin.reflect.full.isSubclassOf

private val logger = KotlinLogging.logger {}

data class StateChangeCallbackFailed(
override val message: String,
override val cause: Throwable
Expand Down Expand Up @@ -67,6 +69,4 @@ class RunStateChanges(
}
}
}

companion object : KLogging()
}

0 comments on commit 0ef92e0

Please sign in to comment.