Search in sources :

Example 21 with TransactionSynchronizationManager

use of com.thoughtworks.go.server.transaction.TransactionSynchronizationManager in project gocd by gocd.

the class StageServiceTest method canGetFailureRunForThreeStagesAtStartOfPipeline.

@Test
public void canGetFailureRunForThreeStagesAtStartOfPipeline() {
    TransactionSynchronizationManager transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    StageRunFinder runFinder = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), securityService, pipelineDao, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, goCache);
    List<StageIdentifier> expectedStages = new ArrayList<>();
    expectedStages.add(new StageIdentifier(PIPELINE_NAME, 3, STAGE_NAME, "1"));
    expectedStages.add(new StageIdentifier(PIPELINE_NAME, 2, STAGE_NAME, "2"));
    expectedStages.add(new StageIdentifier(PIPELINE_NAME, 1, STAGE_NAME, "1"));
    Pipeline pipeline = pipeline(10.0);
    when(pipelineDao.findPipelineByNameAndCounter(PIPELINE_NAME, 3)).thenReturn(pipeline);
    when(pipelineDao.findEarlierPipelineThatPassedForStage(PIPELINE_NAME, STAGE_NAME, 10.0)).thenReturn(null);
    when(stageDao.findFailedStagesBetween(PIPELINE_NAME, STAGE_NAME, 0.0, 10.0)).thenReturn(asList(identifier(3, "1"), identifier(2, "2"), identifier(1, "1")));
    assertEquals(expectedStages, runFinder.findRunForStage(new StageIdentifier(PIPELINE_NAME, 3, STAGE_NAME, "1")));
}
Also used : StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) TransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TransactionSynchronizationManager) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) StageRunFinder(com.thoughtworks.go.server.dao.sparql.StageRunFinder) Test(org.junit.Test)

Aggregations

TransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TransactionSynchronizationManager)21 Test (org.junit.Test)15 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)13 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)5 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)5 StageRunFinder (com.thoughtworks.go.server.dao.sparql.StageRunFinder)4 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)4 Before (org.junit.Before)4 TransactionStatus (org.springframework.transaction.TransactionStatus)4 TransactionTemplate (com.thoughtworks.go.server.transaction.TransactionTemplate)3 SessionFactory (org.hibernate.SessionFactory)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2 GitCommand (com.thoughtworks.go.domain.materials.git.GitCommand)2 MaterialRepository (com.thoughtworks.go.server.persistence.MaterialRepository)2 StubGoCache (com.thoughtworks.go.server.service.StubGoCache)2 File (java.io.File)2 Session (org.hibernate.classic.Session)2 SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)2 TransactionSynchronization (org.springframework.transaction.support.TransactionSynchronization)2 TransactionSynchronizationAdapter (org.springframework.transaction.support.TransactionSynchronizationAdapter)2