Extended the assertions to verify a slash and a dot before a version; fixes gh-152
This commit is contained in:
@@ -36,11 +36,11 @@ import org.springframework.util.StringUtils;
|
||||
public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
|
||||
private static final Pattern SNAPSHOT_PATTERN = Pattern
|
||||
.compile("^.*\\.(BUILD-)?SNAPSHOT.*$");
|
||||
.compile("^.*[\\.|\\-](BUILD-)?SNAPSHOT.*$");
|
||||
|
||||
private static final String MILESTONE_REGEX = ".*\\.M[0-9]+";
|
||||
private static final String MILESTONE_REGEX = ".*[\\.|\\-]M[0-9]+";
|
||||
|
||||
private static final String RC_REGEX = "^.*\\.RC.*$";
|
||||
private static final String RC_REGEX = "^.*[\\.|\\-]RC.*$";
|
||||
|
||||
/**
|
||||
* Name of the project.
|
||||
|
||||
@@ -93,7 +93,7 @@ public class GradleUpdaterTests {
|
||||
thenThrownBy(() -> new GradleUpdater(properties).updateProjectFromBom(projectRoot,
|
||||
projects, new ProjectVersion("spring-cloud-contract", "1.0.0.RELEASE"),
|
||||
true)).hasMessageContaining(
|
||||
"matches the [ ^.*\\.(BUILD-)?SNAPSHOT.*$] pattern in line number [1]");
|
||||
"(BUILD-)?SNAPSHOT.*$] pattern in line number [1]");
|
||||
}
|
||||
|
||||
private File file(String relativePath) throws URISyntaxException {
|
||||
|
||||
@@ -442,6 +442,16 @@ public class ProjectVersionTests {
|
||||
.unacceptableVersionPatterns();
|
||||
then(rcPatterns).isNotEmpty();
|
||||
then(rcPatterns.get(0).pattern()).contains("SNAPSHOT");
|
||||
|
||||
List<Pattern> milestonePatternsWithASlash = projectVersion("1.0.0-M1")
|
||||
.unacceptableVersionPatterns();
|
||||
then(milestonePatterns).isNotEmpty();
|
||||
then(milestonePatterns.get(0).pattern()).contains("SNAPSHOT");
|
||||
|
||||
List<Pattern> rcPatternsWithASlash = projectVersion("1.0.0-RC1")
|
||||
.unacceptableVersionPatterns();
|
||||
then(rcPatterns).isNotEmpty();
|
||||
then(rcPatterns.get(0).pattern()).contains("SNAPSHOT");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -453,10 +463,17 @@ public class ProjectVersionTests {
|
||||
gaPatterns = projectVersion("1.0.0").unacceptableVersionPatterns();
|
||||
thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(gaPatterns);
|
||||
|
||||
gaPatterns = projectVersion("1.0.0-RELEASE").unacceptableVersionPatterns();
|
||||
thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(gaPatterns);
|
||||
|
||||
List<Pattern> srPatterns = projectVersion("1.0.0.SR1")
|
||||
.unacceptableVersionPatterns();
|
||||
thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(srPatterns);
|
||||
|
||||
List<Pattern> srPatternsWithASlash = projectVersion("1.0.0-SR1")
|
||||
.unacceptableVersionPatterns();
|
||||
thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(srPatterns);
|
||||
|
||||
List<Pattern> unknownTypeOfVersion = projectVersion("1.0.0.SOMETHING")
|
||||
.unacceptableVersionPatterns();
|
||||
thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(
|
||||
@@ -480,6 +497,17 @@ public class ProjectVersionTests {
|
||||
then(unknownTypeOfVersion.get(0).pattern()).contains("SNAPSHOT");
|
||||
then(unknownTypeOfVersion.get(1).pattern()).contains("M[0-9]");
|
||||
then(unknownTypeOfVersion.get(2).pattern()).contains("RC");
|
||||
|
||||
then(unknownTypeOfVersion.get(0).matcher("SomeName-BUILD-SNAPSHOT").matches())
|
||||
.isTrue();
|
||||
then(unknownTypeOfVersion.get(0).matcher("SomeName.BUILD-SNAPSHOT").matches())
|
||||
.isTrue();
|
||||
|
||||
then(unknownTypeOfVersion.get(1).matcher("SomeName-M3").matches()).isTrue();
|
||||
then(unknownTypeOfVersion.get(1).matcher("SomeName.M3").matches()).isTrue();
|
||||
|
||||
then(unknownTypeOfVersion.get(2).matcher("SomeName-RC3").matches()).isTrue();
|
||||
then(unknownTypeOfVersion.get(2).matcher("SomeName.RC3").matches()).isTrue();
|
||||
}
|
||||
|
||||
private ProjectVersion projectVersion(String version) {
|
||||
|
||||
Reference in New Issue
Block a user