mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
ENT-11351 - Compiler warnings pass 3 (#7659)
* More compiler warnings fixed * Amended deprecation suppression annotations, as per review comments
This commit is contained in:
parent
3abb218bca
commit
975500d878
@ -51,7 +51,6 @@ class StringToMethodCallParserTest {
|
||||
val result = parser.parse(Target(), "complexNestedObject pairs: { first: 101, second: [ A, B, C ] }").invoke()
|
||||
|
||||
assertTrue(result is Pair<*,*>)
|
||||
result as Pair<*,*>
|
||||
|
||||
assertEquals(101, result.first)
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.corda.client.rpc
|
||||
|
||||
import net.corda.core.internal.uncheckedCast
|
||||
import kotlin.reflect.KCallable
|
||||
import kotlin.reflect.jvm.ExperimentalReflectionOnLambdas
|
||||
import kotlin.reflect.jvm.reflect
|
||||
|
||||
/**
|
||||
@ -10,15 +11,19 @@ import kotlin.reflect.jvm.reflect
|
||||
* different combinations of parameters.
|
||||
*/
|
||||
|
||||
@OptIn(ExperimentalReflectionOnLambdas::class)
|
||||
fun <A : Any, R> measure(a: Iterable<A>, f: (A) -> R) =
|
||||
measure(listOf(a), f.reflect()!!) { f(uncheckedCast(it[0])) }
|
||||
|
||||
@OptIn(ExperimentalReflectionOnLambdas::class)
|
||||
fun <A : Any, B : Any, R> measure(a: Iterable<A>, b: Iterable<B>, f: (A, B) -> R) =
|
||||
measure(listOf(a, b), f.reflect()!!) { f(uncheckedCast(it[0]), uncheckedCast(it[1])) }
|
||||
|
||||
@OptIn(ExperimentalReflectionOnLambdas::class)
|
||||
fun <A : Any, B : Any, C : Any, R> measure(a: Iterable<A>, b: Iterable<B>, c: Iterable<C>, f: (A, B, C) -> R) =
|
||||
measure(listOf(a, b, c), f.reflect()!!) { f(uncheckedCast(it[0]), uncheckedCast(it[1]), uncheckedCast(it[2])) }
|
||||
|
||||
@OptIn(ExperimentalReflectionOnLambdas::class)
|
||||
fun <A : Any, B : Any, C : Any, D : Any, R> measure(a: Iterable<A>, b: Iterable<B>, c: Iterable<C>, d: Iterable<D>, f: (A, B, C, D) -> R) =
|
||||
measure(listOf(a, b, c, d), f.reflect()!!) { f(uncheckedCast(it[0]), uncheckedCast(it[1]), uncheckedCast(it[2]), uncheckedCast(it[3])) }
|
||||
|
||||
|
@ -13,7 +13,7 @@ import net.corda.core.internal.rootCause
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import org.assertj.core.api.Assertions.catchThrowable
|
||||
import org.hamcrest.Matchers.lessThanOrEqualTo
|
||||
import org.junit.Assert.assertThat
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
import java.util.concurrent.ExecutorService
|
||||
|
@ -58,7 +58,7 @@ class ReceiveMultipleFlowTests : WithMockNet {
|
||||
assertEquals(message, receivedMessage)
|
||||
session.send(answer)
|
||||
}
|
||||
} as FlowLogic<Unit>
|
||||
}
|
||||
}
|
||||
|
||||
assertThat(
|
||||
|
@ -116,6 +116,7 @@ class AttachmentSerializationTest {
|
||||
private class CustomAttachment(override val id: SecureHash, internal val customContent: String) : Attachment {
|
||||
override fun open() = throw UnsupportedOperationException("Not implemented.")
|
||||
override val signerKeys get() = throw UnsupportedOperationException()
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
override val signers: List<Party> get() = throw UnsupportedOperationException()
|
||||
override val size get() = throw UnsupportedOperationException()
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ class TransactionTests(private val digestService : DigestService) {
|
||||
val attachments = listOf(ContractAttachment(object : AbstractAttachment({
|
||||
(AttachmentsClassLoaderTests::class.java.getResource(ISOLATED_JAR) ?: fail("Missing $ISOLATED_JAR")).openStream().readBytes()
|
||||
}, TESTDSL_UPLOADER) {
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
override val signers: List<Party> = emptyList()
|
||||
override val signerKeys: List<PublicKey> = emptyList()
|
||||
override val size: Int = 1234
|
||||
|
@ -15,7 +15,7 @@ import net.corda.testing.driver.NodeParameters
|
||||
import net.corda.testing.driver.driver
|
||||
import net.corda.testing.node.internal.cordappForClasses
|
||||
import org.hamcrest.CoreMatchers.`is`
|
||||
import org.junit.Assert.assertThat
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.junit.Test
|
||||
|
||||
class FlowOverrideTests {
|
||||
|
@ -29,6 +29,7 @@ import org.junit.Test
|
||||
import java.io.File
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.io.path.createTempFile
|
||||
|
||||
/**
|
||||
* The idea of this test is upon start-up of the node check if cash been already issued and if not issue under certain reference.
|
||||
@ -40,7 +41,7 @@ class CordaServiceIssueOnceAtStartupTests {
|
||||
private val armedPropName = this::class.java.enclosingClass.name + "-armed"
|
||||
private val logger = contextLogger()
|
||||
private val tempFilePropertyName = this::class.java.enclosingClass.name + "-tmpFile"
|
||||
private val tmpFile = createTempFile(prefix = tempFilePropertyName)
|
||||
private val tmpFile = createTempFile(prefix = tempFilePropertyName).toFile()
|
||||
private const val vaultQueryExecutedMarker = "VaultQueryExecuted"
|
||||
private const val sentFlowMarker = "SentFlow"
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import org.junit.Test
|
||||
import java.io.File
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
import kotlin.io.path.createTempFile
|
||||
class CordaServiceLifecycleFatalTests {
|
||||
|
||||
companion object {
|
||||
@ -34,7 +34,7 @@ class CordaServiceLifecycleFatalTests {
|
||||
|
||||
// Temporaty file used as a latch between two processes
|
||||
private val tempFilePropertyName = this::class.java.enclosingClass.name + "-tmpFile"
|
||||
private val tmpFile = createTempFile(prefix = tempFilePropertyName)
|
||||
private val tmpFile = createTempFile(prefix = tempFilePropertyName).toFile()
|
||||
private const val readyToThrowMarker = "ReadyToThrow"
|
||||
private const val goodToThrowMarker = "GoodToThrow"
|
||||
|
||||
|
@ -138,18 +138,18 @@ internal class CordaRPCOpsImpl(
|
||||
return services.vaultService._trackBy(criteria, paging, sorting, contractStateType)
|
||||
}
|
||||
|
||||
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
|
||||
@Suppress("OVERRIDE_DEPRECATION", "OverridingDeprecatedMember", "DEPRECATION")
|
||||
override fun internalVerifiedTransactionsSnapshot(): List<SignedTransaction> {
|
||||
val (snapshot, updates) = internalVerifiedTransactionsFeed()
|
||||
updates.notUsed()
|
||||
return snapshot
|
||||
}
|
||||
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
override fun internalFindVerifiedTransaction(txnId: SecureHash): SignedTransaction? =
|
||||
services.validatedTransactions.getTransaction(txnId)
|
||||
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
override fun internalVerifiedTransactionsFeed(): DataFeed<List<SignedTransaction>, SignedTransaction> {
|
||||
return services.validatedTransactions.track()
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import org.hamcrest.Matchers.anyOf
|
||||
import org.hamcrest.Matchers.`is`
|
||||
import org.hamcrest.number.OrderingComparison.greaterThan
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@ -103,9 +102,9 @@ class IdentityServiceToStringShortMigrationTest {
|
||||
val hashToIdentityResultSet = hashToIdentityStatement.executeQuery()
|
||||
|
||||
//check that there is a row for every "new" hash
|
||||
Assert.assertThat(hashToIdentityResultSet.next(), `is`(true))
|
||||
assertThat(hashToIdentityResultSet.next(), `is`(true))
|
||||
//check that the pk_hash actually matches what we expect (kinda redundant, but deserializing the whole PartyAndCertificate feels like overkill)
|
||||
Assert.assertThat(hashToIdentityResultSet.getString(1), `is`(it.owningKey.toStringShort()))
|
||||
assertThat(hashToIdentityResultSet.getString(1), `is`(it.owningKey.toStringShort()))
|
||||
|
||||
val nameToHashStatement = connection.prepareStatement("SELECT name FROM node_named_identities WHERE pk_hash=?")
|
||||
nameToHashStatement.setString(1, it.owningKey.toStringShort())
|
||||
@ -113,7 +112,7 @@ class IdentityServiceToStringShortMigrationTest {
|
||||
|
||||
//if there is no result for this key, this means its an identity that is not stored in the DB (IE, it's been seen after another identity has already been mapped to it)
|
||||
if (nameToHashResultSet.next()) {
|
||||
Assert.assertThat(nameToHashResultSet.getString(1), `is`(anyOf(groupedByNameIdentities.getValue(it.name).map<PartyAndCertificate, Matcher<String>?> { identity -> CoreMatchers.equalTo(identity.name.toString()) })))
|
||||
assertThat(nameToHashResultSet.getString(1), `is`(anyOf(groupedByNameIdentities.getValue(it.name).map<PartyAndCertificate, Matcher<String>?> { identity -> CoreMatchers.equalTo(identity.name.toString()) })))
|
||||
} else {
|
||||
logger.warn("did not find a PK_HASH for ${it.name}")
|
||||
listOfNamesWithoutPkHash.add(it.name)
|
||||
|
@ -48,7 +48,6 @@ import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.hamcrest.collection.IsIterableContainingInAnyOrder
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@ -76,6 +75,8 @@ import kotlin.io.path.exists
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
|
||||
|
||||
class NetworkMapUpdaterTest {
|
||||
@Rule
|
||||
@ -161,7 +162,7 @@ class NetworkMapUpdaterTest {
|
||||
//TODO: Remove sleep in unit test.
|
||||
Thread.sleep(2L * cacheExpiryMs)
|
||||
|
||||
Assert.assertThat(networkMapCache.allNodeHashes, IsIterableContainingInAnyOrder.containsInAnyOrder(signedNodeInfo1.raw.hash, signedNodeInfo2.raw.hash))
|
||||
assertThat(networkMapCache.allNodeHashes, IsIterableContainingInAnyOrder.containsInAnyOrder(signedNodeInfo1.raw.hash, signedNodeInfo2.raw.hash))
|
||||
|
||||
assertThat(nodeReadyFuture).isDone()
|
||||
|
||||
@ -173,7 +174,7 @@ class NetworkMapUpdaterTest {
|
||||
Thread.sleep(2L * cacheExpiryMs)
|
||||
//4 node info from network map, and 1 from file.
|
||||
|
||||
Assert.assertThat(networkMapCache.allNodeHashes, IsIterableContainingInAnyOrder.containsInAnyOrder(
|
||||
assertThat(networkMapCache.allNodeHashes, IsIterableContainingInAnyOrder.containsInAnyOrder(
|
||||
signedNodeInfo1.raw.hash,
|
||||
signedNodeInfo2.raw.hash,
|
||||
signedNodeInfo3.raw.hash,
|
||||
@ -204,7 +205,7 @@ class NetworkMapUpdaterTest {
|
||||
Thread.sleep(2L * cacheExpiryMs)
|
||||
|
||||
|
||||
Assert.assertThat(networkMapCache.allNodeHashes, IsIterableContainingInAnyOrder.containsInAnyOrder(
|
||||
assertThat(networkMapCache.allNodeHashes, IsIterableContainingInAnyOrder.containsInAnyOrder(
|
||||
signedNodeInfo1.raw.hash,
|
||||
signedNodeInfo2.raw.hash,
|
||||
signedNodeInfo3.raw.hash,
|
||||
@ -248,7 +249,7 @@ class NetworkMapUpdaterTest {
|
||||
//TODO: Remove sleep in unit test.
|
||||
Thread.sleep(2L * cacheExpiryMs)
|
||||
|
||||
Assert.assertThat(networkMapCache.allNodeHashes, IsIterableContainingInAnyOrder.containsInAnyOrder(
|
||||
assertThat(networkMapCache.allNodeHashes, IsIterableContainingInAnyOrder.containsInAnyOrder(
|
||||
signedNodeInfo1.raw.hash,
|
||||
signedNodeInfo2.raw.hash
|
||||
))
|
||||
|
@ -454,7 +454,7 @@ class DBCheckpointStorageTests {
|
||||
val deserializedException = exceptionDetails.value?.let { SerializedBytes<Any>(it) }?.deserialize(context = SerializationDefaults.STORAGE_CONTEXT)
|
||||
// IllegalStateException does not implement [CordaThrowable] therefore gets deserialized as a [CordaRuntimeException]
|
||||
assertTrue(deserializedException is CordaRuntimeException)
|
||||
val cordaRuntimeException = deserializedException as CordaRuntimeException
|
||||
val cordaRuntimeException = deserializedException
|
||||
assertEquals(IllegalStateException::class.java.name, cordaRuntimeException.originalExceptionClassName)
|
||||
assertEquals("I am a naughty exception", cordaRuntimeException.originalMessage!!)
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ import net.corda.testing.internal.LogHelper
|
||||
import net.corda.testing.internal.TestingNamedCacheFactory
|
||||
import net.corda.testing.internal.configureDatabase
|
||||
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.hamcrest.Matchers.instanceOf
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
@ -12,7 +12,7 @@ import net.corda.coretesting.internal.createTestSerializationEnv
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.hamcrest.CoreMatchers.`is`
|
||||
import org.hamcrest.Matchers
|
||||
import org.junit.Assert
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.junit.Test
|
||||
import java.net.URLClassLoader
|
||||
import java.util.concurrent.ThreadLocalRandom
|
||||
@ -61,10 +61,10 @@ class AbstractAMQPSerializationSchemeTest {
|
||||
val testString = "TEST${ThreadLocalRandom.current().nextInt()}"
|
||||
val serialized = scheme.serialize(testString, context)
|
||||
val deserialized = serialized.deserialize(context = context, serializationFactory = serializationEnvironment.serializationFactory)
|
||||
Assert.assertThat(testString, `is`(deserialized))
|
||||
Assert.assertThat(backingMap.size, `is`(Matchers.lessThanOrEqualTo(maxFactories)))
|
||||
assertThat(testString, `is`(deserialized))
|
||||
assertThat(backingMap.size, `is`(Matchers.lessThanOrEqualTo(maxFactories)))
|
||||
}
|
||||
Assert.assertThat(backingMap.size, CoreMatchers.`is`(Matchers.lessThanOrEqualTo(maxFactories)))
|
||||
assertThat(backingMap.size, CoreMatchers.`is`(Matchers.lessThanOrEqualTo(maxFactories)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.security.PublicKey
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.createTempDirectory
|
||||
import kotlin.io.path.div
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
@ -99,7 +100,7 @@ class NetworkBootstrapperRunnerTests {
|
||||
@Test(timeout=300_000)
|
||||
fun `test when base directory is specified it is passed through to the bootstrapper`() {
|
||||
val (runner, mockBootstrapper) = getRunner()
|
||||
val tempDir = createTempDir()
|
||||
val tempDir = createTempDirectory().toFile()
|
||||
runner.dir = tempDir.toPath()
|
||||
val exitCode = runner.runProgram()
|
||||
verify(mockBootstrapper).bootstrap(tempDir.toPath().toAbsolutePath().normalize(), CopyCordapps.FirstRunOnly, NetworkParametersOverrides())
|
||||
|
@ -4,6 +4,7 @@ import junit.framework.TestCase.assertEquals
|
||||
import net.corda.common.logging.errorReporting.ResourceBundleProperties
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
import kotlin.io.path.createTempDirectory
|
||||
|
||||
class ResourceGeneratorTest {
|
||||
|
||||
@ -42,7 +43,7 @@ class ResourceGeneratorTest {
|
||||
assertEquals(expectedCodes().map { "$it.properties" }.toSet(), missing.toSet())
|
||||
|
||||
// Now check that all resource files that should be created are
|
||||
val tempDir = createTempDir()
|
||||
val tempDir = createTempDirectory().toFile()
|
||||
resourceGenerator.createResources(missing, tempDir.toPath())
|
||||
val createdFiles = tempDir.walkTopDown().filter { it.isFile && it.extension == "properties" }.map { it.name }.toSet()
|
||||
assertEquals(missing.toSet(), createdFiles)
|
||||
|
@ -44,7 +44,7 @@ fun setupJSchWithSshAgent(): JSch {
|
||||
override fun getName() = String(identity.comment)
|
||||
override fun isEncrypted() = false
|
||||
override fun getSignature(data: ByteArray?) = agentProxy.sign(identity.blob, data)
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
override fun decrypt() = true
|
||||
|
||||
override fun getPublicKeyBlob() = identity.blob
|
||||
|
Loading…
Reference in New Issue
Block a user