use of com.thoughtworks.go.server.messaging.StageResultMessage 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.StageResultMessage in project gocd by gocd.
the class StageNotificationServiceIntegrationTest method shouldSendEmailWhenStageFixed.
@Test
public void shouldSendEmailWhenStageFixed() throws SQLException {
String jezMail = prepareOneMatchedUser(StageEvent.Fixed);
Pipeline pipeline = pipelineFixture.createdPipelineWithAllStagesCompleted(JobResult.Failed);
Stage ftStage = mockStageServiceWithStage(pipeline);
stageNotificationListener.onMessage(new StageResultMessage(ftStage.getIdentifier(), StageEvent.Fixed, Username.BLANK));
String subject = "Stage [" + ftStage.getIdentifier().stageLocator() + "]" + " is fixed";
assertThat(inMemoryEmailNotificationTopic.getSubject(jezMail), is(subject));
assertThat(inMemoryEmailNotificationTopic.getBody(jezMail), containsString("Sent by Go on behalf of jez"));
}
use of com.thoughtworks.go.server.messaging.StageResultMessage in project gocd by gocd.
the class StageNotificationServiceIntegrationTest method shouldSendEmailWithLink.
@Test
public void shouldSendEmailWithLink() throws SQLException {
String jezMail = prepareOneMatchedUser();
Pipeline pipeline = pipelineFixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
Stage ftStage = mockStageServiceWithStage(pipeline);
stageNotificationListener.onMessage(new StageResultMessage(ftStage.getIdentifier(), StageEvent.Passes, Username.BLANK));
String body = inMemoryEmailNotificationTopic.getBody(jezMail);
String ipAddress = SystemUtil.getFirstLocalNonLoopbackIpAddress();
int port = systemEnvironment.getServerPort();
assertThat(body, containsString(String.format("http://%s:%s/go/pipelines/%s/%s/%s/%s", ipAddress, port, pipelineFixture.pipelineName, pipeline.getCounter(), pipelineFixture.ftStage, ftStage.getCounter())));
}
use of com.thoughtworks.go.server.messaging.StageResultMessage in project gocd by gocd.
the class StageNotificationServiceIntegrationTest method shouldSendEmailWhenStageBreaks.
@Test
public void shouldSendEmailWhenStageBreaks() throws SQLException {
String jezMail = prepareOneMatchedUser(StageEvent.Breaks);
Pipeline pipeline = pipelineFixture.createdPipelineWithAllStagesPassed();
Stage ftStage = mockStageServiceWithStage(pipeline);
stageNotificationListener.onMessage(new StageResultMessage(ftStage.getIdentifier(), StageEvent.Breaks, Username.BLANK));
String subject = "Stage [" + ftStage.getIdentifier().stageLocator() + "]" + " is broken";
assertThat(inMemoryEmailNotificationTopic.getSubject(jezMail), is(subject));
assertThat(inMemoryEmailNotificationTopic.getBody(jezMail), containsString("Sent by Go on behalf of jez"));
}
use of com.thoughtworks.go.server.messaging.StageResultMessage in project gocd by gocd.
the class StageNotificationServiceIntegrationTest method shouldOnlySendEmailToMatchedUser.
@Test
public void shouldOnlySendEmailToMatchedUser() throws SQLException {
String jezMail = prepareOneMatchedUser();
String chrisMail = prepareOneNotMatchedUser();
Pipeline pipeline = pipelineFixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
Stage ftStage = mockStageServiceWithStage(pipeline);
stageNotificationListener.onMessage(new StageResultMessage(ftStage.getIdentifier(), StageEvent.Passes, Username.BLANK));
String subject = "Stage [" + ftStage.getIdentifier().stageLocator() + "]" + " passed";
assertThat(inMemoryEmailNotificationTopic.getSubject(jezMail), is(subject));
assertThat(inMemoryEmailNotificationTopic.getBody(jezMail), containsString("Sent by Go on behalf of jez"));
assertThat(inMemoryEmailNotificationTopic.emailCount(chrisMail), is(0));
}
Aggregations