Search in sources :

Example 1 with StageRunFinder

use of com.thoughtworks.go.server.dao.sparql.StageRunFinder in project gocd by gocd.

the class StageServiceTest method shouldNotReturnAnythingWhenCurrentStageHasNotFailed.

@Test
public void shouldNotReturnAnythingWhenCurrentStageHasNotFailed() {
    TransactionSynchronizationManager transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    StageRunFinder runFinder = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), securityService, pipelineDao, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, goCache);
    Pipeline pipeline = pipeline(10.0);
    Pipeline pipelineThatLastPassed = pipeline(5.0);
    when(pipelineDao.findPipelineByNameAndCounter(PIPELINE_NAME, 3)).thenReturn(pipeline);
    when(pipelineDao.findEarlierPipelineThatPassedForStage(PIPELINE_NAME, STAGE_NAME, 10.0)).thenReturn(pipelineThatLastPassed);
    when(stageDao.findFailedStagesBetween(PIPELINE_NAME, STAGE_NAME, 5.0, 10.0)).thenReturn(asList(identifier(2, "2"), identifier(1, "1")));
    assertThat(runFinder.findRunForStage(new StageIdentifier(PIPELINE_NAME, 3, STAGE_NAME, "1")).isEmpty(), is(true));
}
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)

Example 2 with StageRunFinder

use of com.thoughtworks.go.server.dao.sparql.StageRunFinder in project gocd by gocd.

the class StageServiceTest method shouldNotReturnAnythingWhenNothingIsFailing.

@Test
public void shouldNotReturnAnythingWhenNothingIsFailing() {
    TransactionSynchronizationManager transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    StageRunFinder runFinder = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), securityService, pipelineDao, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, goCache);
    Pipeline pipeline = pipeline(10.0);
    Pipeline pipelineThatLastPassed = pipeline(5.0);
    when(pipelineDao.findPipelineByNameAndCounter(PIPELINE_NAME, 3)).thenReturn(pipeline);
    when(pipelineDao.findEarlierPipelineThatPassedForStage(PIPELINE_NAME, STAGE_NAME, 10.0)).thenReturn(pipelineThatLastPassed);
    when(stageDao.findFailedStagesBetween(PIPELINE_NAME, STAGE_NAME, 5.0, 10.0)).thenReturn(new ArrayList<>());
    assertThat(runFinder.findRunForStage(new StageIdentifier(PIPELINE_NAME, 3, STAGE_NAME, "1")).isEmpty(), is(true));
}
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)

Example 3 with StageRunFinder

use of com.thoughtworks.go.server.dao.sparql.StageRunFinder 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)

Example 4 with StageRunFinder

use of com.thoughtworks.go.server.dao.sparql.StageRunFinder in project gocd by gocd.

the class StageServiceTest method canGetFailureRunForThreeStages.

@Test
public void canGetFailureRunForThreeStages() {
    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);
    Pipeline pipelineThatLastPassed = pipeline(5.0);
    when(pipelineDao.findPipelineByNameAndCounter(PIPELINE_NAME, 3)).thenReturn(pipeline);
    when(pipelineDao.findEarlierPipelineThatPassedForStage(PIPELINE_NAME, STAGE_NAME, 10.0)).thenReturn(pipelineThatLastPassed);
    when(stageDao.findFailedStagesBetween(PIPELINE_NAME, STAGE_NAME, 5.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

StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)4 StageRunFinder (com.thoughtworks.go.server.dao.sparql.StageRunFinder)4 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)4 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)4 TransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TransactionSynchronizationManager)4 Test (org.junit.Test)4