Search in sources :

Example 1 with DefaultAccountData

use of org.killbill.billing.account.api.user.DefaultAccountCreationEvent.DefaultAccountData in project killbill by killbill.

the class TestEventJson method testAccountCreationEvent.

@Test(groups = "fast", description = "Test Account event serialization")
public void testAccountCreationEvent() throws Exception {
    final DefaultAccountData data = new DefaultAccountData("dsfdsf", "bobo", 3, "bobo@yahoo.com", 12, "USD", null, false, UUID.randomUUID(), new DateTime().toString(), "UTC", "US", "21 avenue", "", "Gling", "San Franciso", "CA", "94110", "USA", "4126789887", "notes", false);
    final DefaultAccountCreationEvent e = new DefaultAccountCreationEvent(data, UUID.randomUUID(), 1L, 2L, null);
    final String json = mapper.writeValueAsString(e);
    final DefaultAccountCreationEvent obj = mapper.readValue(json, DefaultAccountCreationEvent.class);
    Assert.assertTrue(obj.equals(e));
}
Also used : DefaultAccountData(org.killbill.billing.account.api.user.DefaultAccountCreationEvent.DefaultAccountData) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 2 with DefaultAccountData

use of org.killbill.billing.account.api.user.DefaultAccountCreationEvent.DefaultAccountData in project killbill by killbill.

the class DefaultAccountDao method postBusEventFromTransaction.

@Override
protected void postBusEventFromTransaction(final AccountModelDao account, final AccountModelDao savedAccount, final ChangeType changeType, final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final InternalCallContext context) throws BillingExceptionBase {
    // This is only called for the create call (see update below)
    switch(changeType) {
        case INSERT:
            break;
        default:
            return;
    }
    final Long recordId = savedAccount.getRecordId();
    // We need to re-hydrate the callcontext with the account record id
    final InternalCallContext rehydratedContext = internalCallContextFactory.createInternalCallContext(savedAccount, recordId, context);
    final AccountCreationInternalEvent creationEvent = new DefaultAccountCreationEvent(new DefaultAccountData(savedAccount), savedAccount.getId(), rehydratedContext.getAccountRecordId(), rehydratedContext.getTenantRecordId(), rehydratedContext.getUserToken());
    try {
        eventBus.postFromTransaction(creationEvent, entitySqlDaoWrapperFactory.getHandle().getConnection());
    } catch (final EventBusException e) {
        log.warn("Failed to post account creation event for accountId='{}'", savedAccount.getId(), e);
    }
}
Also used : DefaultAccountCreationEvent(org.killbill.billing.account.api.user.DefaultAccountCreationEvent) EventBusException(org.killbill.bus.api.PersistentBus.EventBusException) InternalCallContext(org.killbill.billing.callcontext.InternalCallContext) DefaultAccountData(org.killbill.billing.account.api.user.DefaultAccountCreationEvent.DefaultAccountData) AccountCreationInternalEvent(org.killbill.billing.events.AccountCreationInternalEvent)

Example 3 with DefaultAccountData

use of org.killbill.billing.account.api.user.DefaultAccountCreationEvent.DefaultAccountData in project killbill by killbill.

the class MockAccountDao method create.

@Override
public void create(final AccountModelDao account, final InternalCallContext context) throws AccountApiException {
    super.create(account, context);
    try {
        final Long accountRecordId = getRecordId(account.getId(), context);
        final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID : context.getTenantRecordId();
        eventBus.post(new DefaultAccountCreationEvent(new DefaultAccountData(account), account.getId(), accountRecordId, tenantRecordId, UUID.randomUUID()));
    } catch (final EventBusException ex) {
        Assert.fail(ex.toString());
    }
}
Also used : DefaultAccountCreationEvent(org.killbill.billing.account.api.user.DefaultAccountCreationEvent) EventBusException(org.killbill.bus.api.PersistentBus.EventBusException) DefaultAccountData(org.killbill.billing.account.api.user.DefaultAccountCreationEvent.DefaultAccountData)

Aggregations

DefaultAccountData (org.killbill.billing.account.api.user.DefaultAccountCreationEvent.DefaultAccountData)3 DefaultAccountCreationEvent (org.killbill.billing.account.api.user.DefaultAccountCreationEvent)2 EventBusException (org.killbill.bus.api.PersistentBus.EventBusException)2 DateTime (org.joda.time.DateTime)1 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)1 AccountCreationInternalEvent (org.killbill.billing.events.AccountCreationInternalEvent)1 Test (org.testng.annotations.Test)1