Search in sources :

Example 1 with SqlMapClientTemplate

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)));
}
Also used : SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 2 with SqlMapClientTemplate

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)));
}
Also used : SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 3 with SqlMapClientTemplate

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)));
}
Also used : SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 4 with SqlMapClientTemplate

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());
}
Also used : SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) Test(org.junit.Test)

Example 5 with SqlMapClientTemplate

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());
}
Also used : SqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate) Test(org.junit.Test)

Aggregations

SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)35 Test (org.junit.Test)34 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)8 Method (java.lang.reflect.Method)8 StageHistoryEntry (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryEntry)2 StageHistoryPage (com.thoughtworks.go.presentation.pipelinehistory.StageHistoryPage)2 TransactionManager (com.ibatis.sqlmap.engine.transaction.TransactionManager)1 Cache (com.opensymphony.oscache.base.Cache)1 Cloner (com.rits.cloning.Cloner)1 FeedEntry (com.thoughtworks.go.domain.feed.FeedEntry)1 StageFeedEntry (com.thoughtworks.go.domain.feed.stage.StageFeedEntry)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 GoCache (com.thoughtworks.go.server.cache.GoCache)1 StubGoCache (com.thoughtworks.go.server.service.StubGoCache)1 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)1 Before (org.junit.Before)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1