@Test(groups = "slow") public void testUnknownEntriesWithExceptions() throws PaymentApiException, EventBusException { final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "minus"; final String transactionExternalKey = "plus"; // Make sure the state as seen by the plugin will be in PaymentPluginStatus.ERROR, which will be // returned later to Janitor mockPaymentProviderPlugin.makeNextPaymentFailWithException(); try { paymentApi.createAuthorization( account, account.getPaymentMethodId(), null, requestedAmount, account.getCurrency(), paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); } catch (PaymentApiException ignore) { } final Payment payment = paymentApi.getPaymentByExternalKey( paymentExternalKey, false, ImmutableList.<PluginProperty>of(), callContext); // Artificially move the transaction status to UNKNOWN final String paymentStateName = paymentSMHelper.getErroredStateForTransaction(TransactionType.AUTHORIZE).toString(); paymentDao.updatePaymentAndTransactionOnCompletion( account.getId(), payment.getId(), TransactionType.AUTHORIZE, paymentStateName, paymentStateName, payment.getTransactions().get(0).getId(), TransactionStatus.UNKNOWN, requestedAmount, account.getCurrency(), "foo", "bar", internalCallContext); final List<PaymentTransactionModelDao> paymentTransactionHistoryBeforeJanitor = getPaymentTransactionHistory(transactionExternalKey); Assert.assertEquals(paymentTransactionHistoryBeforeJanitor.size(), 3); clock.addDays(1); try { Thread.sleep(1500); } catch (InterruptedException e) { } // Nothing new happened final List<PaymentTransactionModelDao> paymentTransactionHistoryAfterJanitor = getPaymentTransactionHistory(transactionExternalKey); Assert.assertEquals(paymentTransactionHistoryAfterJanitor.size(), 3); }