本文整理了Java中org.killbill.billing.account.api.Account
类的一些代码示例,展示了Account
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Account
类的具体详情如下:
包路径:org.killbill.billing.account.api.Account
类名称:Account
[英]The interface Account
represents an account within Killbill.
An Account
has a unique UUID and also an externalKey that it set when it is created. The billCycleDay can be specified when creating the account, or it will be set automatically by the system.
[中]
代码示例来源:origin: killbill/killbill
@Test(groups = "slow", expectedExceptiOns= IllegalArgumentException.class, description = "Test updating Account externalKey throws an exception")
public void testShouldntBeAbleToUpdateExternalKey() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
final MutableAccountData otherAccount = new DefaultAccount(account.getId(), account).toMutableAccountData();
otherAccount.setExternalKey(UUID.randomUUID().toString());
accountUserApi.updateAccount(new DefaultAccount(account.getId(), otherAccount), callContext);
}
代码示例来源:origin: killbill/killbill
@Test(groups = "slow", description = "Test Account update with null values")
public void testShouldBeAbleToPassNullForSomeFieldsToAvoidUpdate() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
// Update the address and leave other fields null
final MutableAccountData mutableAccountData = new DefaultMutableAccountData(null, null, null, 0, null, null, false, 0, null,
clock.getUTCNow(), null, null, null, null, null, null,
null, null, null, null, null, false);
final String newAddress1 = UUID.randomUUID().toString();
mutableAccountData.setAddress1(newAddress1);
accountUserApi.updateAccount(account.getId(), mutableAccountData, callContext);
final Account retrievedAccount = accountUserApi.getAccountById(account.getId(), callContext);
Assert.assertEquals(retrievedAccount.getAddress1(), newAddress1);
Assert.assertEquals(retrievedAccount.getAddress2(), account.getAddress2());
Assert.assertEquals(retrievedAccount.getCurrency(), account.getCurrency());
Assert.assertEquals(retrievedAccount.getExternalKey(), account.getExternalKey());
Assert.assertEquals(retrievedAccount.getBillCycleDayLocal(), account.getBillCycleDayLocal());
}
代码示例来源:origin: killbill/killbill
public Account createAccount(final LocalDate dateOfLastUnPaidInvoice) throws SubscriptionBaseApiException, AccountApiException {
final UUID accountId = UUID.randomUUID();
final Account account = Mockito.mock(Account.class);
Mockito.when(account.getId()).thenReturn(accountId);
Mockito.when(account.getTimeZone()).thenReturn(DateTimeZone.UTC);
Mockito.when(accountInternalApi.getAccountById(Mockito.eq(account.getId()), Mockito.
final Invoice invoice = Mockito.mock(Invoice.class);
Mockito.when(invoice.getInvoiceDate()).thenReturn(dateOfLastUnPaidInvoice);
Mockito.when(invoice.getBalance()).thenReturn(BigDecimal.TEN);
Mockito.when(invoice.getStatus()).thenReturn(InvoiceStatus.COMMITTED);
Mockito.when(invoice.getId()).thenReturn(UUID.randomUUID());
final InvoiceItem item = Mockito.mock(InvoiceItem.class);
final List
items.add(item);
Mockito.when(invoice.getInvoiceItems()).thenReturn(items);
final List
invoices.add(invoice);
Mockito.when(invoiceInternalApi.getUnpaidInvoicesByAccountId(Mockito.
final Tag tag = Mockito.mock(Tag.class);
Mockito.when(tag.getObjectId()).thenReturn(accountId);
Mockito.when(tag.getObjectType()).thenReturn(ObjectType.ACCOUNT);
Mockito.when(tag.getTagDefinitionId()).thenReturn(ControlTagType.TEST.getId());
final List
tags.add(tag);
Mockito.when(tagInternalApi.getTags(Mockito.eq(account.getId()), Mockito.eq(ObjectType.ACCOUNT), Mockito.
.thenReturn(tags);
return account;
}
代码示例来源:origin: killbill/killbill
public DefaultImmutableAccountData(final Account account) {
this(account.getId(),
account.getExternalKey(),
account.getCurrency(),
account.getTimeZone(),
AccountDateTimeUtils.getFixedOffsetTimeZone(account),
account.getReferenceTime());
}
代码示例来源:origin: killbill/killbill
public static DateTimeZone getFixedOffsetTimeZone(final Account account) {
return getFixedOffsetTimeZone(account.getTimeZone(), account.getReferenceTime());
}
代码示例来源:origin: killbill/killbill
currentAccount.getExternalKey() != null &&
!currentAccount.getExternalKey().equals(externalKey)) {
throw new IllegalArgumentException(String.format("Killbill doesn't support updating the account external key yet: new=%s, current=%s",
externalKey, currentAccount.getExternalKey()));
currentAccount.getCurrency() != null &&
!currentAccount.getCurrency().equals(currency)) {
throw new IllegalArgumentException(String.format("Killbill doesn't support updating the account currency yet: new=%s, current=%s",
currency, currentAccount.getCurrency()));
currentAccount.getBillCycleDayLocal() != DEFAULT_BILLING_CYCLE_DAY_LOCAL && // There is already a BCD set
!currentAccount.getBillCycleDayLocal().equals(billCycleDayLocal)) { // and it does not match we we have
throw new IllegalArgumentException(String.format("Killbill doesn't support updating the account BCD yet: new=%s, current=%s", billCycleDayLocal, currentAccount.getBillCycleDayLocal()));
currentAccount.getTimeZone() != null &&
!currentAccount.getTimeZone().equals(timeZone)) {
throw new IllegalArgumentException(String.format("Killbill doesn't support updating the account timeZone yet: new=%s, current=%s",
timeZone, currentAccount.getTimeZone()));
if (referenceTime != null && currentAccount.getReferenceTime().withMillisOfDay(0).compareTo(referenceTime.withMillisOfDay(0)) != 0) {
throw new IllegalArgumentException(String.format("Killbill doesn't support updating the account referenceTime yet: new=%s, current=%s",
referenceTime, currentAccount.getReferenceTime()));
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "slow")
public void testAccountBalanceWithNoInvoiceItems() throws EntityPersistenceException {
final UUID accountId = account.getId();
final LocalDate targetDate1 = new LocalDate(2011, 10, 6);
final Invoice invoice1 = new DefaultInvoice(accountId, clock.getUTCToday(), targetDate1, Currency.USD);
invoiceUtil.createInvoice(invoice1, context);
final BigDecimal payment1 = new BigDecimal("48.0");
final InvoicePayment payment = new DefaultInvoicePayment(InvoicePaymentType.ATTEMPT, UUID.randomUUID(), invoice1.getId(), new DateTime(), payment1, Currency.USD, Currency.USD, null, true);
invoiceUtil.createPayment(payment, context);
final BigDecimal balance = invoiceDao.getAccountBalance(accountId, context);
assertEquals(balance.compareTo(BigDecimal.ZERO.subtract(payment1)), 0);
}
代码示例来源:origin: org.kill-bill.billing/killbill-payment
@Test(groups = "slow")
public void testSimpleAuthCaptureWithInvalidPaymentId() throws Exception {
final BigDecimal requestedAmount = new BigDecimal("80.0091");
final Payment initialPayment = paymentApi.createAuthorization(account, account.getPaymentMethodId(), null, requestedAmount, account.getCurrency(), null,
UUID.randomUUID().toString(), UUID.randomUUID().toString(), ImmutableList.
try {
paymentApi.createCapture(account, UUID.randomUUID(), requestedAmount, account.getCurrency(), null, UUID.randomUUID().toString(), ImmutableList.
Assert.fail("Expected capture to fail...");
} catch (final PaymentApiException e) {
Assert.assertEquals(e.getCode(), ErrorCode.PAYMENT_NO_SUCH_PAYMENT.getCode());
final Payment latestPayment = paymentApi.getPayment(initialPayment.getId(), true, false, ImmutableList.
assertEquals(latestPayment, initialPayment);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "slow")
public void testGetInvoiceItemsBySubscriptionId() throws EntityPersistenceException {
final UUID accountId = account.getId();
final UUID subscriptiOnId= UUID.randomUUID();
final UUID bundleId = UUID.randomUUID();
final LocalDate startDate = new LocalDate(2011, 3, 1);
final BigDecimal rate = new BigDecimal("20.00");
for (int i = 0; i <3; i++) {
final UUID invoiceId = UUID.randomUUID();
final RecurringInvoiceItem item = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId,
"test product", "test plan", "test phase", startDate.plusMonths(i), startDate.plusMonths(i + 1),
rate, rate, Currency.USD);
invoiceUtil.createInvoiceItem(item, context);
}
final List
assertEquals(items.size(), 3);
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "slow")
public void testInvoicePayment() throws InvoiceApiException, EntityPersistenceException {
final UUID accountId = account.getId();
final Invoice invoice = new DefaultInvoice(accountId, clock.getUTCToday(), clock.getUTCToday(), Currency.USD);
final UUID invoiceId = invoice.getId();
final UUID subscriptiOnId= UUID.randomUUID();
final UUID bundleId = UUID.randomUUID();
final LocalDate startDate = new LocalDate(2010, 1, 1);
final LocalDate endDate = new LocalDate(2010, 4, 1);
final InvoiceItem invoiceItem = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, "test product", "test plan", "test phase", startDate, endDate,
new BigDecimal("21.00"), new BigDecimal("7.00"), Currency.USD);
invoice.addInvoiceItem(invoiceItem);
invoiceUtil.createInvoice(invoice, context);
final InvoiceModelDao savedInvoice = invoiceDao.getById(invoiceId, context);
assertNotNull(savedInvoice);
assertEquals(InvoiceModelDaoHelper.getRawBalanceForRegularInvoice(savedInvoice).compareTo(new BigDecimal("21.00")), 0);
assertEquals(savedInvoice.getInvoiceItems().size(), 1);
final BigDecimal paymentAmount = new BigDecimal("11.00");
final UUID paymentId = UUID.randomUUID();
final DefaultInvoicePayment defaultInvoicePayment = new DefaultInvoicePayment(InvoicePaymentType.ATTEMPT, paymentId, invoiceId, clock.getUTCNow().plusDays(12), paymentAmount, Currency.USD, Currency.USD, "COOKIE", true);
invoiceDao.notifyOfPaymentCompletion(new InvoicePaymentModelDao(defaultInvoicePayment), context);
final InvoiceModelDao retrievedInvoice = invoiceDao.getById(invoiceId, context);
assertNotNull(retrievedInvoice);
assertEquals(retrievedInvoice.getInvoiceItems().size(), 1);
assertEquals(InvoiceModelDaoHelper.getRawBalanceForRegularInvoice(retrievedInvoice).compareTo(new BigDecimal("10.00")), 0);
}
代码示例来源:origin: killbill/killbill
@Test(groups = "fast", description = "Test Account BCD merge")
public void testBCDMerges() throws Exception {
final UUID accountId = UUID.randomUUID();
final Currency currency = Currency.BRL;
final String externalKey = UUID.randomUUID().toString();
Assert.assertEquals(accountWithNullBCD.getBillCycleDayLocal(), (Integer) 0);
final Account accountWithZeroBCD = new DefaultAccount(accountId, accountDataWithZeroBCD);
Assert.assertEquals(accountWithNullBCD.mergeWithDelegate(accountWithZeroBCD).getBillCycleDayLocal(), (Integer) 0);
final Account accountWithRealBCD = new DefaultAccount(accountId, accountDataWithRealBCD);
Assert.assertEquals(accountWithNullBCD.mergeWithDelegate(accountWithRealBCD).getBillCycleDayLocal(), (Integer) 12);
final Account accountWithAnotherBCD = new DefaultAccount(accountId, accountDataWithAnotherRealBCD);
Assert.assertEquals(accountWithAnotherBCD.mergeWithDelegate(accountWithAnotherBCD).getBillCycleDayLocal(), (Integer) 20);
try {
Assert.assertEquals(accountWithAnotherBCD.mergeWithDelegate(accountWithRealBCD).getBillCycleDayLocal(), (Integer) 20);
Assert.fail();
} catch (final IllegalArgumentException e) {
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
private void createAndVerifyExternalCharge(final BigDecimal amount, final Currency currency) throws EntityPersistenceException {
final InvoiceItem externalChargeInvoiceItem = new ExternalChargeInvoiceItem(UUID.randomUUID(), account.getId(), UUID.randomUUID(),
UUID.randomUUID().toString(), new LocalDate(2012, 4, 1), new LocalDate(2012, 5, 1), amount, currency, null);
invoiceUtil.createInvoiceItem(externalChargeInvoiceItem, context);
final InvoiceItemModelDao savedItem = invoiceUtil.getInvoiceItemById(externalChargeInvoiceItem.getId(), context);
assertSameInvoiceItem(externalChargeInvoiceItem, savedItem);
Assert.assertEquals(externalChargeInvoiceItem.getAmount().compareTo(amount), 0);
}
代码示例来源:origin: org.kill-bill.billing/killbill-payment
@Test(groups = "fast")
public void testPaymentMethodExternalKeySetByPluginIfNonSpecified() throws Exception {
final Account account = Mockito.mock(Account.class);
final UUID accountId = UUID.randomUUID();
Mockito.when(account.getId()).thenReturn(accountId);
Mockito.when(account.getExternalKey()).thenReturn(accountId.toString());
final PaymentMethodPlugin paymentMethodPlugin = Mockito.mock(PaymentMethodPlugin.class);
final Iterable
// By default, the external payment plugin sets the external payment method id to "unknown"
final UUID paymentMethodId2 = paymentMethodProcessor.addPaymentMethod(null, "__EXTERNAL_PAYMENT__", account, false, paymentMethodPlugin, properties, callContext, internalCallContext);
final PaymentMethod paymentMethod2 = paymentMethodProcessor.getPaymentMethodById(paymentMethodId2, false, false, properties, callContext, internalCallContext);
Assert.assertEquals(paymentMethod2.getExternalKey(), "unknown");
}
代码示例来源:origin: org.kill-bill.billing.plugin.java/killbill-base-plugin
public static Account buildAccount(final Currency currency, final String address1, final String address2, final String city, final String stateOrProvince, final String postalCode, final String country) {
final Account account = Mockito.mock(Account.class);
Mockito.when(account.getId()).thenReturn(UUID.randomUUID());
Mockito.when(account.getExternalKey()).thenReturn(UUID.randomUUID().toString());
Mockito.when(account.getName()).thenReturn(UUID.randomUUID().toString());
Mockito.when(account.getFirstNameLength()).thenReturn(4);
Mockito.when(account.getEmail()).thenReturn(UUID.randomUUID().toString());
Mockito.when(account.getBillCycleDayLocal()).thenReturn(2);
Mockito.when(account.getCurrency()).thenReturn(currency);
Mockito.when(account.getPaymentMethodId()).thenReturn(UUID.randomUUID());
Mockito.when(account.getTimeZone()).thenReturn(DateTimeZone.getDefault());
// Return language tag to be able to use Locale.forLanguageTag
Mockito.when(account.getLocale()).thenReturn("en-US");
Mockito.when(account.getAddress1()).thenReturn(address1);
Mockito.when(account.getAddress2()).thenReturn(address2);
Mockito.when(account.getCompanyName()).thenReturn(UUID.randomUUID().toString());
Mockito.when(account.getCity()).thenReturn(city);
Mockito.when(account.getStateOrProvince()).thenReturn(stateOrProvince);
Mockito.when(account.getPostalCode()).thenReturn(postalCode);
Mockito.when(account.getCountry()).thenReturn(country);
Mockito.when(account.getPhone()).thenReturn(UUID.randomUUID().toString().substring(0, 25));
Mockito.when(account.isMigrated()).thenReturn(true);
Mockito.when(account.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 47, DateTimeZone.UTC));
Mockito.when(account.getUpdatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 48, DateTimeZone.UTC));
return account;
}
代码示例来源:origin: org.kill-bill.billing/killbill-payment
public Account createTestAccount(final String email, final boolean addPaymentMethod) throws Exception {
final String name = "First" + UUID.randomUUID().toString() + " " + "Last" + UUID.randomUUID().toString();
final String externalKey = UUID.randomUUID().toString();
Mockito.when(accountData.getId()).thenReturn(UUID.randomUUID());
Mockito.when(accountData.getExternalKey()).thenReturn(externalKey);
Mockito.when(accountData.getName()).thenReturn(name);
Mockito.when(accountData.getFirstNameLength()).thenReturn(10);
Mockito.when(accountData.getPhone()).thenReturn("123-456-7890");
Mockito.when(accountData.getEmail()).thenReturn(email);
Mockito.when(accountData.getCurrency()).thenReturn(Currency.USD);
Mockito.when(accountData.getBillCycleDayLocal()).thenReturn(1);
Mockito.when(accountData.isMigrated()).thenReturn(false);
Mockito.when(accountData.getTimeZone()).thenReturn(DateTimeZone.UTC);
final DateTime utcNow = clock.getUTCNow();
Mockito.when(accountData.getCreatedDate()).thenReturn(utcNow);
Mockito.when(accountData.getReferenceTime()).thenReturn(utcNow);
GuicyKillbillTestSuite.refreshCallContext(account.getId(), clock, internalCallContextFactory, mutableCallContext, internalCallContext);
代码示例来源:origin: killbill/killbill
@Test(groups = "slow")
public void testShouldntInsertMultipleNotificationsPerOverdueable() throws Exception {
final UUID accountId = UUID.randomUUID();
final Account overdueable = Mockito.mock(Account.class);
Mockito.when(overdueable.getId()).thenReturn(accountId);
insertOverdueCheckAndVerifyQueueContent(overdueable, 10, 10);
insertOverdueCheckAndVerifyQueueContent(overdueable, 5, 5);
insertOverdueCheckAndVerifyQueueContent(overdueable, 15, 5);
// Verify the final content of the queue
Assert.assertEquals(Iterables.size(overdueQueue.getFutureNotificationForSearchKeys(internalCallContext.getAccountRecordId(), internalCallContext.getTenantRecordId())), 1);
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "fast")
public void testProcessFixedBillingEventsWithCancellationOnNextDay() throws InvoiceApiException {
final LocalDate targetDate = new LocalDate("2016-01-08");
final UUID invoiceId = UUID.randomUUID();
final BillingEventSet events = new MockBillingEventSet();
final BigDecimal fixedPriceAmount = BigDecimal.TEN;
final MockInternationalPrice fixedPrice = new MockInternationalPrice(new DefaultPrice(fixedPriceAmount, Currency.USD));
final Plan plan = new MockPlan("my-plan");
final PlanPhase phase = new MockPlanPhase(null, fixedPrice, BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL);
final BillingEvent event1 = invoiceUtil.createMockBillingEvent(account, subscription, new DateTime("2016-01-08"),
plan, phase,
fixedPriceAmount, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1,
BillingMode.IN_ADVANCE, "Billing Event Desc", 1L,
SubscriptionBaseTransitionType.CREATE);
events.add(event1);
final BillingEvent event2 = invoiceUtil.createMockBillingEvent(account, subscription, new DateTime("2016-01-09"),
plan, phase,
null, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1,
BillingMode.IN_ADVANCE, "Billing Event Desc", 2L,
SubscriptionBaseTransitionType.CANCEL);
events.add(event2);
final List
fixedAndRecurringInvoiceItemGenerator.processFixedBillingEvents(invoiceId, account.getId(), events, targetDate, Currency.USD, proposedItems, internalCallContext);
assertEquals(proposedItems.size(), 1);
assertEquals(proposedItems.get(0).getInvoiceItemType(), InvoiceItemType.FIXED);
assertEquals(proposedItems.get(0).getAmount().compareTo(fixedPriceAmount), 0);
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "slow")
public void testGetByInvoiceItemId() throws EntityPersistenceException, InvoiceApiException {
final Invoice invoice1 = new DefaultInvoice(account.getId(), clock.getUTCToday(), clock.getUTCToday(), Currency.USD);
invoiceUtil.createInvoice(invoice1, context);
final UUID invoiceId1 = invoice1.getId();
LocalDate startDate = new LocalDate(2011, 3, 1);
LocalDate endDate = startDate.plusMonths(1);
final RecurringInvoiceItem recurringItem1 = new RecurringInvoiceItem(invoiceId1, account.getId(), UUID.randomUUID(), UUID.randomUUID(), "test product", "test plan", "test A", startDate, endDate,
BigDecimal.ONE, BigDecimal.ONE, Currency.USD);
invoiceUtil.createInvoiceItem(recurringItem1, context);
final InvoiceModelDao targetInvoice = invoiceDao.getByInvoiceItem(recurringItem1.getId(), internalCallContext);
assertNotNull(targetInvoice);
assertEquals(targetInvoice.getId(), invoiceId1);
assertEquals(targetInvoice.getInvoiceItems().size(), 1);
assertEquals(targetInvoice.getInvoiceItems().get(0).getId(), recurringItem1.getId());
}
代码示例来源:origin: killbill/killbill
public void clear(final DateTime effectiveDate, final InternalCallContext context) throws OverdueException, OverdueApiException {
GlobalLock lock = null;
try {
lock = locker.lockWithNumberOfTries(LockerType.ACCNT_INV_PAY.toString(), overdueable.getId().toString(), MAX_LOCK_RETRIES);
clearWithLock(effectiveDate, context);
} catch (final LockFailedException e) {
log.warn("Failed to clear overdue for accountId='{}'", overdueable.getId(), e);
} finally {
if (lock != null) {
lock.release();
}
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "slow")
public void testCreateParentInvoice() throws InvoiceApiException {
final UUID parentAccountId = UUID.randomUUID();
final UUID childAccountId = UUID.randomUUID();
final DateTime today = clock.getNow(account.getTimeZone());
InvoiceModelDao parentInvoice = new InvoiceModelDao(parentAccountId, today.toLocalDate(), account.getCurrency(), InvoiceStatus.DRAFT, true);
InvoiceItem parentInvoiceItem = new ParentInvoiceItem(UUID.randomUUID(), today, parentInvoice.getId(), parentAccountId, childAccountId, BigDecimal.TEN, account.getCurrency(), "");
parentInvoice.addInvoiceItem(new InvoiceItemModelDao(parentInvoiceItem));
invoiceDao.createInvoices(ImmutableList.
final InvoiceModelDao parentDraftInvoice = invoiceDao.getParentDraftInvoice(parentAccountId, context);
assertNotNull(parentDraftInvoice);
assertEquals(parentDraftInvoice.getStatus(), InvoiceStatus.DRAFT);
assertEquals(parentDraftInvoice.getInvoiceItems().size(), 1);
}