Search in sources :

Example 11 with EntitlementSpecifier

use of org.killbill.billing.entitlement.api.EntitlementSpecifier in project killbill by killbill.

the class TestSubscription method testCreateMultipleSubscriptionsExceedLimit.

@Test(groups = "slow", expectedExceptions = EntitlementApiException.class, expectedExceptionsMessageRegExp = "Can't create AddOn laser-scope-monthly, the number of Subscriptions allowed by this Plan and Bundle has reached its limit")
public void testCreateMultipleSubscriptionsExceedLimit() throws Exception {
    final LocalDate initialDate = new LocalDate(2015, 10, 1);
    clock.setDay(initialDate);
    final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
    final PlanPhaseSpecifier baseSpec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null);
    final PlanPhaseSpecifier addOnSpec1 = new PlanPhaseSpecifier("Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null);
    final PlanPhaseSpecifier addOnSpec2 = new PlanPhaseSpecifier("Laser-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null);
    final String externalKeyA = "baseExternalKeyAAA";
    final EntitlementSpecifier baseEntitlementSpecifier = new DefaultEntitlementSpecifier(baseSpec, null);
    final EntitlementSpecifier addOnEntitlementSpecifier1 = new DefaultEntitlementSpecifier(addOnSpec1, null);
    final EntitlementSpecifier addOnEntitlementSpecifier2 = new DefaultEntitlementSpecifier(addOnSpec2, null);
    final List<EntitlementSpecifier> specifierListA = new ArrayList<EntitlementSpecifier>();
    specifierListA.add(baseEntitlementSpecifier);
    specifierListA.add(addOnEntitlementSpecifier1);
    specifierListA.add(addOnEntitlementSpecifier2);
    specifierListA.add(addOnEntitlementSpecifier2);
    specifierListA.add(addOnEntitlementSpecifier2);
    final List<BaseEntitlementWithAddOnsSpecifier> entitlementWithAddOnsSpecifierList = new ArrayList<BaseEntitlementWithAddOnsSpecifier>();
    final BaseEntitlementWithAddOnsSpecifier cartSpecifierA = new DefaultBaseEntitlementWithAddOnsSpecifier(null, externalKeyA, specifierListA, null, null, false);
    entitlementWithAddOnsSpecifierList.add(cartSpecifierA);
    entitlementApi.createBaseEntitlementsWithAddOns(account.getId(), entitlementWithAddOnsSpecifierList, ImmutableList.<PluginProperty>of(), callContext);
}
Also used : PlanPhaseSpecifier(org.killbill.billing.catalog.api.PlanPhaseSpecifier) EntitlementSpecifier(org.killbill.billing.entitlement.api.EntitlementSpecifier) DefaultEntitlementSpecifier(org.killbill.billing.entitlement.api.DefaultEntitlementSpecifier) DefaultEntitlementSpecifier(org.killbill.billing.entitlement.api.DefaultEntitlementSpecifier) Account(org.killbill.billing.account.api.Account) ArrayList(java.util.ArrayList) BaseEntitlementWithAddOnsSpecifier(org.killbill.billing.entitlement.api.BaseEntitlementWithAddOnsSpecifier) DefaultBaseEntitlementWithAddOnsSpecifier(org.killbill.billing.entitlement.api.DefaultBaseEntitlementWithAddOnsSpecifier) LocalDate(org.joda.time.LocalDate) DefaultBaseEntitlementWithAddOnsSpecifier(org.killbill.billing.entitlement.api.DefaultBaseEntitlementWithAddOnsSpecifier) Test(org.testng.annotations.Test)

Aggregations

EntitlementSpecifier (org.killbill.billing.entitlement.api.EntitlementSpecifier)11 ArrayList (java.util.ArrayList)9 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)8 LocalDate (org.joda.time.LocalDate)7 Account (org.killbill.billing.account.api.Account)7 BaseEntitlementWithAddOnsSpecifier (org.killbill.billing.entitlement.api.BaseEntitlementWithAddOnsSpecifier)7 DefaultEntitlementSpecifier (org.killbill.billing.entitlement.api.DefaultEntitlementSpecifier)5 Entitlement (org.killbill.billing.entitlement.api.Entitlement)5 Test (org.testng.annotations.Test)5 DefaultBaseEntitlementWithAddOnsSpecifier (org.killbill.billing.entitlement.api.DefaultBaseEntitlementWithAddOnsSpecifier)3 SubscriptionJson (org.killbill.billing.jaxrs.json.SubscriptionJson)3 Predicate (com.google.common.base.Predicate)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 List (java.util.List)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 AccountData (org.killbill.billing.account.api.AccountData)2