[JAVA-29178] Upgrade Spring AOP 2 module to Spring Boot 3 (#15561)

This commit is contained in:
Amit Pandey
2024-01-08 23:22:19 +01:00
committed by GitHub
parent 0d48dd5439
commit b467eb65f6
6 changed files with 26 additions and 10 deletions
@@ -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();
}
}
@@ -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
@@ -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,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;
@@ -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;