EscUtil { public static boolean shouldDeleteEsc(@NonNull final Collection<String> escBlacklistedStatus, @Nullable final PaymentData paymentData, @Nullable final String paymentStatus, @Nullable final String paymentDetail) { return hasValidParametersForESC(paymentData, paymentStatus, paymentDetail) && ListUtil.contains(escBlacklistedStatus, paymentDetail, ListUtil.CONTAIN_IGNORE_CASE); } private  EscUtil(); static boolean shouldDeleteEsc(@NonNull final Collection<String> escBlacklistedStatus,
        @Nullable final PaymentData paymentData, @Nullable final String paymentStatus,
        @Nullable final String paymentDetail); static boolean shouldStoreESC(@NonNull final Collection<String> escBlacklistedStatus,
        @Nullable final PaymentData paymentData, @Nullable final String paymentStatus,
        @Nullable final String paymentDetail); static boolean isInvalidEscPayment(@Nullable final PaymentData paymentData,
        @Nullable final String paymentStatus, @Nullable final String paymentDetail); static boolean isErrorInvalidPaymentWithEsc(final MercadoPagoError error);  }
@Test public void whenNullPaymentDataShouldDeleteEscFalse() { final boolean shouldDeleteEsc = EscUtil.shouldDeleteEsc(ESC_BLACKLISTED_STATUS, null, Payment.StatusCodes.STATUS_APPROVED, Payment.StatusDetail.STATUS_DETAIL_ACCREDITED); assertFalse(shouldDeleteEsc); }
@Test public void whenPaymentDoesNotHasCardInfoShouldDeleteEscFalse() { when(paymentData.containsCardInfo()).thenReturn(false); final boolean shouldDeleteEsc = EscUtil.shouldDeleteEsc(ESC_BLACKLISTED_STATUS, paymentData, Payment.StatusCodes.STATUS_APPROVED, Payment.StatusDetail.STATUS_DETAIL_ACCREDITED); assertFalse(shouldDeleteEsc); }
@Test public void whenPaymentHasCardInfoAndStatusNotApprovedShouldDeleteEscFalse() { when(paymentData.containsCardInfo()).thenReturn(true); final boolean shouldDeleteEsc = EscUtil.shouldDeleteEsc(ESC_BLACKLISTED_STATUS, paymentData, Payment.StatusCodes.STATUS_REJECTED, null); assertFalse(shouldDeleteEsc); }
@Test public void whenPaymentHasCardInfoAndStatusRejectedHighRiskShouldDeleteEscTrue() { when(paymentData.containsCardInfo()).thenReturn(true); final boolean shouldDeleteEsc = EscUtil.shouldDeleteEsc(ESC_BLACKLISTED_STATUS, paymentData, Payment.StatusCodes.STATUS_REJECTED, Payment.StatusDetail.STATUS_DETAIL_CC_REJECTED_HIGH_RISK); assertTrue(shouldDeleteEsc); }
@Test public void whenPaymentHasCardInfoAndStatusApprovedShouldDeleteEscFalse() { when(paymentData.containsCardInfo()).thenReturn(true); final boolean shouldDeleteEsc = EscUtil.shouldDeleteEsc(ESC_BLACKLISTED_STATUS, paymentData, Payment.StatusCodes.STATUS_APPROVED, Payment.StatusDetail.STATUS_DETAIL_ACCREDITED); assertFalse(shouldDeleteEsc); }