• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SqlMapClientTemplate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.orm.ibatis.SqlMapClientTemplate的典型用法代码示例。如果您正苦于以下问题:Java SqlMapClientTemplate类的具体用法?Java SqlMapClientTemplate怎么用?Java SqlMapClientTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqlMapClientTemplate类属于org.springframework.orm.ibatis包,在下文中一共展示了SqlMapClientTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: deleteShouldBeTraced

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@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)));
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:19,代码来源:SqlMapClientTemplateIT.java


示例2: updateShouldBeTraced

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void updateShouldBeTraced() throws Exception {
    // Given
    final String updateId = "updateId";
    SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    clientTemplate.update(updateId);
    clientTemplate.update(updateId, new Object());
    clientTemplate.update(updateId, new Object(), 0);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method update1 = SqlMapClientTemplate.class.getDeclaredMethod("update", String.class);
    Method update2 = SqlMapClientTemplate.class.getDeclaredMethod("update", String.class, Object.class);
    Method update3 = SqlMapClientTemplate.class.getDeclaredMethod("update", String.class, Object.class, int.class);
    verifier.verifyTrace(event("IBATIS_SPRING", update1, Expectations.cachedArgs(updateId)));
    verifier.verifyTrace(event("IBATIS_SPRING", update2, Expectations.cachedArgs(updateId)));
    verifier.verifyTrace(event("IBATIS_SPRING", update3, Expectations.cachedArgs(updateId)));
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:19,代码来源:SqlMapClientTemplateIT.java


示例3: queryForListShouldBeTraced

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void queryForListShouldBeTraced() throws Exception {
    // Given
    final String queryForListId = "queryForListId";
    SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    clientTemplate.queryForList(queryForListId);
    clientTemplate.queryForList(queryForListId, new Object());
    clientTemplate.queryForList(queryForListId, 0, 1);
    clientTemplate.queryForList(queryForListId, new Object(), 0, 1);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method queryForList1 = SqlMapClientTemplate.class.getDeclaredMethod("queryForList", String.class);
    Method queryForList2 = SqlMapClientTemplate.class.getDeclaredMethod("queryForList", String.class, Object.class);
    Method queryForList3 = SqlMapClientTemplate.class.getDeclaredMethod("queryForList", String.class, int.class,
            int.class);
    Method queryForList4 = SqlMapClientTemplate.class.getDeclaredMethod("queryForList", String.class, Object.class,
            int.class, int.class);
    verifier.verifyTrace(event("IBATIS_SPRING", queryForList1, Expectations.cachedArgs(queryForListId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForList2, Expectations.cachedArgs(queryForListId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForList3, Expectations.cachedArgs(queryForListId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForList4, Expectations.cachedArgs(queryForListId)));
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:24,代码来源:SqlMapClientTemplateIT.java


示例4: queryForMapShouldBeTraced

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@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)));
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:18,代码来源:SqlMapClientTemplateIT.java


示例5: queryForObjectShouldBeTraced

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void queryForObjectShouldBeTraced() throws Exception {
    // Given
    final String queryForObjectId = "queryForObjectId";
    SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    clientTemplate.queryForObject(queryForObjectId);
    clientTemplate.queryForObject(queryForObjectId, new Object());
    clientTemplate.queryForObject(queryForObjectId, new Object(), new Object());
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method queryForObject1 = SqlMapClientTemplate.class.getDeclaredMethod("queryForObject", String.class);
    Method queryForObject2 = SqlMapClientTemplate.class.getDeclaredMethod("queryForObject", String.class,
            Object.class);
    Method queryForObject3 = SqlMapClientTemplate.class.getDeclaredMethod("queryForObject", String.class,
            Object.class, Object.class);
    verifier.verifyTrace(event("IBATIS_SPRING", queryForObject1, Expectations.cachedArgs(queryForObjectId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForObject2, Expectations.cachedArgs(queryForObjectId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForObject3, Expectations.cachedArgs(queryForObjectId)));
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:21,代码来源:SqlMapClientTemplateIT.java


示例6: queryForPaginagedListShouldBeTraced

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
@SuppressWarnings("deprecation")
public void queryForPaginagedListShouldBeTraced() throws Exception {
    // Given
    final String queryForPaginatedListId = "queryForPaginatedListId";
    // to emulate lazy-loading, otherwise exception is thrown
    TransactionManager mockTxManager = mock(TransactionManager.class);
    when(this.mockSqlMapExecutorDelegate.getTxManager()).thenReturn(mockTxManager);
    SqlMapClientTemplate clientTemplate = new SqlMapClientTemplate(this.mockDataSource, this.sqlMapClient);
    // When
    clientTemplate.queryForPaginatedList(queryForPaginatedListId, 1);
    clientTemplate.queryForPaginatedList(queryForPaginatedListId, new Object(), 1);
    // Then
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Method queryForPaginatedList1 = SqlMapClientTemplate.class.getDeclaredMethod("queryForPaginatedList",
            String.class, int.class);
    Method queryForPaginatedList2 = SqlMapClientTemplate.class.getDeclaredMethod("queryForPaginatedList",
            String.class, Object.class, int.class);
    verifier.verifyTrace(event("IBATIS_SPRING", queryForPaginatedList1,
            Expectations.cachedArgs(queryForPaginatedListId)));
    verifier.verifyTrace(event("IBATIS_SPRING", queryForPaginatedList2,
            Expectations.cachedArgs(queryForPaginatedListId)));
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:24,代码来源:SqlMapClientTemplateIT.java


示例7: setup

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    goCache.clear();
    mockTemplate = mock(SqlMapClientTemplate.class);
    repository = mock(MaterialRepository.class);
    environmentVariableDao = mock(EnvironmentVariableDao.class);
    mockSessionFactory = mock(SessionFactory.class);
    repository = mock(MaterialRepository.class);
    transactionTemplate = mock(TransactionTemplate.class);
    configFileDao = mock(GoConfigDao.class);
    pipelineDao = new PipelineSqlMapDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null,
            transactionSynchronizationManager, null, configFileDao, mock(Database.class), mockSessionFactory);
    pipelineDao.setSqlMapClientTemplate(mockTemplate);
    session = mock(Session.class);
    when(mockSessionFactory.getCurrentSession()).thenReturn(session);
    when(configFileDao.load()).thenReturn(GoConfigMother.defaultCruiseConfig());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:PipelineSqlMapDaoCachingTest.java


示例8: setup

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    goCache.clear();
    mockTemplate = mock(SqlMapClientTemplate.class);
    repository = mock(MaterialRepository.class);
    environmentVariableDao = mock(EnvironmentVariableDao.class);
    mockSessionFactory = mock(SessionFactory.class);
    repository = mock(MaterialRepository.class);
    transactionTemplate = mock(TransactionTemplate.class);
    configFileDao = mock(GoConfigDao.class);
    pipelineStateDao = new PipelineStateDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null,
            transactionSynchronizationManager, null, configFileDao, mock(Database.class), mockSessionFactory);
    pipelineStateDao.setSqlMapClientTemplate(mockTemplate);
    session = mock(Session.class);
    when(mockSessionFactory.getCurrentSession()).thenReturn(session);
    when(configFileDao.load()).thenReturn(GoConfigMother.defaultCruiseConfig());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:PipelineStateDaoCachingTest.java


示例9: setUp

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Before
public void setUp() {
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    sqlMapClientTemplate = mock(SqlMapClientTemplate.class);
    stageSqlMapDao = new StageSqlMapDao(mock(JobInstanceSqlMapDao.class), new Cache(true, false, false), mock(TransactionTemplate.class), mock(SqlMapClient.class), goCache,
            mock(TransactionSynchronizationManager.class), mock(SystemEnvironment.class), null);
    stageSqlMapDao.setSqlMapClientTemplate(sqlMapClientTemplate);
    cloner = mock(Cloner.class);
    ReflectionUtil.setField(stageSqlMapDao, "cloner", cloner);
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return invocationOnMock.getArguments()[0];
        }
    }).when(cloner).deepClone(anyObject());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:17,代码来源:StageSqlMapDaoTest.java


示例10: getTotalStageCountForChart_shouldInvalidateTheCountCacheOnStageSchedule

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getTotalStageCountForChart_shouldInvalidateTheCountCacheOnStageSchedule() throws SQLException {
    SqlMapClientTemplate mockClient = mock(SqlMapClientTemplate.class);
    stageDao.setSqlMapClientTemplate(mockClient);

    Map<String, Object> toGet = arguments("pipelineName", "maar").and("stageName", "khoon").asMap();

    when(mockClient.queryForObject("getTotalStageCountForChart", toGet)).thenReturn(3).thenReturn(4);

    assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(3));//Should prime the cache
    Stage stage = new Stage("khoon", new JobInstances(), "foo", "manual", new TimeProvider());
    Pipeline pipeline = new Pipeline("maar", "${COUNT}", BuildCause.createWithEmptyModifications(), stage);
    pipeline.setId(1);
    stageDao.save(pipeline, stage);//Should Invalidate the cache

    assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(4));//should refetch

    verify(mockClient, times(2)).queryForObject("getTotalStageCountForChart", toGet);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:StageSqlMapDaoIntegrationTest.java


示例11: getTotalStageCountForChart_shouldInvalidateTheCountCacheOnStageUpdate

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getTotalStageCountForChart_shouldInvalidateTheCountCacheOnStageUpdate() throws SQLException {
    SqlMapClientTemplate mockClient = mock(SqlMapClientTemplate.class);
    stageDao.setSqlMapClientTemplate(mockClient);

    Map<String, Object> toGet = arguments("pipelineName", "maar").and("stageName", "khoon").asMap();

    when(mockClient.queryForObject("getTotalStageCountForChart", toGet)).thenReturn(3).thenReturn(4);

    assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(3));//Should prime the cache
    Stage stage = new Stage("khoon", new JobInstances(), "foo", "manual", new TimeProvider());
    stage.setIdentifier(new StageIdentifier("maar/2/khoon/1"));
    updateResultInTransaction(stage, StageResult.Cancelled);//Should Invalidate the cache

    assertThat(stageDao.getTotalStageCountForChart("maar", "khoon"), is(4));//should refetch

    verify(mockClient, times(2)).queryForObject("getTotalStageCountForChart", toGet);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:19,代码来源:StageSqlMapDaoIntegrationTest.java


示例12: getAllRunsOfStageForPipelineInstance_shouldCacheAllTheStages

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getAllRunsOfStageForPipelineInstance_shouldCacheAllTheStages() {
    SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);

    Stage first = StageMother.passedStageInstance("pipeline", "stage", 1, "job", new Date());
    Stage second = StageMother.passedStageInstance("pipeline", "stage", 2, "job", new Date());
    Stage third = StageMother.passedStageInstance("pipeline", "stage", 3, "job", new Date());
    List<Stage> expected = asList(third, second, first);

    stageDao.setSqlMapClientTemplate(mockTemplate);
    when(mockTemplate.queryForList(eq("getAllRunsOfStageForPipelineInstance"), any())).thenReturn(expected);

    Stages actual = stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
    assertEquals(expected, actual);
    assertThat(expected == actual, is(false));
    assertThat(expected.get(0) == actual.get(0), is(false));
    stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage");
    verify(mockTemplate, times(1)).queryForList(eq("getAllRunsOfStageForPipelineInstance"), any());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:StageSqlMapDaoIntegrationTest.java


示例13: getAllRunsOfStageForPipelineInstance_shouldClearCacheOnJobStateChange

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getAllRunsOfStageForPipelineInstance_shouldClearCacheOnJobStateChange() {
    SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);

    Stage first = StageMother.passedStageInstance("pipeline", "stage", 1, "job", new Date());
    Stage second = StageMother.passedStageInstance("pipeline", "stage", 2, "job", new Date());
    Stage third = StageMother.passedStageInstance("pipeline", "stage", 3, "job", new Date());
    List<Stage> expected = asList(third, second, first);

    stageDao.setSqlMapClientTemplate(mockTemplate);
    when(mockTemplate.queryForList(eq("getAllRunsOfStageForPipelineInstance"), any())).thenReturn(expected);

    assertThat(stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage"), is(expected));
    stageDao.jobStatusChanged(first.getFirstJob());
    assertThat(stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage"), is(expected));
    stageDao.jobStatusChanged(second.getFirstJob());
    assertThat(stageDao.getAllRunsOfStageForPipelineInstance("pipeline", 1, "stage"), is(expected));

    verify(mockTemplate, times(3)).queryForList(eq("getAllRunsOfStageForPipelineInstance"), any());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:21,代码来源:StageSqlMapDaoIntegrationTest.java


示例14: getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageSave

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageSave() {
    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);
    stageDao.save(pipeline, newStage);//should remove first from cache

    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());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:26,代码来源:StageSqlMapDaoIntegrationTest.java


示例15: getAllRunsOfStageForPipelineInstance_shouldRemoveFromCacheOnStageStatusChange

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@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());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:26,代码来源:StageSqlMapDaoIntegrationTest.java


示例16: mock

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void findStageWithIdentifier_shouldRemoveFromTheCacheAllStagesWithTheNameOfTheSameCounterOnStageStatusChange() {
    SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);

    Stage first = StageMother.passedStageInstance("pipeline", "stage", "job", new Date());
    first.setCounter(1);
    Stage second = StageMother.passedStageInstance("pipeline", "stage", "job", new Date());
    second.setCounter(2);

    stageDao.setSqlMapClientTemplate(mockTemplate);
    when(mockTemplate.queryForObject(eq("findStageWithJobsByIdentifier"), any())).thenReturn(first);

    Stage actual = stageDao.findStageWithIdentifier(new StageIdentifier("pipeline", 1, "stage", "1"));
    assertEquals(first, actual);

    updateResultInTransaction(second, StageResult.Unknown); //status of stage 2 changed. This should invalidate the stage 1 because of the latest run state.

    stageDao.findStageWithIdentifier(new StageIdentifier("pipeline", 1, "stage", "1"));

    verify(mockTemplate, times(2)).queryForObject(eq("findStageWithJobsByIdentifier"), any());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:22,代码来源:StageSqlMapDaoIntegrationTest.java


示例17: findStageWithIdentifier_shouldRemoveFromTheCacheOnSave

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void findStageWithIdentifier_shouldRemoveFromTheCacheOnSave() {
    SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);

    Stage first = StageMother.passedStageInstance("pipeline", "stage", "job", new Date());
    first.setCounter(1);
    Stage second = StageMother.passedStageInstance("pipeline", "stage", "job", new Date());
    second.setCounter(2);

    stageDao.setSqlMapClientTemplate(mockTemplate);
    when(mockTemplate.queryForObject(eq("findStageWithJobsByIdentifier"), any())).thenReturn(first);

    Stage actual = stageDao.findStageWithIdentifier(new StageIdentifier("pipeline", 1, "stage", "1"));
    assertEquals(first, actual);

    Pipeline pipeline = new Pipeline("pipeline", "label", BuildCause.createManualForced(), first);
    pipeline.setCounter(1);
    stageDao.save(pipeline, second); //save stage 2.. This should invalidate the stage 1 because of the latest run state.

    stageDao.findStageWithIdentifier(new StageIdentifier("pipeline", 1, "stage", "1"));

    verify(mockTemplate, times(2)).queryForObject(eq("findStageWithJobsByIdentifier"), any());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:24,代码来源:StageSqlMapDaoIntegrationTest.java


示例18: findStageWithIdentifier_shouldRemoveFromTheCacheOnStageStatusChange

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void findStageWithIdentifier_shouldRemoveFromTheCacheOnStageStatusChange() {
    SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);

    Stage stage = StageMother.passedStageInstance("pipeline", "stage", "job", new Date());

    stageDao.setSqlMapClientTemplate(mockTemplate);
    when(mockTemplate.queryForObject(eq("findStageWithJobsByIdentifier"), any())).thenReturn(stage);

    Stage actual = stageDao.findStageWithIdentifier(new StageIdentifier("pipeline", 1, "stage", "1"));
    assertEquals(stage, actual);
    assertFalse("Make sure the cached object is cloned", stage == actual);
    updateResultInTransaction(actual, StageResult.Passed);
    stageDao.findStageWithIdentifier(new StageIdentifier("pipeline", 1, "stage", "1"));
    verify(mockTemplate, times(2)).queryForObject(eq("findStageWithJobsByIdentifier"), any());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:17,代码来源:StageSqlMapDaoIntegrationTest.java


示例19: findStageHistoryPage_shouldCacheStageHistoryPage

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void findStageHistoryPage_shouldCacheStageHistoryPage() {
    SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);

    Stage stage = StageMother.passedStageInstance("dev", "java", "pipeline-name");
    stage.setApprovedBy("admin");

    stageDao.setSqlMapClientTemplate(mockTemplate);
    when(mockTemplate.queryForObject(eq("getStageHistoryCount"), any())).thenReturn(20);
    when(mockTemplate.queryForObject(eq("findOffsetForStage"), any())).thenReturn(10);
    List<StageHistoryEntry> stageList = asList(new StageHistoryEntry(stage, 1, 10));
    when(mockTemplate.queryForList(eq("findStageHistoryPage"), any())).thenReturn(stageList);

    StageHistoryPage stageHistoryPage = stageDao.findStageHistoryPage(stage, 10);
    StageHistoryPage stageHistoryPageInNextQuery = stageDao.findStageHistoryPage(stage, 10);

    assertThat(stageHistoryPage.getStages(), is(stageList));
    assertThat(stageHistoryPage.getPagination(), is(Pagination.pageFor(10, 20, 10)));
    assertThat(stageHistoryPageInNextQuery.getStages(), is(stageList));
    assertThat(stageHistoryPageInNextQuery.getPagination(), is(Pagination.pageFor(10, 20, 10)));

    stageHistoryPage.getStages().get(0).setState(StageState.Failing);
    assertThat(stageHistoryPageInNextQuery.getStages().get(0).getState(), is(StageState.Passed));

    verify(mockTemplate, times(1)).queryForList(eq("findStageHistoryPage"), any());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:27,代码来源:StageSqlMapDaoIntegrationTest.java


示例20: isStageActive_shouldMakeIsActiveFalseWhenTheStageCompletes

import org.springframework.orm.ibatis.SqlMapClientTemplate; //导入依赖的package包/类
@Test
public void isStageActive_shouldMakeIsActiveFalseWhenTheStageCompletes() {
    SqlMapClientTemplate mockTemplate = mock(SqlMapClientTemplate.class);
    stageDao.setSqlMapClientTemplate(mockTemplate);

    when(mockTemplate.queryForObject(eq("isStageActive"), any())).thenReturn(1).thenReturn(0);

    boolean stageActive = stageDao.isStageActive(CaseInsensitiveString.str(mingleConfig.name()), CaseInsensitiveString.str(mingleConfig.getFirstStageConfig().name()));
    assertThat(stageActive, is(true));

    Stage stage = StageMother.completedFailedStageInstance(CaseInsensitiveString.str(mingleConfig.name()), CaseInsensitiveString.str(mingleConfig.getFirstStageConfig().name()), "job");
    stageDao.stageStatusChanged(stage);//The cached 'true' should now be removed

    assertThat(stageDao.isStageActive(CaseInsensitiveString.str(mingleConfig.name()), CaseInsensitiveString.str(mingleConfig.getFirstStageConfig().name())), is(false));
    verify(mockTemplate, times(2)).queryForObject(eq("isStageActive"), any());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:17,代码来源:StageSqlMapDaoIntegrationTest.java



注:本文中的org.springframework.orm.ibatis.SqlMapClientTemplate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GLFWvidmode类代码示例发布时间:2022-05-22
下一篇:
Java BusinessException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap