Skip to content

Commit 43b920c

Browse files
committed
reformats & optimize imports
1 parent 9325f26 commit 43b920c

6 files changed

Lines changed: 11 additions & 13 deletions

File tree

‎jta/src/main/java/com/baeldung/jtademo/JtaDemoApplication.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.hsqldb.jdbc.pool.JDBCXADataSource;
44
import org.springframework.beans.factory.annotation.Qualifier;
55
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6-
import org.springframework.boot.autoconfigure.SpringBootApplication;
76
import org.springframework.boot.jta.bitronix.BitronixXADataSourceWrapper;
87
import org.springframework.context.annotation.Bean;
98
import org.springframework.context.annotation.ComponentScan;

‎jta/src/main/java/com/baeldung/jtademo/services/AuditService.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.springframework.jdbc.core.ResultSetExtractor;
88
import org.springframework.stereotype.Service;
99

10-
import javax.transaction.Transactional;
1110
import java.math.BigDecimal;
1211

1312
@Service
@@ -26,7 +25,8 @@ public void log(String fromAccount, String toAccount, BigDecimal amount) {
2625

2726
public TransferLog lastTransferLog() {
2827
return jdbcTemplate.query("select FROM_ACCOUNT,TO_ACCOUNT,AMOUNT from AUDIT_LOG order by ID desc", (ResultSetExtractor<TransferLog>) (rs) -> {
29-
if(!rs.next()) return null;
28+
if (!rs.next())
29+
return null;
3030
return new TransferLog(rs.getString(1), rs.getString(2), BigDecimal.valueOf(rs.getDouble(3)));
3131
});
3232
}

‎jta/src/main/java/com/baeldung/jtademo/services/BankAccountService.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.springframework.jdbc.core.ResultSetExtractor;
77
import org.springframework.stereotype.Service;
88

9-
import javax.transaction.Transactional;
109
import java.math.BigDecimal;
1110

1211
@Service

‎jta/src/main/java/com/baeldung/jtademo/services/TellerService.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void executeTransfer(String fromAccontId, String toAccountId, BigDecimal
2525
bankAccountService.transfer(fromAccontId, toAccountId, amount);
2626
auditService.log(fromAccontId, toAccountId, amount);
2727
BigDecimal balance = bankAccountService.balanceOf(fromAccontId);
28-
if(balance.compareTo(BigDecimal.ZERO) <= 0) {
28+
if (balance.compareTo(BigDecimal.ZERO) <= 0) {
2929
throw new RuntimeException("Insufficient fund.");
3030
}
3131
}
@@ -35,7 +35,7 @@ public void executeTransferProgrammaticTx(String fromAccontId, String toAccountI
3535
bankAccountService.transfer(fromAccontId, toAccountId, amount);
3636
auditService.log(fromAccontId, toAccountId, amount);
3737
BigDecimal balance = bankAccountService.balanceOf(fromAccontId);
38-
if(balance.compareTo(BigDecimal.ZERO) <= 0) {
38+
if (balance.compareTo(BigDecimal.ZERO) <= 0) {
3939
userTransaction.rollback();
4040
throw new RuntimeException("Insufficient fund.");
4141
} else {

‎jta/src/main/java/com/baeldung/jtademo/services/TestHelper.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
package com.baeldung.jtademo.services;
22

3-
import com.baeldung.jtademo.dto.TransferLog;
43
import org.springframework.beans.factory.annotation.Autowired;
54
import org.springframework.beans.factory.annotation.Qualifier;
65
import org.springframework.core.io.DefaultResourceLoader;
76
import org.springframework.core.io.Resource;
87
import org.springframework.jdbc.core.JdbcTemplate;
9-
import org.springframework.jdbc.core.ResultSetExtractor;
108
import org.springframework.jdbc.datasource.init.ScriptUtils;
119
import org.springframework.stereotype.Component;
1210

1311
import javax.sql.DataSource;
14-
import java.math.BigDecimal;
1512
import java.sql.Connection;
1613
import java.sql.SQLException;
1714

@@ -43,5 +40,4 @@ private void runScript(String scriptName, DataSource dataSouorce) throws SQLExce
4340
}
4441
}
4542

46-
4743
}

‎jta/src/test/java/com/baeldung/jtademo/JtaDemoUnitTest.java‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
package com.baeldung.jtademo;
22

33
import com.baeldung.jtademo.dto.TransferLog;
4-
import com.baeldung.jtademo.services.*;
4+
import com.baeldung.jtademo.services.AuditService;
5+
import com.baeldung.jtademo.services.BankAccountService;
6+
import com.baeldung.jtademo.services.TellerService;
7+
import com.baeldung.jtademo.services.TestHelper;
58
import org.junit.Before;
69
import org.junit.Test;
710
import org.junit.runner.RunWith;
811
import org.springframework.beans.factory.annotation.Autowired;
912
import org.springframework.boot.test.context.SpringBootTest;
1013
import org.springframework.test.context.junit4.SpringRunner;
11-
import static org.assertj.core.api.Assertions.assertThat;
12-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1314

1415
import java.math.BigDecimal;
1516

17+
import static org.assertj.core.api.Assertions.assertThat;
18+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
19+
1620
@RunWith(SpringRunner.class)
1721
@SpringBootTest(classes = JtaDemoApplication.class)
1822
public class JtaDemoUnitTest {

0 commit comments

Comments
 (0)