Search in sources :

Example 1 with BulkBaseSubscriptionAndAddOns

use of org.killbill.billing.client.model.BulkBaseSubscriptionAndAddOns in project killbill by killbill.

the class TestEntitlement method testCreateEntitlementsWithAddOns.

@Test(groups = "slow", description = "Create a bulk of base entitlement and addOns under the same transaction")
public void testCreateEntitlementsWithAddOns() throws Exception {
    final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
    clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
    final Account accountJson = createAccountWithDefaultPaymentMethod();
    final Subscription base = new Subscription();
    base.setAccountId(accountJson.getAccountId());
    base.setProductName("Shotgun");
    base.setProductCategory(ProductCategory.BASE);
    base.setBillingPeriod(BillingPeriod.MONTHLY);
    base.setPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final Subscription addOn1 = new Subscription();
    addOn1.setAccountId(accountJson.getAccountId());
    addOn1.setProductName("Telescopic-Scope");
    addOn1.setProductCategory(ProductCategory.ADD_ON);
    addOn1.setBillingPeriod(BillingPeriod.MONTHLY);
    addOn1.setPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final Subscription addOn2 = new Subscription();
    addOn2.setAccountId(accountJson.getAccountId());
    addOn2.setProductName("Laser-Scope");
    addOn2.setProductCategory(ProductCategory.ADD_ON);
    addOn2.setBillingPeriod(BillingPeriod.MONTHLY);
    addOn2.setPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final List<Subscription> subscriptions = new ArrayList<Subscription>();
    subscriptions.add(base);
    subscriptions.add(addOn1);
    subscriptions.add(addOn2);
    final List<BulkBaseSubscriptionAndAddOns> bulkList = new ArrayList<BulkBaseSubscriptionAndAddOns>();
    bulkList.add(new BulkBaseSubscriptionAndAddOns(subscriptions));
    bulkList.add(new BulkBaseSubscriptionAndAddOns(subscriptions));
    final Bundles bundles = killBillClient.createSubscriptionsWithAddOns(bulkList, null, 10, requestOptions);
    assertNotNull(bundles);
    assertEquals(bundles.size(), 2);
    assertFalse(bundles.get(0).getExternalKey().equals(bundles.get(1).getExternalKey()));
    final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, false, requestOptions);
    assertEquals(invoices.size(), 1);
}
Also used : Account(org.killbill.billing.client.model.Account) BulkBaseSubscriptionAndAddOns(org.killbill.billing.client.model.BulkBaseSubscriptionAndAddOns) Invoice(org.killbill.billing.client.model.Invoice) ArrayList(java.util.ArrayList) Subscription(org.killbill.billing.client.model.Subscription) DateTime(org.joda.time.DateTime) Bundles(org.killbill.billing.client.model.Bundles) Test(org.testng.annotations.Test)

Example 2 with BulkBaseSubscriptionAndAddOns

use of org.killbill.billing.client.model.BulkBaseSubscriptionAndAddOns in project killbill by killbill.

the class TestEntitlement method testCreateEntitlementsWithoutBase.

@Test(groups = "slow", description = "Create a bulk of base entitlements and addOns under the same transaction", expectedExceptions = KillBillClientException.class, expectedExceptionsMessageRegExp = "SubscriptionJson Base Entitlement needs to be provided")
public void testCreateEntitlementsWithoutBase() throws Exception {
    final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
    clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
    final Account accountJson = createAccountWithDefaultPaymentMethod();
    final Subscription addOn1 = new Subscription();
    addOn1.setAccountId(accountJson.getAccountId());
    addOn1.setProductName("Telescopic-Scope");
    addOn1.setProductCategory(ProductCategory.ADD_ON);
    addOn1.setBillingPeriod(BillingPeriod.MONTHLY);
    addOn1.setPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final List<Subscription> subscriptions = new ArrayList<Subscription>();
    subscriptions.add(addOn1);
    final List<BulkBaseSubscriptionAndAddOns> bulkList = new ArrayList<BulkBaseSubscriptionAndAddOns>();
    bulkList.add(new BulkBaseSubscriptionAndAddOns(subscriptions));
    bulkList.add(new BulkBaseSubscriptionAndAddOns(subscriptions));
    killBillClient.createSubscriptionsWithAddOns(bulkList, null, 10, requestOptions);
}
Also used : Account(org.killbill.billing.client.model.Account) BulkBaseSubscriptionAndAddOns(org.killbill.billing.client.model.BulkBaseSubscriptionAndAddOns) ArrayList(java.util.ArrayList) Subscription(org.killbill.billing.client.model.Subscription) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Aggregations

ArrayList (java.util.ArrayList)2 DateTime (org.joda.time.DateTime)2 Account (org.killbill.billing.client.model.Account)2 BulkBaseSubscriptionAndAddOns (org.killbill.billing.client.model.BulkBaseSubscriptionAndAddOns)2 Subscription (org.killbill.billing.client.model.Subscription)2 Test (org.testng.annotations.Test)2 Bundles (org.killbill.billing.client.model.Bundles)1 Invoice (org.killbill.billing.client.model.Invoice)1