This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
-
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.
feature(bank/account): Add check verification
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
.../account/src/main/java/com/cashmanager/server/account/verification/CheckVerification.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,26 @@ | ||
package com.cashmanager.server.account.verification; | ||
|
||
import com.cashmanager.server.database.entities.PaymentMethod; | ||
import com.cashmanager.server.database.enums.PaymentMethodType; | ||
|
||
public final class CheckVerification { | ||
/** | ||
* Private constructor to hide the implicit public one | ||
*/ | ||
private CheckVerification() { | ||
} | ||
|
||
/** | ||
* Verify if the payment method is a check | ||
* | ||
* @param paymentMethod the payment method to verify | ||
* @return true if the payment method is a credit card, false otherwise | ||
*/ | ||
public static boolean isACheck(PaymentMethod paymentMethod) { | ||
return paymentMethod.getType().equals(PaymentMethodType.CHECK); | ||
} | ||
|
||
public static boolean isCashed(PaymentMethod paymentMethod) { | ||
return isACheck(paymentMethod) && paymentMethod.getCashed(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ount/src/test/java/com/cashmanager/server/account/verification/CheckVerificationTest.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,37 @@ | ||
package com.cashmanager.server.account.verification; | ||
|
||
import com.cashmanager.server.common.utils.DateHelper; | ||
import com.cashmanager.server.database.entities.PaymentMethod; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class CheckVerificationTest { | ||
|
||
@Test | ||
void isACheck() { | ||
PaymentMethod paymentMethod = PaymentMethod.createCheck(null, 123456789, false); | ||
assertTrue(CheckVerification.isACheck(paymentMethod)); | ||
} | ||
|
||
@Test | ||
void isNotACheck() { | ||
PaymentMethod paymentMethod = PaymentMethod.createCreditCard(null, | ||
"12341234-1234-1234", | ||
"123", | ||
DateHelper.fromString("2025-01", true)); | ||
assertFalse(CheckVerification.isACheck(paymentMethod)); | ||
} | ||
|
||
@Test | ||
void isCashed() { | ||
PaymentMethod paymentMethod = PaymentMethod.createCheck(null, 123456789, true); | ||
assertTrue(CheckVerification.isCashed(paymentMethod)); | ||
} | ||
|
||
@Test | ||
void isNotCashed() { | ||
PaymentMethod paymentMethod = PaymentMethod.createCheck(null, 123456789, false); | ||
assertFalse(CheckVerification.isCashed(paymentMethod)); | ||
} | ||
} |