DeploymentCompleteSpec { public String getRequestorString() { if (wasSuccessful) return String.format("Successful deployment of %s to %s on %s", projectId, environmentId, url); return String.format("Deployment of %s to %s on %s", projectId, environmentId, url); } DeploymentCompleteSpec(@NotNull String url, @NotNull Environment environment); private  DeploymentCompleteSpec(@NotNull String url, @NotNull String projectId, @Nullable String environmentId,
                           @Nullable Boolean wasSuccessful, @Nullable String deploymentId, @Nullable String version,
                           @Nullable String releaseId); String getRequestorString(); @Override String toString();  }
@Test public void when_successful_returns_success_message() throws Exception { Environment environment = new Environment("theenv", new OctopusDate(2016,4,9), new OctopusDate(2016,4,9), "the-release-id", "the-deployment-id", "the-version", "the-project-id"); DeploymentCompleteSpec sut = new DeploymentCompleteSpec("theurl", environment); Assert.assertEquals(sut.getRequestorString(), "Successful deployment of the-project-id to theenv on theurl"); }
@Test public void when_unsuccessful_returns_non_successful_deployment_message() throws Exception { Environment environment = new Environment("theenv", new OctopusDate(2016,4,9), new OctopusDate(2016,4,8), "the-release-id", "the-deployment-id", "the-version", "the-project-id"); DeploymentCompleteSpec sut = new DeploymentCompleteSpec("theurl", environment); Assert.assertEquals(sut.getRequestorString(), "Deployment of the-project-id to theenv on theurl"); }