From b162a5746caa95cecd8c429e682d5ee101b44ca3 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 17 Mar 2017 09:23:58 +0100 Subject: [PATCH] Not throwing exception when milestone not found fixes #14 --- .../cloud/release/internal/git/MilestoneCloser.java | 2 +- .../cloud/release/internal/git/MilestoneCloserTests.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/MilestoneCloser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/MilestoneCloser.java index b65dc6f7..13483eac 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/MilestoneCloser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/MilestoneCloser.java @@ -60,7 +60,7 @@ class MilestoneCloser { } } if (!matchingMilestone) { - throw new IllegalStateException("No matching milestone was found"); + log.warn("No matching milestone was found"); } } diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/MilestoneCloserTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/MilestoneCloserTests.java index 86677eb4..9d6b9014 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/MilestoneCloserTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/MilestoneCloserTests.java @@ -5,7 +5,9 @@ import java.net.URISyntaxException; import javax.json.Json; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.springframework.boot.test.rule.OutputCapture; import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.pom.ProjectVersion; @@ -13,6 +15,7 @@ import com.jcabi.github.Milestone; import com.jcabi.github.Repo; import com.jcabi.github.mock.MkGithub; +import static org.assertj.core.api.BDDAssertions.then; import static org.assertj.core.api.BDDAssertions.thenThrownBy; /** @@ -22,6 +25,7 @@ public class MilestoneCloserTests { MkGithub github; Repo repo; + @Rule public OutputCapture capture = new OutputCapture(); @Before public void setup() throws URISyntaxException, IOException { @@ -64,9 +68,8 @@ public class MilestoneCloserTests { }; repo.milestones().create("v0.2.0.BUILD-SNAPSHOT"); - thenThrownBy(() -> closer.closeMilestone(sleuthProject())) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("No matching milestone was found"); + closer.closeMilestone(sleuthProject()); + then(this.capture.toString()).contains("No matching milestone was found"); } @Test