From 2cdacee3601148c53b5d2a4963b2ef322f5eab92 Mon Sep 17 00:00:00 2001 From: Wangjhbh Date: Fri, 24 May 2024 02:48:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=9A=E6=9C=9F=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20=E9=80=9A=E8=BF=87=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../childbank/dao/DepositAccountBillsDao.java | 47 ++++++++++++-- .../childbank/entity/DepositAccountBills.java | 3 + .../childbank/service/CurrentService.java | 3 +- .../childbank/service/DepositService.java | 54 +++++++++++++-- .../childbank/utils/StringDateConvert.java | 15 +++++ src/main/resources/data_template.json5 | 5 +- .../TestService/TestDepositService.java | 65 ++++++++++++++++++- 7 files changed, 176 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java b/src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java index 213956b..a673130 100644 --- a/src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java +++ b/src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java @@ -63,6 +63,10 @@ void setAttribute(String attrname, Object value, long depositAccountBillId) { log.info("Set depositAccountBillExpireDate to {}", value); this.setDepositAccountBillExpireDate(depositAccountBillId, (String) value); } + case "depositAccountBillEffectiveDate" -> { + log.info("Set depositAccountBillEffectiveDate to {} ", value); + this.setDepositAccountBillEffectiveDate(depositAccountBillId, (String) value); + } default -> throw new RuntimeException("Invalid attribute name"); } } @@ -85,6 +89,12 @@ private void setDepositAccountBillExpireDate(long depositAccountBillId, String v updateAccountBill(bill); } + private void setDepositAccountBillEffectiveDate(long depositAccountBillId, String value) { + DepositAccountBills bill = this.getElementById(depositAccountBillId); + bill.setDepositAccountBillEffectiveDate(value); + updateAccountBill(bill); + } + private void updateAccountBill(DepositAccountBills bill) { List depositAccountBills = this.load().toJavaList(DepositAccountBills.class); for (int i = 0; i < depositAccountBills.size(); i++) { @@ -97,9 +107,11 @@ private void updateAccountBill(DepositAccountBills bill) { this.depositAccountDao.setAttribute("depositAccountBills", depositAccountBills); } - public void createDepositAccountBill(double amount, double rate, String expireDate) { - log.info("Create DepositAccountBill with date amount {}, rate {}, expireDate {}", amount, rate, expireDate); - DepositAccountBills newDepositAccountBills = new DepositAccountBills(this.ElementCount + 1, amount, rate, expireDate); + // 这里我不明白为什么this.ElementCount 初始就是1 + public void createDepositAccountBill(double amount, double rate, String effectiveDate, String expireDate) { + log.info("Create DepositAccountBill with date amount {}, rate {}, effectiveDate {}, expireDate {}", amount, rate, effectiveDate, expireDate); + DepositAccountBills newDepositAccountBills = new DepositAccountBills(this.ElementCount + 1, amount, rate, effectiveDate, expireDate); + log.debug("this.ElementCount = {}", this.ElementCount); this.ElementCount++; log.debug("DepositAccountBill created {}", newDepositAccountBills); @@ -109,6 +121,15 @@ public void createDepositAccountBill(double amount, double rate, String expireDa this.depositAccountDao.setAttribute("depositAccountBills", depositAccountBills); } + public void deleteDepositAccountBill(long depositAccountBillId) { + log.info("Delete DepositAccountBill with id {}", depositAccountBillId); + List depositAccountBills = this.load().toJavaList(DepositAccountBills.class); + depositAccountBills.removeIf(bill -> bill.getDepositAccountBillId() == depositAccountBillId); + log.debug("Set DepositAccountBill Array after deletion {}", depositAccountBills); + this.depositAccountDao.setAttribute("depositAccountBills", depositAccountBills); + this.ElementCount--; + } + @Override public Object getAttribute(String attrname, long depositAccountBillId) { if (depositAccountBillId < 0 || depositAccountBillId > this.ElementCount) { @@ -117,6 +138,7 @@ public Object getAttribute(String attrname, long depositAccountBillId) { return switch (attrname) { case "depositAccountBillAmount" -> this.getDepositAccountBillAmount(depositAccountBillId); case "depositAccountBillRate" -> this.getDepositAccountBillRate(depositAccountBillId); + case "depositAccountBillEffectiveDate" -> this.getDepositAccountBillEffectiveDate(depositAccountBillId); case "depositAccountBillExpireDate" -> this.getDepositAccountBillExpireDate(depositAccountBillId); default -> throw new RuntimeException("Invalid attribute name"); }; @@ -132,14 +154,29 @@ private Object getDepositAccountBillRate(long depositAccountBillId) { return bill.getDepositAccountBillRate(); } + private Object getDepositAccountBillEffectiveDate(long depositAccountBillId) { + DepositAccountBills bills = this.getElementById(depositAccountBillId); + return bills.getDepositAccountBillEffectiveDate(); + } + private Object getDepositAccountBillExpireDate(long depositAccountBillId) { DepositAccountBills bill = this.getElementById(depositAccountBillId); return bill.getDepositAccountBillExpireDate(); } @Override - List getAllAttributes() { + public List getAllAttributes() { List depositAccountBills = this.load().toJavaList(DepositAccountBills.class); return List.copyOf(depositAccountBills); } -} \ No newline at end of file + + public void deleteAllDepositAccountBills() { + log.info("Deleting all deposit account bills"); + List depositAccountBills = this.load().toJavaList(DepositAccountBills.class); + depositAccountBills.clear(); + this.depositAccountDao.setAttribute("depositAccountBills", depositAccountBills); + this.ElementCount = 0; + } + + +} diff --git a/src/main/java/com/seg83/childbank/entity/DepositAccountBills.java b/src/main/java/com/seg83/childbank/entity/DepositAccountBills.java index 749dc9b..ac88a3f 100644 --- a/src/main/java/com/seg83/childbank/entity/DepositAccountBills.java +++ b/src/main/java/com/seg83/childbank/entity/DepositAccountBills.java @@ -16,6 +16,9 @@ public class DepositAccountBills { @JSONField(name = "depositAccountBillRate") private double depositAccountBillRate; + @JSONField(name = "depositAccountBillEffectiveDate") + private String depositAccountBillEffectiveDate; + @JSONField(name = "depositAccountBillExpireDate") private String depositAccountBillExpireDate; } diff --git a/src/main/java/com/seg83/childbank/service/CurrentService.java b/src/main/java/com/seg83/childbank/service/CurrentService.java index 7199b91..87a1632 100644 --- a/src/main/java/com/seg83/childbank/service/CurrentService.java +++ b/src/main/java/com/seg83/childbank/service/CurrentService.java @@ -42,7 +42,7 @@ public Double checkCurrentAccountBalance() { * * @param amount The amount to deposit. */ - public void depositCurrentAccount(int amount) { + public void depositCurrentAccount(double amount) { double currentAmount = (Double) currentAccountDao.getAttribute("currentAccountAmount"); double newAmount = currentAmount + amount; currentAccountDao.setAttribute("currentAccountAmount", newAmount); @@ -87,4 +87,3 @@ public String toUiContent() { return "$" + String.format("%.2f", balance); } } - diff --git a/src/main/java/com/seg83/childbank/service/DepositService.java b/src/main/java/com/seg83/childbank/service/DepositService.java index 42b0b7f..a8d980c 100644 --- a/src/main/java/com/seg83/childbank/service/DepositService.java +++ b/src/main/java/com/seg83/childbank/service/DepositService.java @@ -3,22 +3,34 @@ import com.seg83.childbank.dao.DepositAccountDao; import com.seg83.childbank.dao.DepositAccountBillsDao; import com.seg83.childbank.entity.DepositAccountBills; +import com.seg83.childbank.utils.StringDateConvert; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @Service @Slf4j public class DepositService { private final DepositAccountDao depositAccountDao; + private final CurrentService currentService; private final DepositAccountBillsDao depositAccountBillsDao; + private final HistoryService historyService; + private final StringDateConvert convert; @Autowired - public DepositService(DepositAccountDao depositAccountDao, DepositAccountBillsDao depositAccountBillsDao) { + public DepositService(DepositAccountDao depositAccountDao, DepositAccountBillsDao depositAccountBillsDao, HistoryService historyService, CurrentService currentService, StringDateConvert convert) { this.depositAccountDao = depositAccountDao; + this.currentService = currentService; this.depositAccountBillsDao = depositAccountBillsDao; + this.historyService = historyService; + this.convert = convert; + } public Object[][] generateDepositList() { @@ -26,19 +38,49 @@ public Object[][] generateDepositList() { List depositAccountBillsList = (List) depositAccountDao.getAttribute("depositAccount"); // For swing JTable - Object[][] data = new Object[depositAccountBillsList.size()][4]; + Object[][] data = new Object[depositAccountBillsList.size()][5]; for (int i = 0; i < depositAccountBillsList.size(); i++) { data[i][0] = i + 1; data[i][1] = depositAccountBillsDao.getAttribute("depositAccountBillAmount", i + 1); data[i][2] = depositAccountBillsDao.getAttribute("depositAccountBillRate", i + 1); - data[i][3] = depositAccountBillsDao.getAttribute("depositAccountBillExpireDate", i + 1); + data[i][3] = depositAccountBillsDao.getAttribute("depositAccountBillEffectiveDate", i + 1); + data[i][4] = depositAccountBillsDao.getAttribute("depositAccountBillExpireDate", i + 1); } return data; } - public void createDepositAccountBill(double amount, double rate, String expireDate) { - log.info("Creating depositAccountBill @ {} for {} {}", amount, rate, expireDate); - depositAccountBillsDao.createDepositAccountBill(amount, rate, expireDate); + public void createDepositAccountBill(double amount, double rate, String effectiveDate, String expireDate) { + log.info("Creating depositAccountBill @ {} for {} (from {} to{})", amount, rate, effectiveDate, expireDate); + depositAccountBillsDao.createDepositAccountBill(amount, rate, effectiveDate, expireDate); + } + + public void depositFixAccount(double amount, double rate, String effectiveDate, String expireDate){ + currentService.withdrawCurrentAccount((int)amount); + createDepositAccountBill(amount, rate, effectiveDate, expireDate); + log.info("Deposit fix {}", amount); + historyService.createOperationHistory(amount, "Fix deposit"); + } + + public void processMaturedDeposits() { + log.info("Processing matured deposits..."); + List depositAccountBillsList = (List) depositAccountDao.getAttribute("depositAccount"); + LocalDate today = LocalDate.now(); + + for (DepositAccountBills bill : depositAccountBillsList) { + LocalDate expireDate = LocalDate.parse(bill.getDepositAccountBillExpireDate(), DateTimeFormatter.ISO_DATE); + if (!expireDate.isAfter(today)) { + double amount = bill.getDepositAccountBillAmount(); + double rate = bill.getDepositAccountBillRate(); + long days = convert.calculateDaysBetween(bill.getDepositAccountBillEffectiveDate(), bill.getDepositAccountBillExpireDate()); + double interest = amount * rate * days / 365; + double totalAmount = amount + interest; + + currentService.depositCurrentAccount(totalAmount); + historyService.createOperationHistory(totalAmount, "Matured fixed deposit"); + depositAccountBillsDao.deleteDepositAccountBill(bill.getDepositAccountBillId()); + log.info("Processed matured deposit with amount: {}, interest: {}, total: {}", amount, interest, totalAmount); + } + } } } diff --git a/src/main/java/com/seg83/childbank/utils/StringDateConvert.java b/src/main/java/com/seg83/childbank/utils/StringDateConvert.java index 881cebd..e401425 100644 --- a/src/main/java/com/seg83/childbank/utils/StringDateConvert.java +++ b/src/main/java/com/seg83/childbank/utils/StringDateConvert.java @@ -4,6 +4,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.Date; /** @@ -41,4 +43,17 @@ public String DateToString(Date date) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); return dateFormat.format(date); } + + /** + * Calculates the number of days between two dates represented as strings. + * + * @param startDate The start date string in the format "yyyy-MM-dd". + * @param endDate The end date string in the format "yyyy-MM-dd". + * @return The number of days between the start date and end date. + */ + public long calculateDaysBetween(String startDate, String endDate) { + LocalDate start = LocalDate.parse(startDate, DateTimeFormatter.ISO_DATE); + LocalDate end = LocalDate.parse(endDate, DateTimeFormatter.ISO_DATE); + return java.time.temporal.ChronoUnit.DAYS.between(start, end); + } } diff --git a/src/main/resources/data_template.json5 b/src/main/resources/data_template.json5 index 4f92432..daa3194 100644 --- a/src/main/resources/data_template.json5 +++ b/src/main/resources/data_template.json5 @@ -14,9 +14,10 @@ // Bill.java { "depositAccountBillId": 1, - "depositAccountBillAmount": 100.0, + "depositAccountBillAmount": 0.0, "depositAccountBillRate": 0.5, - "depositAccountBillExpireDate": "2020-01-01", + "depositAccountBillEffectiveDate": "2019-01-01", + "depositAccountBillExpireDate": "2025-01-01", }, ], }, diff --git a/src/test/java/com/seg83/childbank/TestService/TestDepositService.java b/src/test/java/com/seg83/childbank/TestService/TestDepositService.java index e84d6ca..47bbcb2 100644 --- a/src/test/java/com/seg83/childbank/TestService/TestDepositService.java +++ b/src/test/java/com/seg83/childbank/TestService/TestDepositService.java @@ -1,7 +1,10 @@ package com.seg83.childbank.TestService; import com.seg83.childbank.dao.DepositAccountBillsDao; +import com.seg83.childbank.service.CurrentService; import com.seg83.childbank.service.DepositService; +import com.seg83.childbank.service.HistoryService; +import com.seg83.childbank.utils.StringDateConvert; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; @@ -12,8 +15,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; +import java.util.List; import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; @SpringBootTest @Slf4j @@ -22,6 +27,12 @@ class TestDepositService { private DepositService depositService; @Autowired private DepositAccountBillsDao depositAccountBillsDao; + @Autowired + private CurrentService currentService; + @Autowired + private HistoryService historyService; + @Autowired + private StringDateConvert stringDateConvert; @BeforeAll static void setup() { @@ -50,7 +61,7 @@ void generateDepositList() { void createDepositAccountBill() { long initialElementCount = depositAccountBillsDao.ElementCount; - depositService.createDepositAccountBill(100, 0.1, "2024-08-03"); + depositService.createDepositAccountBill(100, 0.1, "2023-08-03", "2024-08-03"); long newElementCount = depositAccountBillsDao.ElementCount; assertEquals(initialElementCount + 1, newElementCount, "Element count should have incremented by 1"); @@ -63,8 +74,60 @@ void createDepositAccountBill() { assertNotNull(rate, "Deposit account bill rate should not be null"); assertEquals(0.1, rate, "Deposit account bill rate should be 0.1"); + Object effectiveDate = depositAccountBillsDao.getAttribute("depositAccountBillEffectiveDate", newElementCount); + assertNotNull(effectiveDate, "Deposit account bill effective date should not be null"); + assertEquals("2023-08-03", effectiveDate, "Deposit account bill effective date should be '2023-08-03'"); + Object expireDate = depositAccountBillsDao.getAttribute("depositAccountBillExpireDate", newElementCount); assertNotNull(expireDate, "Deposit account bill expire date should not be null"); assertEquals("2024-08-03", expireDate, "Deposit account bill expire date should be '2024-08-03'"); } + + @Test + void depositFixAccount() { + double initialBalance = currentService.checkCurrentAccountBalance(); + + depositService.depositFixAccount(100, 0.1, "2023-08-03", "2024-08-03"); + + double newBalance = currentService.checkCurrentAccountBalance(); + assertEquals(initialBalance - 100, newBalance, "Current account balance should be decreased by 100"); + + long newElementCount = depositAccountBillsDao.ElementCount; + assertEquals(2, newElementCount); + + Object amount = depositAccountBillsDao.getAttribute("depositAccountBillAmount", newElementCount); + assertNotNull(amount, "Deposit account bill amount should not be null"); + assertEquals(100.0, amount, "Deposit account bill amount should be 100.0"); + } + + @Test + void processMaturedDeposits() { + double initialBalance = currentService.checkCurrentAccountBalance(); + + // 创建一个已到期的定期存款账单 + depositService.createDepositAccountBill(200, 0.1, "2023-08-03", "2024-05-01"); + assertEquals(initialBalance, currentService.checkCurrentAccountBalance()); + + depositService.processMaturedDeposits(); + + double newBalance = currentService.checkCurrentAccountBalance(); + double expectedInterest = 200 * 0.1 * 272 / 365; // Assuming the deposit has been active for 273 days + double expectedBalance = initialBalance + 200 + expectedInterest; + assertEquals(expectedBalance, newBalance, 0.01, "Current account balance should include principal and interest"); + + List bills = depositAccountBillsDao.getAllAttributes(); + assertFalse(bills.isEmpty(), "There should be no deposit account bills after processing matured deposits"); + } + + @Test + void testCalculateDaysBetween() { + long days = stringDateConvert.calculateDaysBetween("2023-08-03", "2024-05-01"); + assertEquals(272, days, "Days between 2023-08-03 and 2024-05-01 should be 273"); + + days = stringDateConvert.calculateDaysBetween("2023-01-01", "2023-12-31"); + assertEquals(364, days, "Days between 2023-01-01 and 2023-12-31 should be 364"); // 2023 is not a leap year + + days = stringDateConvert.calculateDaysBetween("2020-01-01", "2020-12-31"); + assertEquals(365, days, "Days between 2020-01-01 and 2020-12-31 should be 365"); // 2020 is a leap year + } } From 8ca149c8541bb6df356154c539461619a6b40681 Mon Sep 17 00:00:00 2001 From: Wangjhbh Date: Fri, 24 May 2024 03:30:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86lD=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../childbank/dao/DepositAccountBillsDao.java | 23 +++++++++---------- src/main/resources/data_template.json5 | 4 ++-- .../TestService/TestDepositService.java | 15 ++++++++++-- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java b/src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java index a673130..f8c2465 100644 --- a/src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java +++ b/src/main/java/com/seg83/childbank/dao/DepositAccountBillsDao.java @@ -8,6 +8,7 @@ import java.util.List; + @Repository @Slf4j public class DepositAccountBillsDao extends AbstractArrayDao { @@ -17,9 +18,17 @@ public class DepositAccountBillsDao extends AbstractArrayDao { @Autowired public DepositAccountBillsDao(DepositAccountDao depositAccountDao) { this.depositAccountDao = depositAccountDao; + // 修正 ElementCount 初始化 this.getElementCount(); } + @Override + void getElementCount() { + log.info("Request deposit account count"); + this.ElementCount = this.load().size(); + log.debug("Get deposit account count {}", this.ElementCount); + } + @Override JSONArray load() { log.info("Request deposit account data in JSON format"); @@ -28,13 +37,6 @@ JSONArray load() { return depositAccountBills; } - @Override - void getElementCount() { - log.info("Request deposit account count"); - this.ElementCount = this.load().size(); - log.debug("Get deposit account count {}", this.ElementCount); - } - @Override DepositAccountBills getElementById(long depositAccountBillId) { log.info("Request depositAccountBill with id {}", depositAccountBillId); @@ -107,16 +109,15 @@ private void updateAccountBill(DepositAccountBills bill) { this.depositAccountDao.setAttribute("depositAccountBills", depositAccountBills); } - // 这里我不明白为什么this.ElementCount 初始就是1 public void createDepositAccountBill(double amount, double rate, String effectiveDate, String expireDate) { log.info("Create DepositAccountBill with date amount {}, rate {}, effectiveDate {}, expireDate {}", amount, rate, effectiveDate, expireDate); DepositAccountBills newDepositAccountBills = new DepositAccountBills(this.ElementCount + 1, amount, rate, effectiveDate, expireDate); log.debug("this.ElementCount = {}", this.ElementCount); - this.ElementCount++; log.debug("DepositAccountBill created {}", newDepositAccountBills); List depositAccountBills = this.load().toJavaList(DepositAccountBills.class); depositAccountBills.add(newDepositAccountBills); + this.ElementCount = depositAccountBills.size(); // 更新 ElementCount log.debug("Set DepositAccountBill Array {}", depositAccountBills); this.depositAccountDao.setAttribute("depositAccountBills", depositAccountBills); } @@ -127,7 +128,7 @@ public void deleteDepositAccountBill(long depositAccountBillId) { depositAccountBills.removeIf(bill -> bill.getDepositAccountBillId() == depositAccountBillId); log.debug("Set DepositAccountBill Array after deletion {}", depositAccountBills); this.depositAccountDao.setAttribute("depositAccountBills", depositAccountBills); - this.ElementCount--; + this.ElementCount = depositAccountBills.size(); // 更新 ElementCount } @Override @@ -177,6 +178,4 @@ public void deleteAllDepositAccountBills() { this.depositAccountDao.setAttribute("depositAccountBills", depositAccountBills); this.ElementCount = 0; } - - } diff --git a/src/main/resources/data_template.json5 b/src/main/resources/data_template.json5 index daa3194..969e6e8 100644 --- a/src/main/resources/data_template.json5 +++ b/src/main/resources/data_template.json5 @@ -14,11 +14,11 @@ // Bill.java { "depositAccountBillId": 1, - "depositAccountBillAmount": 0.0, + "depositAccountBillAmount": 100.0, "depositAccountBillRate": 0.5, "depositAccountBillEffectiveDate": "2019-01-01", "depositAccountBillExpireDate": "2025-01-01", - }, + } ], }, "currentAccount": { diff --git a/src/test/java/com/seg83/childbank/TestService/TestDepositService.java b/src/test/java/com/seg83/childbank/TestService/TestDepositService.java index 47bbcb2..dbe9dbc 100644 --- a/src/test/java/com/seg83/childbank/TestService/TestDepositService.java +++ b/src/test/java/com/seg83/childbank/TestService/TestDepositService.java @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -18,7 +19,6 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.assertEquals; @SpringBootTest @Slf4j @@ -39,6 +39,14 @@ static void setup() { System.setProperty("java.awt.headless", "false"); } + @BeforeEach + void setUp() { + // 删除所有现有的存款账单 + depositAccountBillsDao.deleteAllDepositAccountBills(); + // 创建初始测试数据 + depositService.createDepositAccountBill(100.0, 0.5, "2019-01-01", "2025-01-01"); + } + @AfterEach void restoreTestJson() { try { @@ -51,6 +59,9 @@ void restoreTestJson() { @Test void generateDepositList() { + depositService.createDepositAccountBill(200, 0.1, "2023-08-03", "2024-05-01"); + depositService.createDepositAccountBill(200, 0.1, "2023-08-03", "2024-05-01"); + depositService.createDepositAccountBill(200, 0.1, "2023-08-03", "2024-05-01"); Object[][] depositList = depositService.generateDepositList(); assertNotNull(depositList, "Deposit list should not be null"); assertTrue(depositList.length > 0, "Deposit list should not be empty"); @@ -122,7 +133,7 @@ void processMaturedDeposits() { @Test void testCalculateDaysBetween() { long days = stringDateConvert.calculateDaysBetween("2023-08-03", "2024-05-01"); - assertEquals(272, days, "Days between 2023-08-03 and 2024-05-01 should be 273"); + assertEquals(272, days, "Days between 2023-08-03 and 2024-05-01 should be 272"); days = stringDateConvert.calculateDaysBetween("2023-01-01", "2023-12-31"); assertEquals(364, days, "Days between 2023-01-01 and 2023-12-31 should be 364"); // 2023 is not a leap year