use of org.killbill.billing.client.model.Subscription in project killbill by killbill.
the class TestEntitlement method testCreateEntitlementWithAutoPayOff.
@Test(groups = "slow", description = "Can create an entitlement with an account with autoPayOff")
public void testCreateEntitlementWithAutoPayOff() throws Exception {
final Account accountJson = createAccount();
assertNotNull(accountJson);
// assign autoPaymentOff tag to account
Tags tags = killBillClient.createAccountTag(accountJson.getAccountId(), new UUID(0L, 1L), requestOptions);
assertEquals(tags.get(0).getTagDefinitionName(), "AUTO_PAY_OFF");
// verify that number of invoices and payments for account is still 0
assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 0);
assertEquals(killBillClient.getPaymentsForAccount(accountJson.getAccountId(), requestOptions).size(), 0);
// create a subscription with no trial plan
final Subscription input = new Subscription();
input.setAccountId(accountJson.getAccountId());
input.setProductName("Blowdart");
input.setProductCategory(ProductCategory.BASE);
input.setBillingPeriod(BillingPeriod.MONTHLY);
input.setPriceList("notrial");
final Subscription subscriptionJson = killBillClient.createSubscription(input, null, 10, requestOptions);
assertNotNull(subscriptionJson);
// verify that number of invoices is now 1
assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 1);
// verify that number of payments is still 0 (no attempts)
assertEquals(killBillClient.getPaymentsForAccount(accountJson.getAccountId(), requestOptions).size(), 0);
}
use of org.killbill.billing.client.model.Subscription 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);
}
use of org.killbill.billing.client.model.Subscription in project killbill by killbill.
the class TestEntitlement method testEntitlementWithAddOns.
@Test(groups = "slow", description = "Create a base entitlement and also addOns entitlements under the same bundle")
public void testEntitlementWithAddOns() 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.setExternalKey("base");
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.setExternalKey("");
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.setExternalKey("");
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 Bundle bundle = killBillClient.createSubscriptionWithAddOns(subscriptions, null, 10, "createdBy", "", "");
assertNotNull(bundle);
assertEquals(bundle.getExternalKey(), "base");
assertEquals(bundle.getSubscriptions().size(), 3);
final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, false, AuditLevel.FULL);
assertEquals(invoices.size(), 1);
}
use of org.killbill.billing.client.model.Subscription in project killbill by killbill.
the class TestCache method createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoiceWithInputOptions.
private void createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoiceWithInputOptions(final RequestOptions inputOptions) throws Exception {
Account account = killBillClient.createAccount(getAccount(), inputOptions);
final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
info.setProperties(null);
final PaymentMethod paymentMethodJson = new PaymentMethod(null, UUID.randomUUID().toString(), account.getAccountId(), true, PLUGIN_NAME, info);
killBillClient.createPaymentMethod(paymentMethodJson, inputOptions);
final Subscription subscription = new Subscription();
subscription.setAccountId(account.getAccountId());
subscription.setExternalKey(UUID.randomUUID().toString());
subscription.setProductName("Sports");
subscription.setProductCategory(ProductCategory.BASE);
subscription.setBillingPeriod(BillingPeriod.MONTHLY);
subscription.setPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
clock.resetDeltaFromReality();
clock.setDay(new LocalDate(2013, 3, 1));
final Subscription subscriptionJson = killBillClient.createSubscription(subscription, clock.getUTCToday(), DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, inputOptions);
assertNotNull(subscriptionJson);
clock.addDays(32);
crappyWaitForLackOfProperSynchonization();
}
Aggregations