Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
feature(bank/account): Add check verification
Browse files Browse the repository at this point in the history
  • Loading branch information
MelvinCou committed Dec 19, 2023
1 parent 50a6c2f commit 7aab42a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
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();
}
}
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));
}
}

0 comments on commit 7aab42a

Please sign in to comment.