package com.ruoyi.app.omgpay;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

class OmgPaymentMethodTest {
    @Test
    void requiresOnlyExactCreditOrApplePayValues() {
        assertEquals(OmgPaymentMethod.CREDIT, OmgPaymentMethod.require("CREDIT"));
        assertEquals(OmgPaymentMethod.APPLE_PAY, OmgPaymentMethod.require("APPLE_PAY"));
        for (String invalid : new String[]{"", "credit", "Credit", "ALL", " CREDIT "}) {
            OmgPaymentBusinessException error = assertThrows(
                    OmgPaymentBusinessException.class,
                    () -> OmgPaymentMethod.require(invalid));
            assertEquals(OmgPaymentErrorCode.PAYMENT_METHOD_INVALID, error.getCode());
        }
        assertEquals(OmgPaymentErrorCode.PAYMENT_METHOD_INVALID,
                assertThrows(OmgPaymentBusinessException.class,
                        () -> OmgPaymentMethod.require(null)).getCode());
    }
}
