@Override public void doAudit(final AuditEntry auditEntry) { dbi.withHandle( new HandleCallback<Void>() { @Override public Void withHandle(Handle handle) throws Exception { doAudit(auditEntry, handle); return null; } } ); }
@Override public void insert(final String id, final SupervisorSpec spec) { dbi.withHandle( new HandleCallback<Void>() { @Override public Void withHandle(Handle handle) throws Exception { handle.createStatement( StringUtils.format( "INSERT INTO %s (spec_id, created_date, payload) VALUES (:spec_id, :created_date, :payload)", getSupervisorsTable() ) ) .bind("spec_id", id) .bind("created_date", DateTimes.nowUtc().toString()) .bind("payload", jsonMapper.writeValueAsBytes(spec)) .execute(); return null; } } ); }
@Override public void publishSegments(final String tableName, final List<DataSegment> segments, final ObjectMapper mapper) dbi.withHandle( new HandleCallback<Void>()
dbi.withHandle( new HandleCallback<Void>()
dbi.withHandle( new HandleCallback<Map<String, SupervisorSpec>>()
dbi.withHandle( new HandleCallback<Map<String, List<VersionedSupervisorSpec>>>()
private void insertAccount() throws IOException { 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, tenant_record_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", accountRecordId, accountId.toString(), accountId.toString(), "zozo@tt.com", "zozo", 4, new Date(), "UTC", new Date(), "i", new Date(), "j", tenantRecordId); return null; } }); }
private void insertTagDefinition() throws IOException { 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 tag_definitions (record_id, id, name, description, is_active, created_date, created_by, updated_date, updated_by, tenant_record_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", tagDefinitionRecordId, tagDefinitionId.toString(), "tagdef", "nothing", true, new Date(), "i", new Date(), "j", 0); return null; } }); }
private void insertHistoryAccount() throws IOException { 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 account_history (record_id, id, external_key, email, name, first_name_length, reference_time, time_zone, created_date, created_by, updated_date, updated_by, tenant_record_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", accountRecordId, accountId.toString(), accountId.toString(), "zozo@tt.com", "zozo", 4, new Date(), "UTC", new Date(), "i", new Date(), "j", tenantRecordId); return null; } }); }
private void insertTag() throws IOException { 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 tags (record_id, id, tag_definition_id, object_id, object_type, is_active, created_date, created_by, updated_date, updated_by, account_record_id, tenant_record_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", tagRecordId, tagId.toString(), tagDefinitionId.toString(), accountId.toString(), "ACCOUNT", true, new Date(), "i", new Date(), "j", accountRecordId, 0); return null; } }); }
private void insertTenant() throws IOException { 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 tenants (record_id, id, external_key, api_key, api_secret, api_salt, created_date, created_by, updated_date, updated_by) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", tenantRecordId, tenantId.toString(), "foo", "key", "secret", "salt", new Date(), "i", new Date(), "j"); return null; } }); } }
return dbi.withHandle( new HandleCallback<List<AuditEntry>>()
return dbi.withHandle( new HandleCallback<List<AuditEntry>>()
@Override public Boolean call() throws Exception { final long pending = idbi.withHandle(new PendingBusOrNotificationCallback(clock)); log.debug("Events still in processing: {}", pending); return pending == 0; } });
@BeforeClass(groups = "fast") public void beforeClass() throws Exception { if (hasFailed()) { return; } final Injector g = Guice.createInjector(Stage.PRODUCTION, new TestDefaultSubscriptionModuleNoDB(configSource, clock)); g.injectMembers(this); // For TestApiListener#isCompleted Mockito.doReturn(0L).when(idbi).withHandle(Mockito.<HandleCallback<Long>>any()); }
dbi.withHandle( new HandleCallback<Map<String, List<Rule>>>()
final String theQueryString = queryString; return dbi.withHandle( new HandleCallback<List<AuditEntry>>()
@Override @BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); 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; } }); }
@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); }
dbi.withHandle( new HandleCallback<Void>()