use of com.thoughtworks.go.domain.activity.StageStatusCache in project gocd by gocd.
the class StageServiceTest method shouldNotSendStageStatusMessageAfterStageIsCancelledAndAnyOfTheJobIsAssigned.
@Test
public void shouldNotSendStageStatusMessageAfterStageIsCancelledAndAnyOfTheJobIsAssigned() throws SQLException {
StageStatusTopic topic = mock(StageStatusTopic.class);
final Stage cancelledStage = StageMother.cancelledStage("stage", "job");
cancelledStage.setIdentifier(new StageIdentifier("pipeline/1/stage/1"));
cancelledStage.getJobInstances().first().setAgentUuid("soem-agent");
final StageService service = new StageService(stageDao, jobInstanceService, topic, new StageStatusCache(stageDao), null, null, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, mock(GoCache.class));
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
service.cancelStage(cancelledStage, null);
}
});
verifyNoInteractions(topic);
}
use of com.thoughtworks.go.domain.activity.StageStatusCache in project gocd by gocd.
the class StageServiceTest method shouldFindLatestStageFromCache.
@Test
public void shouldFindLatestStageFromCache() throws SQLException {
Stage expectedStage = StageMother.custom("pipeline", "stage", null);
StageStatusCache cache = new StageStatusCache(stageDao);
cache.stageStatusChanged(expectedStage);
TransactionSynchronizationManager transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
StageService service = new StageService(stageDao, jobInstanceService, null, cache, null, null, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, goCache);
Stage actualStage = service.findLatestStage("pipeline", "stage");
assertThat(actualStage).isEqualTo(expectedStage);
}
use of com.thoughtworks.go.domain.activity.StageStatusCache in project gocd by gocd.
the class StageServiceTest method shouldSendStageStatusMessageAfterStageIsCancelled.
@Test
public void shouldSendStageStatusMessageAfterStageIsCancelled() throws SQLException {
StageStatusTopic topic = mock(StageStatusTopic.class);
final Stage cancelledStage = StageMother.cancelledStage("stage", "job");
cancelledStage.setIdentifier(new StageIdentifier("pipeline/1/stage/1"));
final StageService service = new StageService(stageDao, jobInstanceService, topic, new StageStatusCache(stageDao), null, null, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, mock(GoCache.class));
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
service.cancelStage(cancelledStage, null);
}
});
verify(topic).post(new StageStatusMessage(cancelledStage.getIdentifier(), StageState.Cancelled, StageResult.Cancelled, Username.ANONYMOUS));
verifyNoMoreInteractions(topic);
}
Aggregations