Details
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestCustomFieldApi.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestCustomFieldApi.java
index 0025633..88da850 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestCustomFieldApi.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestCustomFieldApi.java
@@ -53,6 +53,10 @@ public class TestCustomFieldApi extends TestIntegrationBase {
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
+ if (hasFailed()) {
+ return;
+ }
+
super.beforeMethod();
account = createAccountWithNonOsgiPaymentMethod(getAccountData(25));
assertNotNull(account);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
index 504dafe..ce7474f 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
@@ -324,6 +324,10 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB implemen
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
+ if (hasFailed()) {
+ return;
+ }
+
super.beforeMethod();
log.debug("beforeMethod callcontext classLoader = " + (Thread.currentThread().getContextClassLoader() != null ? Thread.currentThread().getContextClassLoader().toString() : "null"));
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/KillbillClient.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/KillbillClient.java
index c539938..b250363 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/KillbillClient.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/KillbillClient.java
@@ -104,11 +104,11 @@ public abstract class KillbillClient extends GuicyKillbillTestSuiteWithEmbeddedD
}
protected Account createAccountWithDefaultPaymentMethod(final String externalkey) throws Exception {
- return createAccountWithDefaultPaymentMethod(externalkey, null);
+ return createAccountWithDefaultPaymentMethod(externalkey, null);
}
protected Account createAccountWithDefaultPaymentMethod() throws Exception {
- return createAccountWithDefaultPaymentMethod(UUID.randomUUID().toString(), null);
+ return createAccountWithDefaultPaymentMethod(UUID.randomUUID().toString(), null);
}
protected Account createAccountWithDefaultPaymentMethod(final String externalkey, @Nullable final List<PluginProperty> pmProperties) throws Exception {
@@ -157,7 +157,11 @@ public abstract class KillbillClient extends GuicyKillbillTestSuiteWithEmbeddedD
protected Subscription createEntitlement(final UUID accountId, final String bundleExternalKey, final String productName,
final ProductCategory productCategory, final BillingPeriod billingPeriod, final boolean waitCompletion) throws Exception {
- callbackServlet.pushExpectedEvents(ExtBusEventType.ACCOUNT_CHANGE, ExtBusEventType.ENTITLEMENT_CREATION, ExtBusEventType.SUBSCRIPTION_CREATION, ExtBusEventType.SUBSCRIPTION_CREATION, ExtBusEventType.INVOICE_CREATION);
+ final Account account = killBillClient.getAccount(accountId, requestOptions);
+ if (account.getBillCycleDayLocal() == null || account.getBillCycleDayLocal() == 0) {
+ callbackServlet.pushExpectedEvent(ExtBusEventType.ACCOUNT_CHANGE);
+ }
+ callbackServlet.pushExpectedEvents(ExtBusEventType.ENTITLEMENT_CREATION, ExtBusEventType.SUBSCRIPTION_CREATION, ExtBusEventType.SUBSCRIPTION_CREATION, ExtBusEventType.INVOICE_CREATION);
final Subscription input = new Subscription();
input.setAccountId(accountId);
@@ -182,6 +186,10 @@ public abstract class KillbillClient extends GuicyKillbillTestSuiteWithEmbeddedD
}
protected Account createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(final String productName, final boolean paymentSuccess) throws Exception {
+ return createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(productName, paymentSuccess, paymentSuccess);
+ }
+
+ protected Account createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(final String productName, final boolean invoicePaymentSuccess, final boolean paymentSuccess) throws Exception {
final Account accountJson = createAccountWithDefaultPaymentMethod();
assertNotNull(accountJson);
@@ -191,10 +199,15 @@ public abstract class KillbillClient extends GuicyKillbillTestSuiteWithEmbeddedD
assertNotNull(subscriptionJson);
callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.INVOICE_CREATION);
+ if (invoicePaymentSuccess) {
+ callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_PAYMENT_SUCCESS);
+ } else {
+ callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_PAYMENT_FAILED);
+ }
if (paymentSuccess) {
- callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_PAYMENT_SUCCESS, ExtBusEventType.PAYMENT_SUCCESS);
+ callbackServlet.pushExpectedEvents(ExtBusEventType.PAYMENT_SUCCESS);
} else {
- callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_PAYMENT_FAILED, ExtBusEventType.PAYMENT_FAILED);
+ callbackServlet.pushExpectedEvents(ExtBusEventType.PAYMENT_FAILED);
}
clock.addDays(32);
callbackServlet.assertListenerStatus();
@@ -248,7 +261,7 @@ public abstract class KillbillClient extends GuicyKillbillTestSuiteWithEmbeddedD
assertNotNull(subscriptionJson);
// No payment will be triggered as the account doesn't have a payment method
- callbackServlet.pushExpectedEvent(ExtBusEventType.INVOICE_CREATION);
+ callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.INVOICE_CREATION);
clock.addMonths(1);
callbackServlet.assertListenerStatus();
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestAdmin.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestAdmin.java
index 26e2a9c..56e1427 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestAdmin.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestAdmin.java
@@ -37,6 +37,7 @@ import org.killbill.billing.client.model.Invoice;
import org.killbill.billing.client.model.Payment;
import org.killbill.billing.client.model.PaymentTransaction;
import org.killbill.billing.jaxrs.json.AdminPaymentJson;
+import org.killbill.billing.notification.plugin.api.ExtBusEventType;
import org.killbill.billing.payment.api.TransactionStatus;
import org.killbill.billing.util.api.AuditLevel;
import org.killbill.billing.util.jackson.ObjectMapper;
@@ -55,8 +56,7 @@ import static org.testng.Assert.assertNotNull;
public class TestAdmin extends TestJaxrsBase {
- // Flaky, see https://github.com/killbill/killbill/issues/860
- @Test(groups = "slow", retryAnalyzer = FlakyRetryAnalyzer.class)
+ @Test(groups = "slow")
public void testAdminPaymentEndpoint() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
@@ -70,32 +70,19 @@ public class TestAdmin extends TestJaxrsBase {
authTransaction.setPaymentExternalKey(paymentExternalKey);
authTransaction.setTransactionExternalKey(authTransactionExternalKey);
authTransaction.setTransactionType("AUTHORIZE");
+ callbackServlet.pushExpectedEvent(ExtBusEventType.PAYMENT_SUCCESS);
final Payment authPayment = killBillClient.createPayment(account.getAccountId(), account.getPaymentMethodId(), authTransaction, requestOptions);
-
- // First fix transactionStatus and paymentSstate (but not lastSuccessPaymentState
- // Note that state is not consistent between TransactionStatus and lastSuccessPaymentState but we don't care.
- fixPaymentState(authPayment, null, "AUTH_FAILED", TransactionStatus.PAYMENT_FAILURE);
-
- final Payment updatedPayment1 = killBillClient.getPayment(authPayment.getPaymentId());
- Assert.assertEquals(updatedPayment1.getTransactions().size(), 1);
- final PaymentTransaction authTransaction1 = updatedPayment1.getTransactions().get(0);
- Assert.assertEquals(authTransaction1.getStatus(), TransactionStatus.PAYMENT_FAILURE.toString());
-
- // Capture should succeed because lastSuccessPaymentState was left untouched
- doCapture(updatedPayment1, false);
+ callbackServlet.assertListenerStatus();
fixPaymentState(authPayment, "AUTH_FAILED", "AUTH_FAILED", TransactionStatus.PAYMENT_FAILURE);
- final Payment updatedPayment2 = killBillClient.getPayment(authPayment.getPaymentId());
- Assert.assertEquals(updatedPayment2.getTransactions().size(), 2);
- final PaymentTransaction authTransaction2 = updatedPayment2.getTransactions().get(0);
+ final Payment updatedPayment = killBillClient.getPayment(authPayment.getPaymentId());
+ Assert.assertEquals(updatedPayment.getTransactions().size(), 1);
+ final PaymentTransaction authTransaction2 = updatedPayment.getTransactions().get(0);
Assert.assertEquals(authTransaction2.getStatus(), TransactionStatus.PAYMENT_FAILURE.toString());
- final PaymentTransaction captureTransaction2 = updatedPayment2.getTransactions().get(1);
- Assert.assertEquals(captureTransaction2.getStatus(), TransactionStatus.SUCCESS.toString());
-
- // Capture should now failed because lastSuccessPaymentState was moved to AUTH_FAILED
- doCapture(updatedPayment2, true);
+ // Capture should fail because lastSuccessPaymentState was moved to AUTH_FAILED
+ doCapture(updatedPayment, true);
}
@Test(groups = "slow")
@@ -116,7 +103,6 @@ public class TestAdmin extends TestJaxrsBase {
BillingPeriod.MONTHLY,
true);
clock.addDays(2);
- crappyWaitForLackOfProperSynchonization();
Assert.assertEquals(killBillClient.getInvoices(requestOptions).getPaginationMaxNbRecords(), i + 1);
final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), false, false, false, false, AuditLevel.NONE, requestOptions);
@@ -124,8 +110,11 @@ public class TestAdmin extends TestJaxrsBase {
}
// Trigger first non-trial invoice
+ for (int i = 0; i < 5; i++) {
+ callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.INVOICE_CREATION, ExtBusEventType.INVOICE_PAYMENT_SUCCESS, ExtBusEventType.PAYMENT_SUCCESS);
+ }
clock.addDays(32);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
Assert.assertEquals(killBillClient.getInvoices(requestOptions).getPaginationMaxNbRecords(), 10);
for (final UUID accountId : accounts) {
@@ -138,12 +127,16 @@ public class TestAdmin extends TestJaxrsBase {
final Map<String, String> perTenantProperties = new HashMap<String, String>();
perTenantProperties.put("org.killbill.invoice.enabled", "false");
final String perTenantConfig = mapper.writeValueAsString(perTenantProperties);
+ callbackServlet.pushExpectedEvent(ExtBusEventType.TENANT_CONFIG_CHANGE);
killBillClient.postConfigurationPropertiesForTenant(perTenantConfig, requestOptions);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
// Verify the second invoice isn't generated
+ for (int i = 0; i < 5; i++) {
+ callbackServlet.pushExpectedEvents(ExtBusEventType.TAG_CREATION);
+ }
clock.addDays(32);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
Assert.assertEquals(killBillClient.getInvoices(requestOptions).getPaginationMaxNbRecords(), 10);
for (final UUID accountId : accounts) {
@@ -157,7 +150,7 @@ public class TestAdmin extends TestJaxrsBase {
Assert.assertEquals(killBillClient.getInvoices(requestOptions).getPaginationMaxNbRecords(), 11);
// Fix all accounts
- final Response response2 = triggerInvoiceGenerationForParkedAccounts(5);
+ final Response response2 = triggerInvoiceGenerationForParkedAccounts(4);
final Map<String,String> fixedAccounts = mapper.readValue(response2.getResponseBody(), new TypeReference<Map<String,String>>() {});
Assert.assertEquals(fixedAccounts.size(), 4);
Assert.assertEquals(fixedAccounts.get(accounts.get(1).toString()), "OK");
@@ -202,7 +195,9 @@ public class TestAdmin extends TestJaxrsBase {
result.put(KillBillHttpClient.AUDIT_OPTION_CREATED_BY, createdBy);
result.put(KillBillHttpClient.AUDIT_OPTION_REASON, reason);
result.put(KillBillHttpClient.AUDIT_OPTION_COMMENT, comment);
+ callbackServlet.pushExpectedEvent(ExtBusEventType.PAYMENT_FAILED);
killBillHttpClient.doPut(uri, body, result);
+ callbackServlet.assertListenerStatus();
}
private Response triggerInvoiceGenerationForParkedAccounts(final int limit) throws KillBillClientException {
@@ -213,6 +208,11 @@ public class TestAdmin extends TestJaxrsBase {
.withCreatedBy(createdBy)
.withReason(reason)
.withComment(comment).build();
- return killBillHttpClient.doPost(uri, null, requestOptions);
+ for (int i = 0; i < limit; i++) {
+ callbackServlet.pushExpectedEvents(ExtBusEventType.TAG_DELETION, ExtBusEventType.INVOICE_CREATION, ExtBusEventType.INVOICE_PAYMENT_SUCCESS, ExtBusEventType.PAYMENT_SUCCESS);
+ }
+ final Response response = killBillHttpClient.doPost(uri, null, requestOptions);
+ callbackServlet.assertListenerStatus();
+ return response;
}
}
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoicePayment.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoicePayment.java
index 787558f..99afa8d 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoicePayment.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoicePayment.java
@@ -39,6 +39,7 @@ import org.killbill.billing.client.model.PaymentMethod;
import org.killbill.billing.client.model.PaymentTransaction;
import org.killbill.billing.client.model.Payments;
import org.killbill.billing.client.model.Subscription;
+import org.killbill.billing.notification.plugin.api.ExtBusEventType;
import org.killbill.billing.osgi.api.OSGIServiceRegistration;
import org.killbill.billing.payment.api.TransactionType;
import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
@@ -79,7 +80,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
@Test(groups = "slow")
public void testRetrievePayment() throws Exception {
- final InvoicePayment paymentJson = setupScenarioWithPayment();
+ final InvoicePayment paymentJson = setupScenarioWithPayment(true);
final Payment retrievedPaymentJson = killBillClient.getPayment(paymentJson.getPaymentId(), false, requestOptions);
Assert.assertTrue(retrievedPaymentJson.equals((Payment) paymentJson));
}
@@ -89,7 +90,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
public void testInvoicePaymentCompletion() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentPending();
- final InvoicePayment paymentJson = setupScenarioWithPayment();
+ final InvoicePayment paymentJson = setupScenarioWithPayment(false);
final Payment retrievedPaymentJson = killBillClient.getPayment(paymentJson.getPaymentId(), false, requestOptions);
Assert.assertTrue(retrievedPaymentJson.equals((Payment) paymentJson));
@@ -112,7 +113,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
@Test(groups = "slow", description = "Can create a full refund with no adjustment")
public void testFullRefundWithNoAdjustment() throws Exception {
- final InvoicePayment invoicePaymentJson = setupScenarioWithPayment();
+ final InvoicePayment invoicePaymentJson = setupScenarioWithPayment(true);
// Issue a refund for the full amount
final BigDecimal refundAmount = invoicePaymentJson.getPurchasedAmount();
@@ -131,7 +132,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
@Test(groups = "slow", description = "Can create a partial refund with no adjustment")
public void testPartialRefundWithNoAdjustment() throws Exception {
- final InvoicePayment paymentJson = setupScenarioWithPayment();
+ final InvoicePayment paymentJson = setupScenarioWithPayment(true);
// Issue a refund for a fraction of the amount
final BigDecimal refundAmount = getFractionOfAmount(paymentJson.getPurchasedAmount());
@@ -150,7 +151,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
@Test(groups = "slow", description = "Can create a full refund with invoice item adjustment")
public void testRefundWithFullInvoiceItemAdjustment() throws Exception {
- final InvoicePayment paymentJson = setupScenarioWithPayment();
+ final InvoicePayment paymentJson = setupScenarioWithPayment(true);
// Get the individual items for the invoice
final Invoice invoice = killBillClient.getInvoice(paymentJson.getTargetInvoiceId(), true, false, requestOptions);
@@ -178,7 +179,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
@Test(groups = "slow", description = "Can create a partial refund with invoice item adjustment")
public void testPartialRefundWithInvoiceItemAdjustment() throws Exception {
- final InvoicePayment paymentJson = setupScenarioWithPayment();
+ final InvoicePayment paymentJson = setupScenarioWithPayment(true);
// Get the individual items for the invoice
final Invoice invoice = killBillClient.getInvoice(paymentJson.getTargetInvoiceId(), true, false, requestOptions);
@@ -205,7 +206,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
@Test(groups = "slow", description = "Cannot create invoice item adjustments for more than the refund amount")
public void testPartialRefundWithFullInvoiceItemAdjustment() throws Exception {
- final InvoicePayment paymentJson = setupScenarioWithPayment();
+ final InvoicePayment paymentJson = setupScenarioWithPayment(true);
// Get the individual items for the invoice
final Invoice invoice = killBillClient.getInvoice(paymentJson.getTargetInvoiceId(), true, false, requestOptions);
@@ -236,7 +237,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
@Test(groups = "slow", description = "Can paginate through all payments and refunds")
public void testPaymentsAndRefundsPagination() throws Exception {
- InvoicePayment lastPayment = setupScenarioWithPayment();
+ InvoicePayment lastPayment = setupScenarioWithPayment(true);
for (int i = 0; i < 5; i++) {
final InvoicePaymentTransaction refund = new InvoicePaymentTransaction();
@@ -276,7 +277,7 @@ public class TestInvoicePayment extends TestJaxrsBase {
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
- final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
+ final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
InvoicePayments invoicePayments = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(invoicePayments.size(), 1);
@@ -308,7 +309,9 @@ public class TestInvoicePayment extends TestJaxrsBase {
assertNotNull(accountJson);
// Disable automatic payments
+ callbackServlet.pushExpectedEvent(ExtBusEventType.TAG_CREATION);
killBillClient.createAccountTag(accountJson.getAccountId(), ControlTagType.AUTO_PAY_OFF.getId(), requestOptions);
+ callbackServlet.assertListenerStatus();
// Add a bundle, subscription and move the clock to get the first invoice
final Subscription subscriptionJson = createEntitlement(accountJson.getAccountId(), UUID.randomUUID().toString(), "Shotgun",
@@ -354,8 +357,8 @@ public class TestInvoicePayment extends TestJaxrsBase {
return amount.divide(BigDecimal.TEN).setScale(2, BigDecimal.ROUND_HALF_UP);
}
- private InvoicePayment setupScenarioWithPayment() throws Exception {
- final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
+ private InvoicePayment setupScenarioWithPayment(final boolean invoicePaymentSuccess) throws Exception {
+ final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice("Shotgun", invoicePaymentSuccess, true);
final List<InvoicePayment> paymentsForAccount = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId(), requestOptions);
Assert.assertEquals(paymentsForAccount.size(), 1);
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestOverdue.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestOverdue.java
index 6b13996..27678d1 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestOverdue.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestOverdue.java
@@ -22,12 +22,12 @@ import java.math.BigDecimal;
import java.util.Comparator;
import java.util.List;
-import org.killbill.billing.client.KillBillClientException;
import org.killbill.billing.client.model.Account;
import org.killbill.billing.client.model.Invoice;
import org.killbill.billing.client.model.InvoicePayment;
import org.killbill.billing.client.model.Invoices;
import org.killbill.billing.client.model.Tags;
+import org.killbill.billing.notification.plugin.api.ExtBusEventType;
import org.killbill.billing.util.tag.ControlTagType;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -103,20 +103,25 @@ public class TestOverdue extends TestJaxrsBase {
@Test(groups = "slow", description = "Allow overdue condition by control tag defined in overdue config xml file")
public void testControlTagOverdueConfig() throws Exception {
+ callbackServlet.pushExpectedEvent(ExtBusEventType.TENANT_CONFIG_CHANGE);
final String overdueConfigPath = Resources.getResource("overdueWithControlTag.xml").getPath();
killBillClient.uploadXMLOverdueConfig(overdueConfigPath, requestOptions);
+ callbackServlet.assertListenerStatus();
// Create an account without a payment method and assign a TEST tag
final Account accountJson = createAccountNoPMBundleAndSubscription();
+ callbackServlet.pushExpectedEvent(ExtBusEventType.TAG_CREATION);
final Tags accountTag = killBillClient.createAccountTag(accountJson.getAccountId(), ControlTagType.TEST.getId(), requestOptions);
+ callbackServlet.assertListenerStatus();
assertEquals(accountTag.get(0).getTagDefinitionId(), ControlTagType.TEST.getId());
// Create an account without a TEST tag
final Account accountJsonNoTag = createAccountNoPMBundleAndSubscription();
// No payment will be triggered as the account doesn't have a payment method
+ callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.INVOICE_CREATION, ExtBusEventType.INVOICE_CREATION, ExtBusEventType.INVOICE_PAYMENT_FAILED, ExtBusEventType.INVOICE_PAYMENT_FAILED);
clock.addMonths(1);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
// Get the invoices
final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
@@ -131,8 +136,14 @@ public class TestOverdue extends TestJaxrsBase {
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJson.getAccountId(), requestOptions).getIsClearState());
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJsonNoTag.getAccountId(), requestOptions).getIsClearState());
+ callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_CREATION,
+ ExtBusEventType.INVOICE_PAYMENT_FAILED,
+ ExtBusEventType.INVOICE_CREATION,
+ ExtBusEventType.INVOICE_PAYMENT_FAILED,
+ ExtBusEventType.BLOCKING_STATE,
+ ExtBusEventType.OVERDUE_CHANGE);
clock.addDays(30);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
// This account is expected to move to OD1 state because it matches with controlTag defined
Assert.assertEquals(killBillClient.getOverdueStateForAccount(accountJson.getAccountId(), requestOptions).getName(), "OD1");
@@ -142,12 +153,16 @@ public class TestOverdue extends TestJaxrsBase {
@Test(groups = "slow", description = "Allow overdue condition by exclusion control tag defined in overdue config xml file")
public void testExclusionControlTagOverdueConfig() throws Exception {
+ callbackServlet.pushExpectedEvent(ExtBusEventType.TENANT_CONFIG_CHANGE);
final String overdueConfigPath = Resources.getResource("overdueWithExclusionControlTag.xml").getPath();
killBillClient.uploadXMLOverdueConfig(overdueConfigPath, requestOptions);
+ callbackServlet.assertListenerStatus();
// Create an account without a payment method and assign a TEST tag
final Account accountJson = createAccountNoPMBundleAndSubscription();
+ callbackServlet.pushExpectedEvent(ExtBusEventType.TAG_CREATION);
final Tags accountTag = killBillClient.createAccountTag(accountJson.getAccountId(), ControlTagType.TEST.getId(), requestOptions);
+ callbackServlet.assertListenerStatus();
assertEquals(accountTag.get(0).getTagDefinitionId(), ControlTagType.TEST.getId());
// Create an account without a TEST tag
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestPayment.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestPayment.java
index a713922..d08a80c 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestPayment.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestPayment.java
@@ -216,7 +216,7 @@ public class TestPayment extends TestJaxrsBase {
@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsGetInvoicePayment() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
- final Account account = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
+ final Account account = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
// Getting Invoice #2 (first after Trial period)
UUID failedInvoiceId = killBillClient.getInvoicesForAccount(account.getAccountId(), false, false, RequestOptions.empty()).get(1).getInvoiceId();
@@ -247,7 +247,7 @@ public class TestPayment extends TestJaxrsBase {
@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsGetPaymentsForAccount() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
- final Account account = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
+ final Account account = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
HashMultimap<String, String> queryParams = HashMultimap.create();
queryParams.put("withAttempts", "true");
@@ -267,7 +267,7 @@ public class TestPayment extends TestJaxrsBase {
@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsGetPayments() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
- createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
+ createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
HashMultimap<String, String> queryParams = HashMultimap.create();
queryParams.put("withAttempts", "true");
@@ -287,7 +287,7 @@ public class TestPayment extends TestJaxrsBase {
@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsSearchPayments() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
- createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
+ createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
HashMultimap<String, String> queryParams = HashMultimap.create();
queryParams.put("withAttempts", "true");
@@ -307,7 +307,7 @@ public class TestPayment extends TestJaxrsBase {
@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsGetPaymentById() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
- createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
+ createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
Payments payments = killBillClient.searchPayments("", 0L, 100L, AuditLevel.NONE, requestOptions);
Assert.assertNotNull(payments.get(0));