Search in sources :

Example 1 with StageResultMessage

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)));
}
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 2 with StageResultMessage

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"));
}
Also used : StageResultMessage(com.thoughtworks.go.server.messaging.StageResultMessage) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 3 with StageResultMessage

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())));
}
Also used : StageResultMessage(com.thoughtworks.go.server.messaging.StageResultMessage) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 4 with StageResultMessage

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"));
}
Also used : StageResultMessage(com.thoughtworks.go.server.messaging.StageResultMessage) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 5 with StageResultMessage

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));
}
Also used : StageResultMessage(com.thoughtworks.go.server.messaging.StageResultMessage) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Aggregations

StageResultMessage (com.thoughtworks.go.server.messaging.StageResultMessage)7 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 Test (org.junit.jupiter.api.Test)6 Pipeline (com.thoughtworks.go.domain.Pipeline)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 Username (com.thoughtworks.go.server.domain.Username)1 StageStatusMessage (com.thoughtworks.go.server.messaging.StageStatusMessage)1 Test (org.junit.Test)1