use of org.qi4j.index.sql.support.common.GenericDatabaseExplorer.DatabaseProcessorAdapter in project qi4j-sdk by Qi4j.
the class PostgreSQLDBIntegrityTest method createAndRemoveEntityAndVerifyNoExtraDataLeftInDB.
@Test
public void createAndRemoveEntityAndVerifyNoExtraDataLeftInDB() throws Exception {
UnitOfWork uow = this.module.newUnitOfWork();
TestEntity entity = uow.newEntity(TestEntity.class);
uow.complete();
uow = this.module.newUnitOfWork();
entity = uow.get(entity);
SQLConfiguration config = uow.get(SQLConfiguration.class, PostgreSQLIndexQueryAssembler.DEFAULT_IDENTITY);
String schemaName = config.schemaName().get();
if (schemaName == null) {
schemaName = PostgreSQLAppStartup.DEFAULT_SCHEMA_NAME;
}
uow.remove(entity);
uow.complete();
Connection connection = this.module.findService(DataSource.class).get().getConnection();
try {
GenericDatabaseExplorer.visitDatabaseTables(connection, null, schemaName, null, new DatabaseProcessorAdapter() {
@Override
public void beginProcessRowInfo(String schemaNamee, String tableName, Object[] rowContents) {
if ((tableName.startsWith(DBNames.QNAME_TABLE_NAME_PREFIX) && (tableName.equals(DBNames.QNAME_TABLE_NAME_PREFIX + 0) || tableName.equals(DBNames.QNAME_TABLE_NAME_PREFIX + 1))) || tableName.equals(DBNames.ALL_QNAMES_TABLE_NAME) || tableName.equals(DBNames.ENTITY_TABLE_NAME)) {
throw new RuntimeException("Table: " + schemaNamee + "." + tableName);
}
}
}, SQLVendorProvider.createVendor(PostgreSQLVendor.class));
} finally {
SQLUtil.closeQuietly(connection);
}
}
Aggregations