diff --git a/release-tools/src/main/java/org/springframework/data/release/cli/TrainIterationConverter.java b/release-tools/src/main/java/org/springframework/data/release/cli/TrainIterationConverter.java index d90d10a..2b2cfac 100644 --- a/release-tools/src/main/java/org/springframework/data/release/cli/TrainIterationConverter.java +++ b/release-tools/src/main/java/org/springframework/data/release/cli/TrainIterationConverter.java @@ -32,7 +32,7 @@ import org.springframework.stereotype.Component; @Component public class TrainIterationConverter implements Converter { - /* + /* * (non-Javadoc) * @see org.springframework.shell.core.Converter#supports(java.lang.Class, java.lang.String) */ @@ -41,7 +41,7 @@ public class TrainIterationConverter implements Converter { return TrainIteration.class.equals(type); } - /* + /* * (non-Javadoc) * @see org.springframework.shell.core.Converter#convertFromText(java.lang.String, java.lang.Class, java.lang.String) */ @@ -55,12 +55,11 @@ public class TrainIterationConverter implements Converter { } Train train = ReleaseTrains.getTrainByName(parts[0].trim()); - Iteration iteration = train.getIteration(parts[1].trim()); - return new TrainIteration(train, iteration); + return train.getIteration(parts[1].trim()); } - /* + /* * (non-Javadoc) * @see org.springframework.shell.core.Converter#getAllPossibleValues(java.util.List, java.lang.Class, java.lang.String, java.lang.String, org.springframework.shell.core.MethodTarget) */ @@ -71,7 +70,10 @@ public class TrainIterationConverter implements Converter { for (Train train : ReleaseTrains.TRAINS) { for (Iteration iteration : train.getIterations()) { - completions.add(new Completion(new TrainIteration(train, iteration).toString())); + + TrainIteration trainIteration = train.getIteration(iteration.getName()); + + completions.add(new Completion(trainIteration.toString())); } } diff --git a/release-tools/src/main/java/org/springframework/data/release/deployment/DeploymentOperations.java b/release-tools/src/main/java/org/springframework/data/release/deployment/DeploymentOperations.java index edc37d4..2b5ac89 100644 --- a/release-tools/src/main/java/org/springframework/data/release/deployment/DeploymentOperations.java +++ b/release-tools/src/main/java/org/springframework/data/release/deployment/DeploymentOperations.java @@ -17,12 +17,13 @@ package org.springframework.data.release.deployment; import lombok.RequiredArgsConstructor; +import org.springframework.data.release.utils.Logger; import org.springframework.stereotype.Component; import org.springframework.util.Assert; /** * Deployment functionality. - * + * * @author Oliver Gierke */ @Component @@ -30,6 +31,7 @@ import org.springframework.util.Assert; public class DeploymentOperations { private final ArtifactoryClient client; + private final Logger logger; public void verifyAuthentication() { client.verify(); @@ -37,13 +39,19 @@ public class DeploymentOperations { /** * Promotes the artifacts identified by the given {@link DeploymentInformation}. - * + * * @param information must not be {@literal null}. */ public void promote(DeploymentInformation information) { Assert.notNull(information, "DeploymentInformation must not be null!"); + if (information.getModule().getIteration().isPublic()) { + logger.log(information.getModule(), + "Skipping build promotion as it's a public version and was deployed to Maven Central directly,"); + return; + } + client.promote(information); } } diff --git a/release-tools/src/main/java/org/springframework/data/release/issues/IssueTrackerCommands.java b/release-tools/src/main/java/org/springframework/data/release/issues/IssueTrackerCommands.java index dde435c..a2ccfae 100644 --- a/release-tools/src/main/java/org/springframework/data/release/issues/IssueTrackerCommands.java +++ b/release-tools/src/main/java/org/springframework/data/release/issues/IssueTrackerCommands.java @@ -29,6 +29,7 @@ import org.springframework.data.release.CliComponent; import org.springframework.data.release.TimedCommand; import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.Project; +import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.TrainIteration; import org.springframework.data.release.utils.ExecutionUtils; import org.springframework.plugin.core.PluginRegistry; @@ -131,7 +132,9 @@ class IssueTrackerCommands extends TimedCommand { if (StringUtils.hasText(moduleName)) { - ModuleIteration module = iteration.getModule(moduleName); + Project project = Projects.requiredByName(moduleName); + + ModuleIteration module = iteration.getModule(project); return getTrackerFor(module).getChangelogFor(module).toString(); } diff --git a/release-tools/src/main/java/org/springframework/data/release/model/Iteration.java b/release-tools/src/main/java/org/springframework/data/release/model/Iteration.java index eb1feb8..c408658 100644 --- a/release-tools/src/main/java/org/springframework/data/release/model/Iteration.java +++ b/release-tools/src/main/java/org/springframework/data/release/model/Iteration.java @@ -109,4 +109,13 @@ public class Iteration { public int getBugfixValue() { return name.startsWith("SR") ? Integer.parseInt(name.substring(2)) : 0; } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return name; + } } diff --git a/release-tools/src/main/java/org/springframework/data/release/model/ModuleIteration.java b/release-tools/src/main/java/org/springframework/data/release/model/ModuleIteration.java index 7b0305a..5e556b8 100644 --- a/release-tools/src/main/java/org/springframework/data/release/model/ModuleIteration.java +++ b/release-tools/src/main/java/org/springframework/data/release/model/ModuleIteration.java @@ -15,6 +15,7 @@ */ package org.springframework.data.release.model; +import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -22,7 +23,7 @@ import lombok.RequiredArgsConstructor; /** * @author Oliver Gierke */ -@RequiredArgsConstructor +@RequiredArgsConstructor(access = AccessLevel.PACKAGE) @EqualsAndHashCode public class ModuleIteration implements IterationVersion { @@ -44,7 +45,7 @@ public class ModuleIteration implements IterationVersion { return module.getProject(); } - /* + /* * (non-Javadoc) * @see org.springframework.data.release.model.IterationVersion#getVersion() */ @@ -60,10 +61,11 @@ public class ModuleIteration implements IterationVersion { public Iteration getIteration() { return trainIteration.getIteration().isInitialIteration() && this.module.hasCustomFirstIteration() - ? module.getCustomFirstIteration() : this.trainIteration.getIteration(); + ? module.getCustomFirstIteration() + : this.trainIteration.getIteration(); } - /* + /* * (non-Javadoc) * @see org.springframework.data.release.model.IterationVersion#isBranchVersion() */ @@ -75,7 +77,7 @@ public class ModuleIteration implements IterationVersion { /** * Returns the {@link String} representation of the logical version of the {@link ModuleIteration}. This will * abbreviate trailing zeros and not include the release train name. - * + * * @return */ public String getShortVersionString() { @@ -112,7 +114,7 @@ public class ModuleIteration implements IterationVersion { /** * Returns the {@link String} representation of the logical version of the {@link ModuleIteration}. This will use the * technical version string and append the train iteration. - * + * * @return */ public String getFullVersionString() { diff --git a/release-tools/src/main/java/org/springframework/data/release/model/Train.java b/release-tools/src/main/java/org/springframework/data/release/model/Train.java index fad726d..dc40775 100644 --- a/release-tools/src/main/java/org/springframework/data/release/model/Train.java +++ b/release-tools/src/main/java/org/springframework/data/release/model/Train.java @@ -73,14 +73,6 @@ public class Train implements Streamable { anyMatch(module -> module.getProject().equals(project)); } - public Module getModule(String name) { - - return modules.stream().// - filter(module -> module.getProject().getName().equals(name)).// - findFirst().// - orElseThrow(() -> new IllegalArgumentException(String.format("No Module found with name %s!", name))); - } - /** * Returns the {@link Module} for the given {@link Project} in the current release {@link Train}. * @@ -121,14 +113,21 @@ public class Train implements Streamable { return new Train(name, collect); } - public ModuleIteration getModuleIteration(Iteration iteration, String moduleName) { + /** + * Returns the {@link ModuleIteration} for the given {@link Project} and {@link Iteration}. + * + * @param project must not be {@literal null}. + * @param iteration must not be {@literal null}. + * @return will never be {@literal null}. + */ + public ModuleIteration getModuleIteration(Project project, Iteration iteration) { - return modules.stream().// - filter(module -> module.hasName(moduleName)).// - findFirst().// - map(module -> new ModuleIteration(module, new TrainIteration(this, iteration))).// - orElseThrow( - () -> new IllegalArgumentException(String.format("No module found with module name %s!", moduleName))); + Assert.notNull(project, "Project must not be null!"); + Assert.notNull(iteration, "Iteration must not be null!"); + + Module module = getModule(project); + + return new ModuleIteration(module, getIteration(iteration)); } public Iterable getModuleIterations(Iteration iteration) { @@ -145,8 +144,8 @@ public class Train implements Streamable { collect(Collectors.toList()); } - public Iteration getIteration(String name) { - return iterations.getIterationByName(name); + public TrainIteration getIteration(String name) { + return new TrainIteration(this, iterations.getIterationByName(name)); } public ArtifactVersion getModuleVersion(Project project, Iteration iteration) { @@ -176,6 +175,21 @@ public class Train implements Streamable { return builder.toString(); } + /** + * Returns the {@link TrainIteration} for the given {@link Iteration} contained in this train. + * + * @param iteration must not be {@literal null}. + * @return + * @throws IllegalArgumentException in case the given {@link Iteration} is not available in this {@link Train}. + */ + private TrainIteration getIteration(Iteration iteration) { + + Assert.isTrue(iterations.contains(iteration), + String.format("Iteration %s is not a valid one for the configured iterations %s!", iteration, iterations)); + + return new TrainIteration(this, iteration); + } + /** * Value object to represent a set of {@link Iteration}s. * @@ -223,6 +237,10 @@ public class Train implements Streamable { String.format("Could not find previous iteration for %s!", iteration))); } + boolean contains(Iteration iteration) { + return iterations.contains(iteration); + } + /* * (non-Javadoc) * @see java.lang.Iterable#iterator() diff --git a/release-tools/src/main/java/org/springframework/data/release/model/TrainIteration.java b/release-tools/src/main/java/org/springframework/data/release/model/TrainIteration.java index 5c2d0ea..4078332 100644 --- a/release-tools/src/main/java/org/springframework/data/release/model/TrainIteration.java +++ b/release-tools/src/main/java/org/springframework/data/release/model/TrainIteration.java @@ -15,6 +15,7 @@ */ package org.springframework.data.release.model; +import lombok.RequiredArgsConstructor; import lombok.Value; import java.util.Iterator; @@ -26,12 +27,13 @@ import org.springframework.data.release.Streamable; * @author Oliver Gierke */ @Value +@RequiredArgsConstructor public class TrainIteration implements Streamable { private final Train train; private final Iteration iteration; - /* + /* * (non-Javadoc) * @see java.lang.Iterable#iterator() */ @@ -44,12 +46,8 @@ public class TrainIteration implements Streamable { return train.getModuleVersion(project, iteration); } - public ModuleIteration getModule(String name) { - return train.getModuleIteration(iteration, name); - } - public ModuleIteration getModule(Project project) { - return train.getModuleIteration(iteration, project.getName()); + return train.getModuleIteration(project, iteration); } public List getModulesExcept(Project... exclusions) { @@ -63,7 +61,7 @@ public class TrainIteration implements Streamable { public ModuleIteration getPreviousIteration(ModuleIteration module) { Iteration previousIteration = train.getIterations().getPreviousIteration(iteration); - return train.getModuleIteration(previousIteration, module.getProject().getName()); + return train.getModuleIteration(module.getProject(), previousIteration); } /* diff --git a/release-tools/src/test/java/org/springframework/data/release/ArtifactUnitTests.java b/release-tools/src/test/java/org/springframework/data/release/ArtifactUnitTests.java index d613aa3..322665c 100644 --- a/release-tools/src/test/java/org/springframework/data/release/ArtifactUnitTests.java +++ b/release-tools/src/test/java/org/springframework/data/release/ArtifactUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.junit.Test; import org.springframework.data.release.build.MavenArtifact; import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.Iteration; +import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.ReleaseTrains; /** @@ -32,7 +33,7 @@ public class ArtifactUnitTests { @Test public void testname() { - MavenArtifact artifact = new MavenArtifact(ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.M1, "JPA")); + MavenArtifact artifact = new MavenArtifact(ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.JPA, Iteration.M1)); assertThat(artifact.getArtifactId(), is("spring-data-jpa")); assertThat(artifact.getVersion(), is(ArtifactVersion.of("1.6.0.M1"))); diff --git a/release-tools/src/test/java/org/springframework/data/release/deployment/DeploymentOperationsIntegrationTests.java b/release-tools/src/test/java/org/springframework/data/release/deployment/DeploymentOperationsIntegrationTests.java index 37781d1..236db3b 100644 --- a/release-tools/src/test/java/org/springframework/data/release/deployment/DeploymentOperationsIntegrationTests.java +++ b/release-tools/src/test/java/org/springframework/data/release/deployment/DeploymentOperationsIntegrationTests.java @@ -24,6 +24,7 @@ import org.springframework.data.release.git.GitOperations; import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.Phase; +import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.ReleaseTrains; import org.springframework.data.release.model.Train; @@ -42,7 +43,7 @@ public class DeploymentOperationsIntegrationTests extends AbstractIntegrationTes public void testname() { Train train = ReleaseTrains.HOPPER; - ModuleIteration buildModule = train.getModuleIteration(Iteration.M1, "build"); + ModuleIteration buildModule = train.getModuleIteration(Projects.BUILD, Iteration.M1); git.update(train); build.prepareVersion(buildModule, Phase.PREPARE); diff --git a/release-tools/src/test/java/org/springframework/data/release/deployment/DeploymentOperationsUnitTests.java b/release-tools/src/test/java/org/springframework/data/release/deployment/DeploymentOperationsUnitTests.java new file mode 100644 index 0000000..fdf626f --- /dev/null +++ b/release-tools/src/test/java/org/springframework/data/release/deployment/DeploymentOperationsUnitTests.java @@ -0,0 +1,51 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.release.deployment; + +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; + +import org.junit.Test; +import org.springframework.data.release.model.Iteration; +import org.springframework.data.release.model.ModuleIteration; +import org.springframework.data.release.model.Projects; +import org.springframework.data.release.model.ReleaseTrains; +import org.springframework.data.release.utils.Logger; + +/** + * Unit tests for {@link DeploymentOperations}. + * + * @author Oliver Drotbohm + */ +public class DeploymentOperationsUnitTests { + + @Test // #113 + public void skipsPromotionForPublicArtifacts() { + + Logger logger = mock(Logger.class); + ArtifactoryClient client = mock(ArtifactoryClient.class); + DeploymentOperations operations = new DeploymentOperations(client, logger); + + ModuleIteration module = ReleaseTrains.MOORE.getModuleIteration(Projects.COMMONS, Iteration.GA); + + DefaultDeploymentInformation information = new DefaultDeploymentInformation(module, new DeploymentProperties()); + + operations.promote(information); + + verify(logger).log(eq(module), any()); + verifyZeroInteractions(client); + } +} diff --git a/release-tools/src/test/java/org/springframework/data/release/git/GitProjectUnitTests.java b/release-tools/src/test/java/org/springframework/data/release/git/GitProjectUnitTests.java index 9f6ab76..07f7f4c 100644 --- a/release-tools/src/test/java/org/springframework/data/release/git/GitProjectUnitTests.java +++ b/release-tools/src/test/java/org/springframework/data/release/git/GitProjectUnitTests.java @@ -21,12 +21,13 @@ import static org.junit.Assert.*; import org.junit.Test; import org.springframework.data.release.model.Module; import org.springframework.data.release.model.Project; +import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.ReleaseTrains; import org.springframework.data.release.model.Train; /** * Unit tests for {@link GitProject}. - * + * * @author Oliver Gierke */ public class GitProjectUnitTests { @@ -36,7 +37,7 @@ public class GitProjectUnitTests { Train codd = ReleaseTrains.CODD; GitServer server = new GitServer(); - Module module = codd.getModule("Commons"); + Module module = codd.getModule(Projects.COMMONS); Project project = module.getProject(); GitProject gitProject = new GitProject(project, server); diff --git a/release-tools/src/test/java/org/springframework/data/release/issues/github/GitHubIssueTrackerIntegrationTests.java b/release-tools/src/test/java/org/springframework/data/release/issues/github/GitHubIssueTrackerIntegrationTests.java index d252963..2953395 100644 --- a/release-tools/src/test/java/org/springframework/data/release/issues/github/GitHubIssueTrackerIntegrationTests.java +++ b/release-tools/src/test/java/org/springframework/data/release/issues/github/GitHubIssueTrackerIntegrationTests.java @@ -55,8 +55,8 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests public static final String ISSUES_URI = "/repos/spring-projects/spring-data-build/issues"; public static final String RELEASE_TICKET_URI = "/repos/spring-projects/spring-data-build/issues/233"; public static final String MILESTONES_URI = "/repos/spring-projects/spring-data-build/milestones"; - public static final ModuleIteration BUILD_HOPPER_RC1 = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, - "Build"); + public static final ModuleIteration BUILD_HOPPER_RC1 = ReleaseTrains.HOPPER.getModuleIteration(Projects.BUILD, + Iteration.RC1); @Rule public WireMockRule mockService = new WireMockRule( wireMockConfig().port(8888).fileSource(new ClasspathFileSource("integration/github"))); @@ -189,7 +189,7 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests expectedException.expect(IllegalStateException.class); expectedException.expectMessage("No milestone for Spring Data Build found containing 1.8 RC1!"); - ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "Build"); + ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.BUILD, Iteration.RC1); mockGetIssuesWith("emptyIssues.json"); mockGetMilestonesWith("emptyMilestones.json"); diff --git a/release-tools/src/test/java/org/springframework/data/release/issues/github/GithubMilestoneUnitTests.java b/release-tools/src/test/java/org/springframework/data/release/issues/github/GithubMilestoneUnitTests.java index 6909a82..1268399 100644 --- a/release-tools/src/test/java/org/springframework/data/release/issues/github/GithubMilestoneUnitTests.java +++ b/release-tools/src/test/java/org/springframework/data/release/issues/github/GithubMilestoneUnitTests.java @@ -19,9 +19,9 @@ import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import org.junit.Test; -import org.springframework.data.release.issues.github.GithubMilestone; import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.ModuleIteration; +import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.ReleaseTrains; /** @@ -47,7 +47,7 @@ public class GithubMilestoneUnitTests { @Test public void usesCustomModuleIterationStartVersion() { - ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.M1, "Elasticsearch"); + ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1); GithubMilestone version = new GithubMilestone(module); assertThat(version.toString(), is("1.0 M1 (Dijkstra)")); @@ -56,7 +56,7 @@ public class GithubMilestoneUnitTests { @Test public void doesNotUseCustomIterationOnNonFirstiterations() { - ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.RC1, "Elasticsearch"); + ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.RC1); GithubMilestone version = new GithubMilestone(module); assertThat(version.toString(), is("1.0 RC1 (Dijkstra)")); @@ -65,7 +65,7 @@ public class GithubMilestoneUnitTests { @Test public void rendersDescriptionCorrectly() { - ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.M1, "Elasticsearch"); + ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1); GithubMilestone version = new GithubMilestone(module); assertThat(version.getDescription(), is("Dijkstra M2")); @@ -73,7 +73,7 @@ public class GithubMilestoneUnitTests { private void assertIterationVersion(Iteration iteration, String expected) { - ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(iteration, "Commons"); + ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.COMMONS, iteration); GithubMilestone version = new GithubMilestone(module); assertThat(version.toString(), is(expected)); diff --git a/release-tools/src/test/java/org/springframework/data/release/issues/jira/JiraConnectorIntegrationTests.java b/release-tools/src/test/java/org/springframework/data/release/issues/jira/JiraConnectorIntegrationTests.java index 00f26dd..fef076e 100644 --- a/release-tools/src/test/java/org/springframework/data/release/issues/jira/JiraConnectorIntegrationTests.java +++ b/release-tools/src/test/java/org/springframework/data/release/issues/jira/JiraConnectorIntegrationTests.java @@ -60,7 +60,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { static final String SEARCH_URI = "/rest/api/2/search"; static final String PROJECT_VERSION_URI = "/rest/api/2/project/%s/version"; static final String PROJECT_COMPONENTS_URI = "/rest/api/2/project/%s/components"; - static final ModuleIteration REST_HOPPER_RC1 = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST"); + static final ModuleIteration REST_HOPPER_RC1 = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); @Rule public WireMockRule mockService = new WireMockRule( wireMockConfig().port(8888).fileSource(new ClasspathFileSource("integration/jira"))); @@ -177,7 +177,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { @Test public void createReleaseVersionShouldFindExistingReleaseVersion() throws Exception { - ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST"); + ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); mockGetProjectVersionsWith("releaseVersions.json", moduleIteration.getProjectKey()); @@ -192,7 +192,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { @Test public void archiveReleaseVersionShouldArchiveReleaseVersion() throws Exception { - ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST"); + ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); mockGetProjectVersionsWith("releaseVersions.json", moduleIteration.getProjectKey()); mockService.stubFor(put(urlPathMatching(UPDATE_VERSION_URI)).// @@ -211,7 +211,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { @Test public void createReleaseTicketShouldCreateReleaseTicket() throws Exception { - ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST"); + ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); mockGetProjectVersionsWith("releaseVersions.json", moduleIteration.getProjectKey()); mockGetProjectComponentsWith("projectComponents.json", moduleIteration.getProjectKey()); @@ -233,7 +233,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { @Test public void createReleaseTicketShouldCreateReleaseTicketWithoutComponent() throws Exception { - ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST"); + ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); mockGetProjectVersionsWith("releaseVersions.json", moduleIteration.getProjectKey()); mockGetProjectComponentsWith("emptyProjectComponents.json", moduleIteration.getProjectKey()); @@ -257,7 +257,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Did not find a release version for Spring Data REST 2.5 RC1"); - ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST"); + ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); mockSearchWith("emptyTickets.json"); mockGetProjectVersionsWith("emptyReleaseVersions.json", moduleIteration.getProjectKey()); @@ -273,7 +273,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { @Test public void createReleaseTicketShouldFindExistingTicket() throws Exception { - ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST"); + ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); mockGetProjectVersionsWith("releaseVersions.json", moduleIteration.getProjectKey()); mockGetProjectComponentsWith("projectComponents.json", moduleIteration.getProjectKey()); @@ -327,7 +327,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { @Test public void closeIterationShouldResolveReleaseTicket() { - ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Iteration.RC1, "REST"); + ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); properties.setUsername("mp911de"); diff --git a/release-tools/src/test/java/org/springframework/data/release/issues/jira/JiraVersionUnitTests.java b/release-tools/src/test/java/org/springframework/data/release/issues/jira/JiraVersionUnitTests.java index 8baa83c..cb95f68 100644 --- a/release-tools/src/test/java/org/springframework/data/release/issues/jira/JiraVersionUnitTests.java +++ b/release-tools/src/test/java/org/springframework/data/release/issues/jira/JiraVersionUnitTests.java @@ -19,9 +19,9 @@ import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import org.junit.Test; -import org.springframework.data.release.issues.jira.JiraVersion; import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.ModuleIteration; +import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.ReleaseTrains; /** @@ -47,7 +47,7 @@ public class JiraVersionUnitTests { @Test public void usesCustomModuleIterationStartVersion() { - ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.M1, "Elasticsearch"); + ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1); JiraVersion version = new JiraVersion(module); assertThat(version.toString(), is("1.0 M1 (Dijkstra)")); @@ -56,7 +56,7 @@ public class JiraVersionUnitTests { @Test public void doesNotUseCustomIterationOnNonFirstiterations() { - ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.RC1, "Elasticsearch"); + ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.RC1); JiraVersion version = new JiraVersion(module); assertThat(version.toString(), is("1.0 RC1 (Dijkstra)")); @@ -65,7 +65,7 @@ public class JiraVersionUnitTests { @Test public void rendersDescriptionCorrectly() { - ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.M1, "Elasticsearch"); + ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1); JiraVersion version = new JiraVersion(module); assertThat(version.getDescription(), is("Dijkstra M2")); @@ -73,7 +73,7 @@ public class JiraVersionUnitTests { private void assertIterationVersion(Iteration iteration, String expected) { - ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(iteration, "Commons"); + ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.COMMONS, iteration); JiraVersion version = new JiraVersion(module); assertThat(version.toString(), is(expected)); diff --git a/release-tools/src/test/java/org/springframework/data/release/issues/jira/TicketsUnitTests.java b/release-tools/src/test/java/org/springframework/data/release/issues/jira/TicketsUnitTests.java index 186efa0..150d938 100644 --- a/release-tools/src/test/java/org/springframework/data/release/issues/jira/TicketsUnitTests.java +++ b/release-tools/src/test/java/org/springframework/data/release/issues/jira/TicketsUnitTests.java @@ -26,11 +26,12 @@ import org.junit.Test; import org.springframework.data.release.issues.Ticket; import org.springframework.data.release.issues.Tickets; import org.springframework.data.release.model.Iteration; +import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.ReleaseTrains; /** * Unit tests for {@link Tickets}. - * + * * @author Mark Paluch */ public class TicketsUnitTests { @@ -41,7 +42,7 @@ public class TicketsUnitTests { Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(false, "", "")); Tickets tickets = new Tickets(Collections.singletonList(ticket)); - boolean result = tickets.hasReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Iteration.GA, "JPA")); + boolean result = tickets.hasReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); assertThat(result, is(true)); } @@ -51,7 +52,7 @@ public class TicketsUnitTests { Ticket ticket = new Ticket("1234", "Release 1.10 GA", JiraTicketStatus.of(false, "", "")); Tickets tickets = new Tickets(Collections.singletonList(ticket)); - boolean result = tickets.hasReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Iteration.GA, "JPA")); + boolean result = tickets.hasReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); assertThat(result, is(false)); } @@ -61,7 +62,8 @@ public class TicketsUnitTests { Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(false, "", "")); Tickets tickets = new Tickets(Collections.singletonList(ticket)); - Ticket releaseTicket = tickets.getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Iteration.GA, "JPA")); + Ticket releaseTicket = tickets + .getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); assertThat(releaseTicket, is(ticket)); } @@ -71,7 +73,7 @@ public class TicketsUnitTests { Ticket ticket = new Ticket("1234", "Release 1.10 GA", JiraTicketStatus.of(false, "", "")); Tickets tickets = new Tickets(Collections.singletonList(ticket)); - tickets.getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Iteration.GA, "JPA")); + tickets.getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); fail("Missing IllegalStateException"); } @@ -81,7 +83,8 @@ public class TicketsUnitTests { Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(true, "", "")); Tickets tickets = new Tickets(Collections.singletonList(ticket)); - Ticket releaseTicket = tickets.getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Iteration.GA, "JPA")); + Ticket releaseTicket = tickets + .getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); assertThat(releaseTicket, is(ticket)); } @@ -92,7 +95,7 @@ public class TicketsUnitTests { Tickets tickets = new Tickets(Collections.singletonList(ticket)); Tickets result = tickets - .getReleaseTickets(ReleaseTrains.HOPPER.getModuleIteration(Iteration.GA, "JPA").getTrainIteration()); + .getReleaseTickets(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA).getTrainIteration()); assertThat(result.getTickets().contains(ticket), is(true)); } }