-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/test/java/com/pauluswi/batavia/dto/BalanceDataDTOTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.pauluswi.batavia.dto; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import com.pauluswi.dto.BalanceDataDTO; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
public class BalanceDataDTOTest { | ||
|
||
@Test | ||
public void testGettersAndSetters() { | ||
// Arrange | ||
BalanceDataDTO balanceData = new BalanceDataDTO(); | ||
balanceData.setBankAccountNumber("1234567890"); | ||
balanceData.setCustomerFullName("Ahmad Subarjo"); | ||
balanceData.setBalance(1500.00); | ||
|
||
// Assert | ||
assertEquals("1234567890", balanceData.getBankAccountNumber()); | ||
assertEquals("Ahmad Subarjo", balanceData.getCustomerFullName()); | ||
assertEquals(1500.00, balanceData.getBalance()); | ||
} | ||
|
||
@Test | ||
public void testEqualsAndHashCode() { | ||
// Arrange | ||
BalanceDataDTO balanceData1 = new BalanceDataDTO(); | ||
balanceData1.setBankAccountNumber("1234567890"); | ||
balanceData1.setCustomerFullName("Ahmad Subarjo"); | ||
balanceData1.setBalance(1500.00); | ||
|
||
BalanceDataDTO balanceData2 = new BalanceDataDTO(); | ||
balanceData2.setBankAccountNumber("1234567890"); | ||
balanceData2.setCustomerFullName("Ahmad Subarjo"); | ||
balanceData2.setBalance(1500.00); | ||
|
||
// Assert | ||
assertEquals(balanceData1, balanceData2); | ||
assertEquals(balanceData1.hashCode(), balanceData2.hashCode()); | ||
|
||
// Modify one object and verify they are no longer equal | ||
balanceData2.setBalance(2000.00); | ||
assertNotEquals(balanceData1, balanceData2); | ||
assertNotEquals(balanceData1.hashCode(), balanceData2.hashCode()); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
// Arrange | ||
BalanceDataDTO balanceData = new BalanceDataDTO(); | ||
balanceData.setBankAccountNumber("1234567890"); | ||
balanceData.setCustomerFullName("Ahmad Subarjo"); | ||
balanceData.setBalance(1500.00); | ||
|
||
// Act | ||
String toStringOutput = balanceData.toString(); | ||
|
||
// Assert - Check if the toString output contains the field values | ||
assertEquals("BalanceDataDTO(bankAccountNumber=1234567890, customerFullName=Ahmad Subarjo, balance=1500.0)", toStringOutput); | ||
} | ||
} |