use of org.killbill.billing.tenant.dao.TenantSqlDao in project killbill by killbill.
the class TestDefaultAccountUserApi method testCreateAccountWithSameExternalKeyInDifferentTenants.
@Test(groups = "slow", description = "Test Account creation with same External Key in different tenants")
public void testCreateAccountWithSameExternalKeyInDifferentTenants() throws Exception {
final AccountData accountData = createAccountData();
final Account account1 = accountUserApi.createAccount(accountData, callContext);
try {
// Same tenant
accountUserApi.createAccount(accountData, callContext);
Assert.fail();
} catch (final AccountApiException e) {
assertEquals(e.getCode(), ErrorCode.ACCOUNT_ALREADY_EXISTS.getCode());
}
final TenantSqlDao tenantSqlDao = dbi.onDemand(TenantSqlDao.class);
final TenantModelDao tenant2 = new TenantModelDao();
tenantSqlDao.create(tenant2, internalCallContext);
final CallContext callContext2 = new DefaultCallContext(tenant2.getId(), callContext.getUserName(), callContext.getCallOrigin(), callContext.getUserType(), callContext.getUserToken(), clock);
final Account account2 = accountUserApi.createAccount(accountData, callContext2);
Assert.assertEquals(account1.getExternalKey(), account2.getExternalKey());
Assert.assertNotEquals(account1.getId(), account2.getId());
}
Aggregations