use of org.springframework.orm.ibatis.SqlMapClientTemplate in project pinpoint by naver.
the class SqlMapClientTemplateIT method deleteShouldBeTraced.
@Test
public void deleteShouldBeTraced() throws Exception {
// Given
final String deleteId = "deleteId";
SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
// When
clientTemplate.delete(deleteId);
clientTemplate.delete(deleteId, new Object());
clientTemplate.delete(deleteId, new Object(), 0);
// Then
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Method delete1 = SqlMapClientTemplate.class.getDeclaredMethod("delete", String.class);
Method delete2 = SqlMapClientTemplate.class.getDeclaredMethod("delete", String.class, Object.class);
Method delete3 = SqlMapClientTemplate.class.getDeclaredMethod("delete", String.class, Object.class, int.class);
verifier.verifyTrace(event("IBATIS_SPRING", delete1, Expectations.cachedArgs(deleteId)));
verifier.verifyTrace(event("IBATIS_SPRING", delete2, Expectations.cachedArgs(deleteId)));
verifier.verifyTrace(event("IBATIS_SPRING", delete3, Expectations.cachedArgs(deleteId)));
}
use of org.springframework.orm.ibatis.SqlMapClientTemplate in project pinpoint by naver.
the class SqlMapClientTemplateIT method insertShouldBeTraced.
@Test
public void insertShouldBeTraced() throws Exception {
// Given
final String insertId = "insertId";
SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
// When
clientTemplate.insert(insertId);
clientTemplate.insert(insertId, new Object());
// Then
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Method insert = SqlMapClientTemplate.class.getDeclaredMethod("insert", String.class);
Method insertWithParameter = SqlMapClientTemplate.class.getDeclaredMethod("insert", String.class, Object.class);
verifier.verifyTrace(event("IBATIS_SPRING", insert, Expectations.cachedArgs(insertId)));
verifier.verifyTrace(event("IBATIS_SPRING", insertWithParameter, Expectations.cachedArgs(insertId)));
}
use of org.springframework.orm.ibatis.SqlMapClientTemplate in project pinpoint by naver.
the class SqlMapClientTemplateIT method queryForMapShouldBeTraced.
@Test
public void queryForMapShouldBeTraced() throws Exception {
// Given
final String queryForMapId = "queryForMapId";
SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
// When
clientTemplate.queryForMap(queryForMapId, new Object(), "key");
clientTemplate.queryForMap(queryForMapId, new Object(), "key", "value");
// Then
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Method queryForMap1 = SqlMapClientTemplate.class.getDeclaredMethod("queryForMap", String.class, Object.class, String.class);
Method queryForMap2 = SqlMapClientTemplate.class.getDeclaredMethod("queryForMap", String.class, Object.class, String.class, String.class);
verifier.verifyTrace(event("IBATIS_SPRING", queryForMap1, Expectations.cachedArgs(queryForMapId)));
verifier.verifyTrace(event("IBATIS_SPRING", queryForMap2, Expectations.cachedArgs(queryForMapId)));
}
use of org.springframework.orm.ibatis.SqlMapClientTemplate in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method mostRecentId_shouldCacheResults.
@Test
public void mostRecentId_shouldCacheResults() throws Exception {
SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
stageDao.setSqlMapClientTemplate(mockTemplate);
when(mockTemplate.queryForObject(eq("getMostRecentId"), any())).thenReturn(20L);
stageDao.mostRecentId(CaseInsensitiveString.str(mingleConfig.name()), CaseInsensitiveString.str(mingleConfig.get(0).name()));
Long id = stageDao.mostRecentId(CaseInsensitiveString.str(mingleConfig.name()), CaseInsensitiveString.str(mingleConfig.get(0).name()));
assertThat(id, is(20L));
verify(mockTemplate, times(1)).queryForObject(eq("getMostRecentId"), any());
}
use of org.springframework.orm.ibatis.SqlMapClientTemplate in project gocd by gocd.
the class StageSqlMapDaoIntegrationTest method getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageStatusChange.
@Test
public void getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageStatusChange() {
SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
Stage newStage = StageMother.passedStageInstance("pipeline", "stage", 2, "job", new Date());
Stage first = StageMother.passedStageInstance("pipeline", "stage", 1, "job", new Date());
List<Stage> expected = asList(first);
List<Stage> expectedSecondTime = asList(first, newStage);
stageDao.setSqlMapClientTemplate(mockTemplate);
when(mockTemplate.queryForList(eq("getAllRunsOfStageForPipelineInstance"), any())).thenReturn(expected, expectedSecondTime);
stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
Pipeline pipeline = PipelineMother.pipeline("pipeline");
pipeline.setCounter(1);
updateResultInTransaction(newStage, StageResult.Passed);
Stages actual = stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
assertThat(actual.size(), is(2));
assertThat(actual, hasItem(newStage));
assertThat(actual, hasItem(first));
verify(mockTemplate, times(2)).queryForList(eq("getAllRunsOfStageForPipelineInstance"), any());
}
Aggregations