@Test(groups = "slow") public void testCreateInternalCallContextWithAccountRecordIdFromAccountObjectType() throws Exception { final UUID accountId = UUID.randomUUID(); final Long accountRecordId = 19384012L; final ImmutableAccountData immutableAccountData = Mockito.mock(ImmutableAccountData.class); Mockito.when(immutableAccountInternalApi.getImmutableAccountDataByRecordId(Mockito.<Long>eq(accountRecordId), Mockito.<InternalTenantContext>any())).thenReturn(immutableAccountData); dbi.withHandle(new HandleCallback<Void>() { @Override public Void withHandle(final Handle handle) throws Exception { // Note: we always create an accounts table, see MysqlTestingHelper handle.execute("insert into accounts (record_id, id, external_key, email, name, first_name_length, reference_time, time_zone, created_date, created_by, updated_date, updated_by) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", accountRecordId, accountId.toString(), accountId.toString(), "yo@t.com", "toto", 4, new Date(), "UTC", new Date(), "i", new Date(), "j"); return null; } }); final InternalCallContext context = internalCallContextFactory.createInternalCallContext(accountId, ObjectType.ACCOUNT, callContext); // The account record id should have been looked up in the accounts table Assert.assertEquals(context.getAccountRecordId(), accountRecordId); verifyInternalCallContext(context); }
@Test(groups = "slow") public void testCreateInternalCallContextWithAccountRecordIdFromAccountObjectType() throws Exception { final UUID accountId = UUID.randomUUID(); final Long accountRecordId = 19384012L; final ImmutableAccountData immutableAccountData = Mockito.mock(ImmutableAccountData.class); Mockito.when(immutableAccountInternalApi.getImmutableAccountDataByRecordId(Mockito.<Long>eq(accountRecordId), Mockito.<InternalTenantContext>any())).thenReturn(immutableAccountData); dbi.withHandle(new HandleCallback<Void>() { @Override public Void withHandle(final Handle handle) throws Exception { // Note: we always create an accounts table, see MysqlTestingHelper handle.execute("insert into accounts (record_id, id, external_key, email, name, first_name_length, reference_time, time_zone, created_date, created_by, updated_date, updated_by) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", accountRecordId, accountId.toString(), accountId.toString(), "yo@t.com", "toto", 4, new Date(), "UTC", new Date(), "i", new Date(), "j"); return null; } }); final InternalCallContext context = internalCallContextFactory.createInternalCallContext(accountId, ObjectType.ACCOUNT, callContext); // The account record id should have been looked up in the accounts table Assert.assertEquals(context.getAccountRecordId(), accountRecordId); verifyInternalCallContext(context); }