Search in sources :

Example 1 with StageStatusMessage

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()));
        }
    });
}
Also used : StageStatusMessage(com.thoughtworks.go.server.messaging.StageStatusMessage) TransactionSynchronizationAdapter(org.springframework.transaction.support.TransactionSynchronizationAdapter)

Example 2 with StageStatusMessage

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)));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) StageResultMessage(com.thoughtworks.go.server.messaging.StageResultMessage) StageStatusMessage(com.thoughtworks.go.server.messaging.StageStatusMessage) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 3 with StageStatusMessage

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);
}
Also used : StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) GoCache(com.thoughtworks.go.server.cache.GoCache) TransactionStatus(org.springframework.transaction.TransactionStatus) StageStatusMessage(com.thoughtworks.go.server.messaging.StageStatusMessage) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Test(org.junit.Test)

Aggregations

StageStatusMessage (com.thoughtworks.go.server.messaging.StageStatusMessage)3 Test (org.junit.Test)2 Pipeline (com.thoughtworks.go.domain.Pipeline)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)1 GoCache (com.thoughtworks.go.server.cache.GoCache)1 StageResultMessage (com.thoughtworks.go.server.messaging.StageResultMessage)1 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)1 TransactionSynchronizationAdapter (org.springframework.transaction.support.TransactionSynchronizationAdapter)1