killbill-aplcache
Merge remote-tracking branch 'origin/test-fixes' into test-fixes-doc Signed-off-by: …
5/2/2018 10:10:08 AM
Changes
Details
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoiceVoid.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoiceVoid.java
index 22d9520..85a66db 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoiceVoid.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoiceVoid.java
@@ -24,7 +24,6 @@ import java.util.UUID;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
-import org.killbill.billing.api.FlakyRetryAnalyzer;
import org.killbill.billing.catalog.api.BillingPeriod;
import org.killbill.billing.catalog.api.ProductCategory;
import org.killbill.billing.client.KillBillClientException;
@@ -35,6 +34,7 @@ import org.killbill.billing.client.model.gen.InvoicePayment;
import org.killbill.billing.client.model.gen.InvoicePaymentTransaction;
import org.killbill.billing.client.model.gen.PaymentTransaction;
import org.killbill.billing.invoice.api.InvoiceStatus;
+import org.killbill.billing.notification.plugin.api.ExtBusEventType;
import org.killbill.billing.payment.api.TransactionType;
import org.killbill.billing.util.api.AuditLevel;
import org.testng.Assert;
@@ -147,8 +147,7 @@ public class TestInvoiceVoid extends TestJaxrsBase {
}
- // Flaky, see https://github.com/killbill/killbill/issues/860
- @Test(groups = "slow", description = "Void a child invoice", retryAnalyzer = FlakyRetryAnalyzer.class)
+ @Test(groups = "slow", description = "Void a child invoice")
public void testChildVoidInvoice() throws Exception {
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
final LocalDate triggeredDate = new LocalDate(2012, 5, 26);
@@ -159,16 +158,19 @@ public class TestInvoiceVoid extends TestJaxrsBase {
// Add a bundle and subscription
createSubscription(childAccount1.getAccountId(), UUID.randomUUID().toString(), "Shotgun",
- ProductCategory.BASE, BillingPeriod.MONTHLY, true);
+ ProductCategory.BASE, BillingPeriod.MONTHLY, true);
// trigger an invoice generation
+ callbackServlet.pushExpectedEvent(ExtBusEventType.INVOICE_CREATION);
invoiceApi.createFutureInvoice(childAccount1.getAccountId(), triggeredDate, requestOptions);
+ callbackServlet.assertListenerStatus();
List<Invoice> child1Invoices = accountApi.getInvoicesForAccount(childAccount1.getAccountId(), true, false, false, true, AuditLevel.NONE, requestOptions);
assertEquals(child1Invoices.size(), 2);
// move one day so that the parent invoice is committed
+ callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_CREATION, ExtBusEventType.INVOICE_PAYMENT_FAILED);
clock.addDays(1);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
List<Invoice> parentInvoices = accountApi.getInvoicesForAccount(parentAccount.getAccountId(), true, false, false, false, AuditLevel.NONE, requestOptions);
assertEquals(parentInvoices.size(), 1);
@@ -176,8 +178,12 @@ public class TestInvoiceVoid extends TestJaxrsBase {
invoiceApi.voidInvoice(child1Invoices.get(1).getInvoiceId(), requestOptions);
// move the clock 1 month to check if invoices change
+ callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE,
+ ExtBusEventType.INVOICE_CREATION,
+ ExtBusEventType.OVERDUE_CHANGE,
+ ExtBusEventType.BLOCKING_STATE);
clock.addDays(31);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
// The parent added other invoice, now it has two (duplicate)
parentInvoices = accountApi.getInvoicesForAccount(parentAccount.getAccountId(), true, false, false, false, AuditLevel.NONE, requestOptions);
@@ -188,8 +194,7 @@ public class TestInvoiceVoid extends TestJaxrsBase {
assertEquals(child1Invoices.size(), 2);
}
- // Flaky, see https://github.com/killbill/killbill/issues/860
- @Test(groups = "slow", description = "Void a parent invoice", retryAnalyzer = FlakyRetryAnalyzer.class)
+ @Test(groups = "slow", description = "Void a parent invoice")
public void testParentVoidInvoice() throws Exception {
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
final LocalDate triggeredDate = new LocalDate(2012, 5, 26);
@@ -200,16 +205,19 @@ public class TestInvoiceVoid extends TestJaxrsBase {
// Add a bundle and subscription
createSubscription(childAccount1.getAccountId(), UUID.randomUUID().toString(), "Shotgun",
- ProductCategory.BASE, BillingPeriod.MONTHLY, true);
+ ProductCategory.BASE, BillingPeriod.MONTHLY, true);
// trigger an invoice generation
+ callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_CREATION);
invoiceApi.createFutureInvoice(childAccount1.getAccountId(), triggeredDate, requestOptions);
+ callbackServlet.assertListenerStatus();
List<Invoice> child1Invoices = accountApi.getInvoicesForAccount(childAccount1.getAccountId(), true, false, false, true, AuditLevel.NONE, requestOptions);
assertEquals(child1Invoices.size(), 2);
// move one day so that the parent invoice is committed
+ callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_CREATION, ExtBusEventType.INVOICE_PAYMENT_FAILED);
clock.addDays(1);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
List<Invoice> parentInvoices = accountApi.getInvoicesForAccount(parentAccount.getAccountId(), true, false, false, false, AuditLevel.NONE, requestOptions);
assertEquals(parentInvoices.size(), 1);
@@ -217,8 +225,9 @@ public class TestInvoiceVoid extends TestJaxrsBase {
invoiceApi.voidInvoice(parentInvoices.get(0).getInvoiceId(), requestOptions);
// move the clock 1 month to check if invoices change
+ callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE);
clock.addDays(31);
- crappyWaitForLackOfProperSynchonization();
+ callbackServlet.assertListenerStatus();
// since the child did not have any change, the parent does not have an invoice
// after the void.