EscUtil { public static boolean shouldStoreESC(@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) && !TextUtil.isEmpty(paymentData.getToken().getEsc()); } 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 whenPaymentHasCardInfoAndEscAndStatusApprovedShouldStoreEscTrue() { when(token.getEsc()).thenReturn(STUB_ESC); when(paymentData.getToken()).thenReturn(token); when(paymentData.containsCardInfo()).thenReturn(true); final boolean shouldStoreESC = EscUtil.shouldStoreESC(ESC_BLACKLISTED_STATUS, paymentData, Payment.StatusCodes.STATUS_APPROVED, Payment.StatusDetail.STATUS_DETAIL_ACCREDITED); assertTrue(shouldStoreESC); }
@Test public void whenPaymentHasCardInfoAndNotEscAndStatusApprovedShouldStoreEscFalse() { when(token.getEsc()).thenReturn(null); when(paymentData.getToken()).thenReturn(token); when(paymentData.containsCardInfo()).thenReturn(true); final boolean shouldStoreESC = EscUtil.shouldStoreESC(ESC_BLACKLISTED_STATUS, paymentData, Payment.StatusCodes.STATUS_APPROVED, Payment.StatusDetail.STATUS_DETAIL_ACCREDITED); assertFalse(shouldStoreESC); }