[JAVA-29178] Upgrade Spring AOP 2 module to Spring Boot 3 (#15561)
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package com.baeldung.method.info;
|
||||
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BankAccountService {
|
||||
|
||||
private final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
|
||||
|
||||
@AccountOperation(operation = "deposit")
|
||||
public void deposit(Account account, Double amount) {
|
||||
account.setBalance(account.getBalance() + amount);
|
||||
@@ -23,7 +26,7 @@ public class BankAccountService {
|
||||
}
|
||||
|
||||
public double getBalance() {
|
||||
return RandomUtils.nextDouble();
|
||||
return rng.nextDouble();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-3
@@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SpringBootTest
|
||||
@@ -26,20 +27,20 @@ class BankAccountServiceIntegrationTest {
|
||||
@Test
|
||||
void withdraw() {
|
||||
bankAccountService.withdraw(account, 500.0);
|
||||
assertTrue(account.getBalance() == 1500.0);
|
||||
assertEquals(1500.0, account.getBalance());
|
||||
}
|
||||
|
||||
@Test
|
||||
void withdrawWhenLimitReached() {
|
||||
Assertions.assertThatExceptionOfType(WithdrawLimitException.class)
|
||||
.isThrownBy(() -> bankAccountService.withdraw(account, 600.0));
|
||||
assertTrue(account.getBalance() == 2000.0);
|
||||
assertEquals(2000.0, account.getBalance());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deposit() {
|
||||
bankAccountService.deposit(account, 500.0);
|
||||
assertTrue(account.getBalance() == 2500.0);
|
||||
assertEquals(2500.0, account.getBalance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.baeldung.selfinvocation;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package com.baeldung.selfinvocation;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import com.baeldung.Application;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
Reference in New Issue
Block a user