diff --git a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/Environment.java b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/Environment.java index 5419d95..2de588d 100644 --- a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/Environment.java +++ b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/Environment.java @@ -67,12 +67,12 @@ public String toString() { return String.format("%s;%s;%s;%s;%s;%s;%s", environmentId, latestDeployment, latestSuccessfulDeployment, releaseId, deploymentId, version, projectId); } - public static Environment Parse(String toStringRepresentation) throws NeedToDeleteAndRecreateTrigger { + public static Environment Parse(String toStringRepresentation) throws NeedToDeleteAndRecreateTriggerException { final Integer DONT_REMOVE_EMPTY_VALUES = -1; final String[] split = toStringRepresentation.split(";", DONT_REMOVE_EMPTY_VALUES); if (split.length < 4) - throw new NeedToDeleteAndRecreateTrigger(); + throw new NeedToDeleteAndRecreateTriggerException(); final String environmentId = split[0]; final OctopusDate latestDeployment = OctopusDate.Parse(split[1]); diff --git a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/Environments.java b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/Environments.java index 5e75996..dd6fe6b 100644 --- a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/Environments.java +++ b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/Environments.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.DeploymentComplete; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import com.mjrichardson.teamCity.buildTriggers.NullOctopusDate; import com.mjrichardson.teamCity.buildTriggers.OctopusDate; import jetbrains.buildServer.util.StringUtil; @@ -26,7 +26,7 @@ public Environments(Environment environment) { addOrUpdate(environment); } - public static Environments Parse(String oldStoredData) throws ParseException, NeedToDeleteAndRecreateTrigger { + public static Environments Parse(String oldStoredData) throws ParseException, NeedToDeleteAndRecreateTriggerException { Environments result = new Environments(); if (!StringUtil.isEmptyOrSpaces(oldStoredData)) { diff --git a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/Machine.java b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/Machine.java index d8d43bb..5dd812b 100644 --- a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/Machine.java +++ b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/Machine.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.MachineAdded; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -48,7 +48,7 @@ public static Machine Parse(Map item) { return new Machine(id, name, environmentIds.toArray(new String[0]), roleIds.toArray(new String[0])); } - public static Machine Parse(String pair) throws NeedToDeleteAndRecreateTrigger { + public static Machine Parse(String pair) throws NeedToDeleteAndRecreateTriggerException { if (pair == null || pair.equals("")) { return new NullMachine(); } @@ -56,7 +56,7 @@ public static Machine Parse(String pair) throws NeedToDeleteAndRecreateTrigger { final String[] split = pair.split(";", DONT_REMOVE_EMPTY_VALUES); if (split.length < 4) - throw new NeedToDeleteAndRecreateTrigger(); + throw new NeedToDeleteAndRecreateTriggerException(); final String id = split[0]; final String name = split[1]; diff --git a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/Machines.java b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/Machines.java index b63f118..e438282 100644 --- a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/Machines.java +++ b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/Machines.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.MachineAdded; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import jetbrains.buildServer.util.StringUtil; import java.util.ArrayList; @@ -13,7 +13,7 @@ public Machines() { this.statusMap = new ArrayList<>(); } - public static Machines Parse(String oldStoredData) throws NeedToDeleteAndRecreateTrigger { + public static Machines Parse(String oldStoredData) throws NeedToDeleteAndRecreateTriggerException { Machines result = new Machines(); if (!StringUtil.isEmptyOrSpaces(oldStoredData)) { diff --git a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/NeedToDeleteAndRecreateTrigger.java b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/NeedToDeleteAndRecreateTriggerException.java similarity index 65% rename from octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/NeedToDeleteAndRecreateTrigger.java rename to octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/NeedToDeleteAndRecreateTriggerException.java index 4431ad1..62af312 100644 --- a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/NeedToDeleteAndRecreateTrigger.java +++ b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/NeedToDeleteAndRecreateTriggerException.java @@ -1,7 +1,7 @@ package com.mjrichardson.teamCity.buildTriggers; -public class NeedToDeleteAndRecreateTrigger extends Exception { - public NeedToDeleteAndRecreateTrigger() { +public class NeedToDeleteAndRecreateTriggerException extends Exception { + public NeedToDeleteAndRecreateTriggerException() { super("The way state is stored has been changed between your current version and the 2.x series.\n" + "Please delete the trigger in TeamCity and re-add it."); } diff --git a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/Release.java b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/Release.java index 65e53a0..9b4ab65 100644 --- a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/Release.java +++ b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/Release.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.ReleaseCreated; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import com.mjrichardson.teamCity.buildTriggers.OctopusDate; import org.jetbrains.annotations.NotNull; @@ -37,7 +37,7 @@ public static Release Parse(Map item) { return new Release(releaseId, assembledDate, version, projectId); } - public static Release Parse(String pair) throws NeedToDeleteAndRecreateTrigger { + public static Release Parse(String pair) throws NeedToDeleteAndRecreateTriggerException { if (pair == null || pair.equals("")) { return new NullRelease(); } @@ -48,7 +48,7 @@ public static Release Parse(String pair) throws NeedToDeleteAndRecreateTrigger { final String version = split[2]; if (split.length < 4) - throw new NeedToDeleteAndRecreateTrigger(); + throw new NeedToDeleteAndRecreateTriggerException(); final String projectId = split[3]; diff --git a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/Releases.java b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/Releases.java index cab3ca0..9935880 100644 --- a/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/Releases.java +++ b/octopus-build-trigger-server/src/main/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/Releases.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.ReleaseCreated; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import jetbrains.buildServer.util.StringUtil; import java.util.ArrayList; @@ -13,7 +13,7 @@ public Releases() { this.statusMap = new ArrayList<>(); } - public static Releases Parse(String data) throws NeedToDeleteAndRecreateTrigger { + public static Releases Parse(String data) throws NeedToDeleteAndRecreateTriggerException { Releases releases = new Releases(); if (!StringUtil.isEmptyOrSpaces(data)) { diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/DeploymentsProviderImplTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/DeploymentsProviderImplTest.java index 90b23e6..4d6efd5 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/DeploymentsProviderImplTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/DeploymentsProviderImplTest.java @@ -316,7 +316,7 @@ public void determine_outcome_of_fallback_handles_fewer_responses() { Assert.assertEquals(result, AnalyticsTracker.EventAction.FallBackToDeploymentsApiProducedFewerEnvironments); } - public void determine_outcome_of_fallback_handles_identical_responses() throws ParseException, NeedToDeleteAndRecreateTrigger { + public void determine_outcome_of_fallback_handles_identical_responses() throws ParseException, NeedToDeleteAndRecreateTriggerException { HttpContentProviderFactory contentProviderFactory = new FakeContentProviderFactory(octopusUrl, octopusApiKey); FakeAnalyticsTracker fakeAnalyticsTracker = new FakeAnalyticsTracker(); DeploymentsProviderImpl deploymentsProviderImpl = new DeploymentsProviderImpl(contentProviderFactory, fakeAnalyticsTracker); @@ -330,7 +330,7 @@ public void determine_outcome_of_fallback_handles_identical_responses() throws P Assert.assertEquals(result, AnalyticsTracker.EventAction.FallBackToDeploymentsApiProducedSameResults); } - public void determine_outcome_of_fallback_handles_different_environments() throws ParseException, NeedToDeleteAndRecreateTrigger { + public void determine_outcome_of_fallback_handles_different_environments() throws ParseException, NeedToDeleteAndRecreateTriggerException { HttpContentProviderFactory contentProviderFactory = new FakeContentProviderFactory(octopusUrl, octopusApiKey); FakeAnalyticsTracker fakeAnalyticsTracker = new FakeAnalyticsTracker(); DeploymentsProviderImpl deploymentsProviderImpl = new DeploymentsProviderImpl(contentProviderFactory, fakeAnalyticsTracker); @@ -345,7 +345,7 @@ public void determine_outcome_of_fallback_handles_different_environments() throw Assert.assertEquals(result, AnalyticsTracker.EventAction.FallBackToDeploymentsApiProducedDifferentEnvironments); } - public void determine_outcome_of_fallback_handles_response_with_newer_latest_deployment_date() throws ParseException, NeedToDeleteAndRecreateTrigger { + public void determine_outcome_of_fallback_handles_response_with_newer_latest_deployment_date() throws ParseException, NeedToDeleteAndRecreateTriggerException { HttpContentProviderFactory contentProviderFactory = new FakeContentProviderFactory(octopusUrl, octopusApiKey); FakeAnalyticsTracker fakeAnalyticsTracker = new FakeAnalyticsTracker(); DeploymentsProviderImpl deploymentsProviderImpl = new DeploymentsProviderImpl(contentProviderFactory, fakeAnalyticsTracker); @@ -360,7 +360,7 @@ public void determine_outcome_of_fallback_handles_response_with_newer_latest_dep Assert.assertEquals(result, AnalyticsTracker.EventAction.FallBackToDeploymentsApiProducedBetterInformation); } - public void determine_outcome_of_fallback_handles_response_with_newer_successful_latest_deployment_date() throws ParseException, NeedToDeleteAndRecreateTrigger { + public void determine_outcome_of_fallback_handles_response_with_newer_successful_latest_deployment_date() throws ParseException, NeedToDeleteAndRecreateTriggerException { HttpContentProviderFactory contentProviderFactory = new FakeContentProviderFactory(octopusUrl, octopusApiKey); FakeAnalyticsTracker fakeAnalyticsTracker = new FakeAnalyticsTracker(); DeploymentsProviderImpl deploymentsProviderImpl = new DeploymentsProviderImpl(contentProviderFactory, fakeAnalyticsTracker); @@ -375,7 +375,7 @@ public void determine_outcome_of_fallback_handles_response_with_newer_successful Assert.assertEquals(result, AnalyticsTracker.EventAction.FallBackToDeploymentsApiProducedBetterInformation); } - public void determine_outcome_of_fallback_handles_response_with_older_latest_deployment_date() throws ParseException, NeedToDeleteAndRecreateTrigger { + public void determine_outcome_of_fallback_handles_response_with_older_latest_deployment_date() throws ParseException, NeedToDeleteAndRecreateTriggerException { HttpContentProviderFactory contentProviderFactory = new FakeContentProviderFactory(octopusUrl, octopusApiKey); FakeAnalyticsTracker fakeAnalyticsTracker = new FakeAnalyticsTracker(); DeploymentsProviderImpl deploymentsProviderImpl = new DeploymentsProviderImpl(contentProviderFactory, fakeAnalyticsTracker); diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/EnvironmentTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/EnvironmentTest.java index e099302..382d3d2 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/EnvironmentTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/EnvironmentTest.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.DeploymentComplete; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import com.mjrichardson.teamCity.buildTriggers.NullOctopusDate; import com.mjrichardson.teamCity.buildTriggers.OctopusDate; import org.testng.Assert; @@ -115,13 +115,13 @@ public void parse_map_returns_deployment_with_null_latest_successful_deployment_ Assert.assertEquals(sut.projectId, "Project-8"); } - @Test(expectedExceptions = NeedToDeleteAndRecreateTrigger.class) - public void parse_string_throws_exception_if_format_is_different() throws NeedToDeleteAndRecreateTrigger { + @Test(expectedExceptions = NeedToDeleteAndRecreateTriggerException.class) + public void parse_string_throws_exception_if_format_is_different() throws NeedToDeleteAndRecreateTriggerException { //the format changed (we added another 4 fields (releaseId, deploymentId, version, projectId)), so it needs to be deleted and recreated Environment.Parse("env-id;2015-12-09T14:10:11.000+00:00;2015-12-12T09:04:03.000+00:00"); } - public void parse_string_populates_object_correctly() throws NeedToDeleteAndRecreateTrigger { + public void parse_string_populates_object_correctly() throws NeedToDeleteAndRecreateTriggerException { Environment sut = Environment.Parse("Environment-1;2016-2-26T17:58:13.537+00:00;2016-2-26T17:58:13.537+00:00;Release-1;Deployment-1;1.0.1;Project-8"); Assert.assertEquals(sut.environmentId, "Environment-1"); Assert.assertEquals(sut.latestDeployment, new OctopusDate(2016, 2, 26, 17, 58, 13, 537)); diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/EnvironmentsTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/EnvironmentsTest.java index f41f7ee..dab5ac9 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/EnvironmentsTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/DeploymentComplete/EnvironmentsTest.java @@ -143,7 +143,7 @@ public void get_changed_deployment_throws_exception_when_none_changed() throws E newEnvironments.getChangedDeployment(oldEnvironments); } - public void to_array_converts_deployments_to_array_successfully() throws ParseException, NeedToDeleteAndRecreateTrigger { + public void to_array_converts_deployments_to_array_successfully() throws ParseException, NeedToDeleteAndRecreateTriggerException { final String data = "Environments-1;2016-01-19T14:00:00.000+00:00;2016-01-19T00:00:00.000+00:00;the-release-id;the-deployment-id;the-version;the-project-id|Environments-21;2016-01-20T14:00:00.000+00:00;2016-01-20T14:00:00.000+00:00;the-release-id;the-deployment-id;the-version;the-project-id"; Environments environments = Environments.Parse(data); Environment[] array = environments.toArray(); diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/MachineTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/MachineTest.java index f531358..d04852a 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/MachineTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/MachineTest.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.MachineAdded; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import org.testng.Assert; import org.testng.annotations.Test; @@ -10,40 +10,40 @@ @Test public class MachineTest { - public void can_parse_empty_string_to_null_machine() throws NeedToDeleteAndRecreateTrigger { + public void can_parse_empty_string_to_null_machine() throws NeedToDeleteAndRecreateTriggerException { Machine sut = Machine.Parse(""); Assert.assertEquals(sut.getClass(), NullMachine.class); } - public void can_parse_null_string_to_null_machine() throws NeedToDeleteAndRecreateTrigger { + public void can_parse_null_string_to_null_machine() throws NeedToDeleteAndRecreateTriggerException { Machine sut = Machine.Parse((String)null); Assert.assertEquals(sut.getClass(), NullMachine.class); } - public void can_parse_valid_string_to_machine() throws NeedToDeleteAndRecreateTrigger { + public void can_parse_valid_string_to_machine() throws NeedToDeleteAndRecreateTriggerException { Machine sut = Machine.Parse("Machines-91;MachineNinetyOne;env-1,env-2;role-one,role-two"); Assert.assertEquals(sut.id, "Machines-91"); Assert.assertEquals(sut.name, "MachineNinetyOne"); } - public void to_string_formats_correctly() throws NeedToDeleteAndRecreateTrigger { + public void to_string_formats_correctly() throws NeedToDeleteAndRecreateTriggerException { Machine sut = Machine.Parse("Machines-91;MachineNinetyOne;env-1,env-2;role-one,role-two"); Assert.assertEquals(sut.toString(), "Machines-91;MachineNinetyOne;env-1,env-2;role-one,role-two"); } - public void compare_returns_1_when_passed_machine_has_lower_id() throws NeedToDeleteAndRecreateTrigger { + public void compare_returns_1_when_passed_machine_has_lower_id() throws NeedToDeleteAndRecreateTriggerException { Machine machine1 = Machine.Parse("Machines-1;MachineOne;env-1,env-2;role-one,role-two"); Machine machine2 = Machine.Parse("Machines-2;MachineTwo;env-1,env-2;role-one,role-two"); Assert.assertEquals(machine2.compareTo(machine1), 1); } - public void compare_returns_0_when_passed_machine_has_same_id() throws NeedToDeleteAndRecreateTrigger { + public void compare_returns_0_when_passed_machine_has_same_id() throws NeedToDeleteAndRecreateTriggerException { Machine machine1 = Machine.Parse("Machines-1;MachineOne;env-1,env-2;role-one,role-two"); Machine machine2 = Machine.Parse("Machines-1;MachineOneAgain;env-1,env-2;role-one,role-two"); Assert.assertEquals(machine1.compareTo(machine2), 0); } - public void compare_returns_minus_1_when_passed_machine_has_higher_id() throws NeedToDeleteAndRecreateTrigger { + public void compare_returns_minus_1_when_passed_machine_has_higher_id() throws NeedToDeleteAndRecreateTriggerException { Machine machine1 = Machine.Parse("Machines-3;MachineOne;env-1,env-2;role-one,role-two"); Machine machine2 = Machine.Parse("Machines-21;MachineTwo;env-1,env-2;role-one,role-two"); Assert.assertEquals(machine1.compareTo(machine2), -1); diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/MachinesTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/MachinesTest.java index 68ffa1c..fae2886 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/MachinesTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/MachinesTest.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.MachineAdded; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import org.testng.Assert; import org.testng.annotations.Test; @@ -78,7 +78,7 @@ public void get_next_machine_returns_next_machine() throws Exception { Assert.assertEquals(machine, firstNewMachine); } - public void to_array_converts_machines_to_array_successfully() throws NeedToDeleteAndRecreateTrigger { + public void to_array_converts_machines_to_array_successfully() throws NeedToDeleteAndRecreateTriggerException { final Machine oldMachine = new Machine("machine-2", "MachineTwo", new String[] { "env-id" }, new String[]{ "role-name" }); final Machine newMachine = new Machine("machine-3", "MachineThree", new String[] { "env-id" }, new String[]{ "role-name" }); Machines machines = Machines.Parse(String.format("%s|%s", oldMachine.toString(), newMachine.toString())); diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/NullMachineTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/NullMachineTest.java index 723100c..3ca23b4 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/NullMachineTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/MachineAdded/NullMachineTest.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.MachineAdded; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import org.testng.Assert; import org.testng.annotations.Test; @@ -12,7 +12,7 @@ public void null_machine_sets_fields_to_empty() { Assert.assertEquals(sut.name, ""); } - public void can_parse_to_null_machine() throws NeedToDeleteAndRecreateTrigger { + public void can_parse_to_null_machine() throws NeedToDeleteAndRecreateTriggerException { Machine sut = Machine.Parse(new NullMachine().toString()); Assert.assertEquals(sut.getClass(), NullMachine.class); } diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/NullReleaseTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/NullReleaseTest.java index 42b177c..1980b53 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/NullReleaseTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/NullReleaseTest.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.ReleaseCreated; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import com.mjrichardson.teamCity.buildTriggers.NullOctopusDate; import org.testng.Assert; import org.testng.annotations.Test; @@ -14,7 +14,7 @@ public void null_release_sets_fields_to_empty() { Assert.assertEquals(sut.version, ""); } - public void can_parse_to_null_release() throws NeedToDeleteAndRecreateTrigger { + public void can_parse_to_null_release() throws NeedToDeleteAndRecreateTriggerException { Release sut = Release.Parse(new NullRelease().toString()); Assert.assertEquals(sut.getClass(), NullRelease.class); } diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/ReleaseTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/ReleaseTest.java index 16a8e6c..bd129a2 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/ReleaseTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/ReleaseTest.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.ReleaseCreated; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import com.mjrichardson.teamCity.buildTriggers.OctopusDate; import org.testng.Assert; import org.testng.annotations.Test; @@ -9,17 +9,17 @@ @Test public class ReleaseTest { - public void can_parse_empty_string_to_null_release() throws NeedToDeleteAndRecreateTrigger { + public void can_parse_empty_string_to_null_release() throws NeedToDeleteAndRecreateTriggerException { Release sut = Release.Parse(""); Assert.assertEquals(sut.getClass(), NullRelease.class); } - public void can_parse_null_string_to_null_release() throws NeedToDeleteAndRecreateTrigger { + public void can_parse_null_string_to_null_release() throws NeedToDeleteAndRecreateTriggerException { Release sut = Release.Parse((String)null); Assert.assertEquals(sut.getClass(), NullRelease.class); } - public void can_parse_valid_string_to_release() throws NeedToDeleteAndRecreateTrigger { + public void can_parse_valid_string_to_release() throws NeedToDeleteAndRecreateTriggerException { Release sut = Release.Parse("Releases-91;2016-01-21T13:32:59.991+00:00;1.0.0;Projects-1"); Assert.assertEquals(sut.releaseId, "Releases-91"); Assert.assertEquals(sut.version, "1.0.0"); @@ -27,30 +27,30 @@ public void can_parse_valid_string_to_release() throws NeedToDeleteAndRecreateTr Assert.assertEquals(sut.assembledDate, new OctopusDate(2016, 1, 21, 13, 32, 59, 991)); } - public void to_string_formats_correctly() throws NeedToDeleteAndRecreateTrigger { + public void to_string_formats_correctly() throws NeedToDeleteAndRecreateTriggerException { Release sut = Release.Parse("Releases-91;2016-01-21T13:32:59.991+00:00;1.0.0;Projects-1"); Assert.assertEquals(sut.toString(), "Releases-91;2016-01-21T13:32:59.991+00:00;1.0.0;Projects-1"); } - @Test(expectedExceptions = NeedToDeleteAndRecreateTrigger.class) - public void parse_throws_exception_if_format_is_different() throws NeedToDeleteAndRecreateTrigger { + @Test(expectedExceptions = NeedToDeleteAndRecreateTriggerException.class) + public void parse_throws_exception_if_format_is_different() throws NeedToDeleteAndRecreateTriggerException { //the format changed (we added another field, projectId), so it needs to be deleted and recreated Release.Parse("Releases-91;2016-01-21T13:32:59.991+00:00;1.0.0"); } - public void compare_returns_1_when_passed_release_has_newer_assembled_date() throws NeedToDeleteAndRecreateTrigger { + public void compare_returns_1_when_passed_release_has_newer_assembled_date() throws NeedToDeleteAndRecreateTriggerException { Release release1 = Release.Parse("Releases-1;2016-01-21T13:32:59.991+00:00;1.0.0;Projects-1"); Release release2 = Release.Parse("Releases-2;2016-01-22T13:32:59.991+00:00;1.0.0;Projects-1"); Assert.assertEquals(release1.compareTo(release2), 1); } - public void compare_returns_0_when_passed_release_has_same_assembled_date() throws NeedToDeleteAndRecreateTrigger { + public void compare_returns_0_when_passed_release_has_same_assembled_date() throws NeedToDeleteAndRecreateTriggerException { Release release1 = Release.Parse("Releases-1;2016-01-21T13:32:59.991+00:00;1.0.0;Projects-1"); Release release2 = Release.Parse("Releases-2;2016-01-21T13:32:59.991+00:00;1.0.0;Projects-1"); Assert.assertEquals(release1.compareTo(release2), 0); } - public void compare_returns_minus_1_when_passed_release_has_older_assembled_date() throws NeedToDeleteAndRecreateTrigger { + public void compare_returns_minus_1_when_passed_release_has_older_assembled_date() throws NeedToDeleteAndRecreateTriggerException { Release release1 = Release.Parse("Releases-1;2016-01-21T13:32:59.991+00:00;1.0.0;Projects-1"); Release release2 = Release.Parse("Releases-2;2016-01-20T13:32:59.991+00:00;1.0.0;Projects-1"); Assert.assertEquals(release1.compareTo(release2), -1); diff --git a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/ReleasesTest.java b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/ReleasesTest.java index 941a73a..6e748c3 100644 --- a/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/ReleasesTest.java +++ b/octopus-build-trigger-server/src/test/java/com/mjrichardson/teamCity/buildTriggers/ReleaseCreated/ReleasesTest.java @@ -1,6 +1,6 @@ package com.mjrichardson.teamCity.buildTriggers.ReleaseCreated; -import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTrigger; +import com.mjrichardson.teamCity.buildTriggers.NeedToDeleteAndRecreateTriggerException; import com.mjrichardson.teamCity.buildTriggers.OctopusDate; import org.testng.Assert; import org.testng.annotations.Test; @@ -116,7 +116,7 @@ public void get_latest_release_returns_null_release_if_no_releases() throws Exce Assert.assertEquals(release.getClass(), NullRelease.class); } - public void to_array_converts_releases_to_array_successfully() throws NeedToDeleteAndRecreateTrigger { + public void to_array_converts_releases_to_array_successfully() throws NeedToDeleteAndRecreateTriggerException { final Release oldRelease = new Release("release-2", new OctopusDate(2016, 3, 1), "1.0.0", "the-project-id"); final Release newRelease = new Release("release-3", new OctopusDate(2016, 3, 3), "1.2.0", "the-project-id"); Releases releases = Releases.Parse(String.format("%s|%s", oldRelease.toString(), newRelease.toString()));