killbill-uncached
Changes
catalog/src/test/resources/catalogTest.xml 34(+32 -2)
Details
catalog/src/test/resources/catalogTest.xml 34(+32 -2)
diff --git a/catalog/src/test/resources/catalogTest.xml b/catalog/src/test/resources/catalogTest.xml
index 24aa18b..d9fc757 100644
--- a/catalog/src/test/resources/catalogTest.xml
+++ b/catalog/src/test/resources/catalogTest.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
~ Copyright 2010-2013 Ning, Inc.
+ ~ Copyright 2014-2018 Groupon, Inc
+ ~ Copyright 2014-2018 The Billing Project, LLC
~
- ~ Ning licenses this file to you under the Apache License, version 2.0
+ ~ The Billing Project licenses this file to you under the Apache License, version 2.0
~ (the "License"); you may not use this file except in compliance with the
~ License. You may obtain a copy of the License at:
~
@@ -42,6 +44,9 @@
</units>
<products>
+ <product name="Knife">
+ <category>STANDALONE</category>
+ </product>
<product name="Blowdart">
<category>BASE</category>
</product>
@@ -191,6 +196,31 @@
</rules>
<plans>
+ <plan name="knife-monthly-notrial">
+ <product>Knife</product>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <recurring>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>USD</currency>
+ <value>29.95</value>
+ </price>
+ <price>
+ <currency>EUR</currency>
+ <value>29.95</value>
+ </price>
+ <price>
+ <currency>GBP</currency>
+ <value>29.95</value>
+ </price>
+ </recurringPrice>
+ </recurring>
+ </finalPhase>
+ </plan>
<plan name="blowdart-monthly-notrial">
<product>Blowdart</product>
<finalPhase type="EVERGREEN">
@@ -216,7 +246,6 @@
</recurring>
</finalPhase>
</plan>
-
<plan name="pistol-monthly-notrial">
<product>Pistol</product>
<finalPhase type="EVERGREEN">
@@ -1373,6 +1402,7 @@
</childPriceList>
<childPriceList name="notrial">
<plans>
+ <plan>knife-monthly-notrial</plan>
<plan>blowdart-monthly-notrial</plan>
<plan>pistol-monthly-notrial</plan>
</plans>
diff --git a/entitlement/src/main/java/org/killbill/billing/entitlement/engine/core/DefaultEventsStream.java b/entitlement/src/main/java/org/killbill/billing/entitlement/engine/core/DefaultEventsStream.java
index 7c84dac..878f1a0 100644
--- a/entitlement/src/main/java/org/killbill/billing/entitlement/engine/core/DefaultEventsStream.java
+++ b/entitlement/src/main/java/org/killbill/billing/entitlement/engine/core/DefaultEventsStream.java
@@ -1,7 +1,7 @@
/*
* Copyright 2010-2013 Ning, Inc.
- * Copyright 2014-2016 Groupon, Inc
- * Copyright 2014-2016 The Billing Project, LLC
+ * Copyright 2014-2018 Groupon, Inc
+ * Copyright 2014-2018 The Billing Project, LLC
*
* The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
@@ -111,7 +111,8 @@ public class DefaultEventsStream implements EventsStream {
@Nullable final SubscriptionBaseBundle bundle,
@Nullable final SubscriptionBase baseSubscription,
@Nullable final SubscriptionBase subscription) {
- for (final Object object : new Object[]{account, bundle, baseSubscription, subscription}) {
+ // baseSubscription can be null for STANDALONE products (https://github.com/killbill/killbill/issues/840)
+ for (final Object object : new Object[]{account, bundle, subscription}) {
Preconditions.checkNotNull(object,
"accountId='%s', bundleId='%s', baseSubscriptionId='%s', subscriptionId='%s'",
account != null ? account.getId() : null,
diff --git a/entitlement/src/test/java/org/killbill/billing/entitlement/api/TestDefaultEntitlement.java b/entitlement/src/test/java/org/killbill/billing/entitlement/api/TestDefaultEntitlement.java
index 6771c42..8fb8df5 100644
--- a/entitlement/src/test/java/org/killbill/billing/entitlement/api/TestDefaultEntitlement.java
+++ b/entitlement/src/test/java/org/killbill/billing/entitlement/api/TestDefaultEntitlement.java
@@ -24,13 +24,11 @@ import org.killbill.billing.ErrorCode;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountApiException;
import org.killbill.billing.api.TestApiListener.NextEvent;
-import org.killbill.billing.catalog.api.BillingActionPolicy;
import org.killbill.billing.catalog.api.BillingPeriod;
import org.killbill.billing.catalog.api.PlanPhasePriceOverride;
import org.killbill.billing.catalog.api.PlanPhaseSpecifier;
import org.killbill.billing.catalog.api.PlanSpecifier;
import org.killbill.billing.catalog.api.PriceListSet;
-import org.killbill.billing.catalog.api.ProductCategory;
import org.killbill.billing.entitlement.EntitlementTestSuiteWithEmbeddedDB;
import org.killbill.billing.entitlement.api.Entitlement.EntitlementActionPolicy;
import org.killbill.billing.entitlement.api.Entitlement.EntitlementSourceType;
@@ -140,6 +138,39 @@ public class TestDefaultEntitlement extends EntitlementTestSuiteWithEmbeddedDB {
assertEquals(entitlement3.getState(), EntitlementState.ACTIVE);
}
+ @Test(groups = "slow", description = "https://github.com/killbill/killbill/issues/840")
+ public void testUncancelEntitlementFor_STANDALONE_Product() throws AccountApiException, EntitlementApiException {
+ final LocalDate initialDate = new LocalDate(2013, 8, 7);
+ clock.setDay(initialDate);
+
+ final Account account = createAccount(getAccountData(7));
+
+ final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Knife", BillingPeriod.MONTHLY, "notrial", null);
+
+ // Create entitlement and check each field
+ testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK);
+ final Entitlement entitlement = entitlementApi.createBaseEntitlement(account.getId(), spec, account.getExternalKey(), null, null, null, false, ImmutableList.<PluginProperty>of(), callContext);
+ assertListenerStatus();
+ assertEquals(entitlement.getState(), EntitlementState.ACTIVE);
+
+ clock.addDays(5);
+
+ final LocalDate cancelDate = new LocalDate(clock.getUTCToday().plusDays(1));
+ entitlement.cancelEntitlementWithDate(cancelDate, true, ImmutableList.<PluginProperty>of(), callContext);
+
+ final Entitlement entitlement2 = entitlementApi.getEntitlementForId(entitlement.getId(), callContext);
+ assertEquals(entitlement2.getState(), EntitlementState.ACTIVE);
+ assertEquals(entitlement2.getEffectiveEndDate(), cancelDate);
+
+ testListener.pushExpectedEvents(NextEvent.UNCANCEL);
+ entitlement2.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext);
+ assertListenerStatus();
+
+ clock.addDays(1);
+ final Entitlement entitlement3 = entitlementApi.getEntitlementForId(entitlement.getId(), callContext);
+ assertEquals(entitlement3.getState(), EntitlementState.ACTIVE);
+ }
+
@Test(groups = "slow")
public void testCancelWithEntitlementPolicyEOTAndNOCTD() throws AccountApiException, EntitlementApiException, SubscriptionApiException {
final LocalDate initialDate = new LocalDate(2013, 8, 7);
@@ -283,11 +314,10 @@ public class TestDefaultEntitlement extends EntitlementTestSuiteWithEmbeddedDB {
}
@Test(groups = "slow")
- public void testEntitlementChangePlanOnPendingEntitlement() throws AccountApiException, EntitlementApiException {
+ public void testEntitlementChangePlanOnPendingEntitlement() throws AccountApiException, EntitlementApiException {
final LocalDate initialDate = new LocalDate(2013, 8, 7);
clock.setDay(initialDate);
-
final LocalDate startDate = initialDate.plusDays(10);
final Account account = accountApi.createAccount(getAccountData(7), callContext);
@@ -316,7 +346,7 @@ public class TestDefaultEntitlement extends EntitlementTestSuiteWithEmbeddedDB {
entitlement.changePlanWithDate(spec2, ImmutableList.<PlanPhasePriceOverride>of(), startDate, ImmutableList.<PluginProperty>of(), callContext);
- testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK);
+ testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK);
clock.addDays(10);
assertListenerStatus();