Search in sources :

Example 1 with MutableCallContext

use of org.killbill.billing.callcontext.MutableCallContext in project killbill by killbill.

the class TestPaymentHelper method createTestAccount.

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();
    final Account accountData = Mockito.mock(Account.class);
    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);
    final MutableCallContext mutableCallContext = new MutableCallContext(internalCallContext);
    Account account;
    if (isFastTest()) {
        account = GuicyKillbillTestSuiteNoDB.createMockAccount(accountData, accountApi, accountInternalApi, immutableAccountInternalApi, nonEntityDao, clock, internalCallContextFactory, mutableCallContext, internalCallContext);
    } else {
        account = accountApi.createAccount(accountData, context);
    }
    GuicyKillbillTestSuite.refreshCallContext(account.getId(), clock, internalCallContextFactory, mutableCallContext, internalCallContext);
    if (addPaymentMethod) {
        final PaymentMethodPlugin pm = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), true, null);
        account = addTestPaymentMethod(account, pm);
    }
    return account;
}
Also used : Account(org.killbill.billing.account.api.Account) MutableCallContext(org.killbill.billing.callcontext.MutableCallContext) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin) PaymentMethodPlugin(org.killbill.billing.payment.api.PaymentMethodPlugin) DateTime(org.joda.time.DateTime) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin)

Example 2 with MutableCallContext

use of org.killbill.billing.callcontext.MutableCallContext in project killbill by killbill.

the class TestInvoiceHelper method createAccount.

public Account createAccount(final CallContext callContext) throws AccountApiException {
    final Account accountData = new MockAccountBuilder().name(UUID.randomUUID().toString().substring(1, 8)).firstNameLength(6).email(UUID.randomUUID().toString().substring(1, 8)).phone(UUID.randomUUID().toString().substring(1, 8)).migrated(false).externalKey(UUID.randomUUID().toString().substring(1, 8)).billingCycleDayLocal(31).currency(accountCurrency).paymentMethodId(UUID.randomUUID()).timeZone(DateTimeZone.UTC).createdDate(clock.getUTCNow()).build();
    final MutableCallContext mutableCallContext = new MutableCallContext(internalCallContext);
    final Account account;
    if (isFastTest()) {
        account = GuicyKillbillTestSuiteNoDB.createMockAccount(accountData, accountUserApi, accountApi, immutableAccountApi, nonEntityDao, clock, internalCallContextFactory, mutableCallContext, internalCallContext);
    } else {
        account = accountUserApi.createAccount(accountData, callContext);
    }
    GuicyKillbillTestSuite.refreshCallContext(account.getId(), clock, internalCallContextFactory, mutableCallContext, internalCallContext);
    return account;
}
Also used : Account(org.killbill.billing.account.api.Account) MockAccountBuilder(org.killbill.billing.mock.MockAccountBuilder) MutableCallContext(org.killbill.billing.callcontext.MutableCallContext)

Aggregations

Account (org.killbill.billing.account.api.Account)2 MutableCallContext (org.killbill.billing.callcontext.MutableCallContext)2 DateTime (org.joda.time.DateTime)1 MockAccountBuilder (org.killbill.billing.mock.MockAccountBuilder)1 PaymentMethodPlugin (org.killbill.billing.payment.api.PaymentMethodPlugin)1 DefaultNoOpPaymentMethodPlugin (org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin)1