use of com.thoughtworks.go.server.messaging.StageStatusMessage in project gocd by gocd.
the class StageService method cancelStage.
public synchronized void cancelStage(final Stage stage) {
cancel(stage);
notifyStageStatusChangeListeners(stage);
transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
stageStatusTopic.post(new StageStatusMessage(stage.getIdentifier(), stage.stageState(), stage.getResult(), UserHelper.getUserName()));
}
});
}
use of com.thoughtworks.go.server.messaging.StageStatusMessage in project gocd by gocd.
the class StageResultCacheTest method shouldSendStageResultMessageWhenStageComplete.
@Test
public void shouldSendStageResultMessageWhenStageComplete() {
Pipeline pipeline = pipelineFixture.createdPipelineWithAllStagesPassed();
StageResultTopicStub stub = new StageResultTopicStub(messagingService);
StageResultCache cache = new StageResultCache(stageDao, stub, stageStatusTopic);
StageIdentifier identifier = pipeline.getFirstStage().getIdentifier();
cache.onMessage(new StageStatusMessage(identifier, StageState.Passed, StageResult.Passed));
assertThat(stub.message, is(new StageResultMessage(identifier, StageEvent.Passes, Username.BLANK)));
cache.onMessage(new StageStatusMessage(identifier, StageState.Failed, StageResult.Failed));
assertThat(stub.message, is(new StageResultMessage(identifier, StageEvent.Breaks, Username.BLANK)));
}
use of com.thoughtworks.go.server.messaging.StageStatusMessage 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() {
public void doInTransactionWithoutResult(TransactionStatus status) {
service.cancelStage(cancelledStage);
}
});
verify(topic).post(new StageStatusMessage(cancelledStage.getIdentifier(), StageState.Cancelled, StageResult.Cancelled, Username.ANONYMOUS));
verifyNoMoreInteractions(topic);
}
Aggregations