use of com.evolveum.midpoint.repo.sqlbase.querydsl.SqlRecorder in project midpoint by Evolveum.
the class SqaleRepoSmokeTest method test400SqlLogger.
@Test
public void test400SqlLogger() throws Exception {
if (!SqlRecorder.LOGGER.isDebugEnabled()) {
throw new SkipException("We need debug on SqlRecorder logger for this test");
}
OperationResult result = createOperationResult();
// INSERT + UPDATE
queryRecorder.clearBufferAndStartRecording();
String oid = repositoryService.addObject(new UserType(prismContext).name("user" + getTestNumber()).asPrismObject(), null, result);
// These assertions are quite implementation dependent, obviously.
Queue<SqlRecorder.QueryEntry> queryBuffer = queryRecorder.getQueryBuffer();
assertThat(queryBuffer).hasSize(2);
SqlRecorder.QueryEntry entry = queryBuffer.remove();
assertThat(entry.sql).startsWith("insert into m_user");
entry = queryBuffer.remove();
assertThat(entry.sql).startsWith("update m_user");
// param for where oid = ...
assertThat(entry.params.get(2)).isEqualTo(oid);
// COUNT
queryRecorder.clearBufferAndStartRecording();
int count = repositoryService.countObjects(UserType.class, null, null, result);
// at least user from above should be there
assertThat(count).isGreaterThanOrEqualTo(1);
queryBuffer = queryRecorder.getQueryBuffer();
assertThat(queryBuffer).hasSize(1);
entry = queryBuffer.remove();
assertThat(entry.sql).startsWith("select count(*)");
// normal select
queryRecorder.clearBufferAndStartRecording();
SearchResultList<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, null, null, result);
assertThat(users).isNotEmpty();
queryBuffer = queryRecorder.getQueryBuffer();
assertThat(queryBuffer).hasSize(1);
entry = queryBuffer.remove();
assertThat(entry.sql).startsWith("select u.oid, u.fullObject");
}
use of com.evolveum.midpoint.repo.sqlbase.querydsl.SqlRecorder in project midpoint by Evolveum.
the class SqaleRepoBaseTest method initDatabase.
@BeforeClass
public void initDatabase() throws Exception {
queryRecorder = new SqlRecorder(QUERY_BUFFER_SIZE);
sqlRepoContext.setQuerydslSqlListener(queryRecorder);
if (System.getProperty(SYSTEM_PROPERTY_SKIP_DB_CLEAR) == null) {
clearDatabase();
}
}
Aggregations