Use AssertJ static imports consistently in 5.3.x

Closes gh-29282
This commit is contained in:
Johnny Lim
2022-10-08 01:43:56 +09:00
committed by Sam Brannen
parent a599601dd9
commit 1c1a0afbed
10 changed files with 104 additions and 104 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,8 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking
import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.fail
import org.junit.jupiter.api.Test
import org.springframework.aop.framework.ProxyFactory
import org.springframework.transaction.interceptor.TransactionInterceptor
@@ -60,7 +61,6 @@ class CoroutinesAnnotationTransactionInterceptorTests {
}
catch (ex: IllegalStateException) {
}
}
assertReactiveGetTransactionAndRollbackCount(1)
}
@@ -72,7 +72,7 @@ class CoroutinesAnnotationTransactionInterceptorTests {
proxyFactory.addAdvice(TransactionInterceptor(rtm, source))
val proxy = proxyFactory.proxy as TestWithCoroutines
runBlocking {
Assertions.assertThat(proxy.suspendingValueSuccess()).isEqualTo("foo")
assertThat(proxy.suspendingValueSuccess()).isEqualTo("foo")
}
assertReactiveGetTransactionAndCommitCount(1)
}
@@ -86,7 +86,7 @@ class CoroutinesAnnotationTransactionInterceptorTests {
runBlocking {
try {
proxy.suspendingValueFailure()
Assertions.fail("No exception thrown as expected")
fail("No exception thrown as expected")
}
catch (ex: IllegalStateException) {
}
@@ -101,7 +101,7 @@ class CoroutinesAnnotationTransactionInterceptorTests {
proxyFactory.addAdvice(TransactionInterceptor(rtm, source))
val proxy = proxyFactory.proxy as TestWithCoroutines
runBlocking {
Assertions.assertThat(proxy.suspendingFlowSuccess().toList()).containsExactly("foo", "foo")
assertThat(proxy.suspendingFlowSuccess().toList()).containsExactly("foo", "foo")
}
assertReactiveGetTransactionAndCommitCount(1)
}
@@ -113,19 +113,19 @@ class CoroutinesAnnotationTransactionInterceptorTests {
proxyFactory.addAdvice(TransactionInterceptor(rtm, source))
val proxy = proxyFactory.proxy as TestWithCoroutines
runBlocking {
Assertions.assertThat(proxy.flowSuccess().toList()).containsExactly("foo", "foo")
assertThat(proxy.flowSuccess().toList()).containsExactly("foo", "foo")
}
assertReactiveGetTransactionAndCommitCount(1)
}
private fun assertReactiveGetTransactionAndCommitCount(expectedCount: Int) {
Assertions.assertThat(rtm.begun).isEqualTo(expectedCount)
Assertions.assertThat(rtm.commits).isEqualTo(expectedCount)
assertThat(rtm.begun).isEqualTo(expectedCount)
assertThat(rtm.commits).isEqualTo(expectedCount)
}
private fun assertReactiveGetTransactionAndRollbackCount(expectedCount: Int) {
Assertions.assertThat(rtm.begun).isEqualTo(expectedCount)
Assertions.assertThat(rtm.rollbacks).isEqualTo(expectedCount)
assertThat(rtm.begun).isEqualTo(expectedCount)
assertThat(rtm.rollbacks).isEqualTo(expectedCount)
}
@Transactional

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Fail
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
@@ -188,7 +188,7 @@ abstract class AbstractCoroutinesTransactionAspectTests {
ex: Exception, shouldRollback: Boolean, rollbackException: Boolean) {
val txatt: TransactionAttribute = object : DefaultTransactionAttribute() {
override fun rollbackOn(t: Throwable): Boolean {
Assertions.assertThat(t).isSameAs(ex)
assertThat(t).isSameAs(ex)
return shouldRollback
}
}
@@ -218,9 +218,9 @@ abstract class AbstractCoroutinesTransactionAspectTests {
}
catch (actual: Exception) {
if (rollbackException) {
Assertions.assertThat(actual).hasMessage(tex.message).isInstanceOf(tex::class.java)
assertThat(actual).hasMessage(tex.message).isInstanceOf(tex::class.java)
} else {
Assertions.assertThat(actual).hasMessage(ex.message).isInstanceOf(ex::class.java)
assertThat(actual).hasMessage(ex.message).isInstanceOf(ex::class.java)
}
}
}
@@ -259,7 +259,7 @@ abstract class AbstractCoroutinesTransactionAspectTests {
itb.getName()
}
catch (actual: Exception) {
Assertions.assertThat(actual).isInstanceOf(CannotCreateTransactionException::class.java)
assertThat(actual).isInstanceOf(CannotCreateTransactionException::class.java)
}
}
}
@@ -291,11 +291,11 @@ abstract class AbstractCoroutinesTransactionAspectTests {
itb.setName(name)
}
catch (ex: Exception) {
Assertions.assertThat(ex).isInstanceOf(RuntimeException::class.java)
Assertions.assertThat(ex.cause).hasMessage(ex.message).isInstanceOf(ex::class.java)
assertThat(ex).isInstanceOf(RuntimeException::class.java)
assertThat(ex.cause).hasMessage(ex.message).isInstanceOf(ex::class.java)
}
// Should have invoked target and changed name
Assertions.assertThat(itb.getName()).isEqualTo(name)
assertThat(itb.getName()).isEqualTo(name)
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.transaction.interceptor
import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.springframework.aop.framework.ProxyFactory
import org.springframework.transaction.ReactiveTransactionManager
@@ -44,9 +44,9 @@ class CoroutinesTransactionInterceptorTests : AbstractCoroutinesTransactionAspec
override fun advised(target: Any, rtm: ReactiveTransactionManager, tas: TransactionAttributeSource): Any {
val ti = TransactionInterceptor()
ti.transactionManager = rtm
Assertions.assertThat(ti.transactionManager).isEqualTo(rtm)
assertThat(ti.transactionManager).isEqualTo(rtm)
ti.transactionAttributeSource = tas
Assertions.assertThat(ti.transactionAttributeSource).isEqualTo(tas)
assertThat(ti.transactionAttributeSource).isEqualTo(tas)
val pf = ProxyFactory(target)
pf.addAdvice(0, ti)
return pf.proxy