#5 - Polishing.
Refactored issue tracker implementation into dedicated packages. Removed package tangles by moving some types around. Extracted GitHub specific properties into its own properties type reusing the Git credentials as we're talking to GitHub anyway. Added Jackson parameter name module and enabled Java 8 parameter names to be able to get rid of the manually declared constructors for payload classes. Turned them into value objects where possible. Original pull request: #14.
This commit is contained in:
@@ -30,7 +30,6 @@ 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.TrainIteration;
|
||||
import org.springframework.data.release.model.UpdateInformation;
|
||||
import org.xmlbeam.ProjectionFactory;
|
||||
import org.xmlbeam.io.XBFileIO;
|
||||
|
||||
@@ -75,7 +74,7 @@ public class MavenIntegrationTests extends AbstractIntegrationTests {
|
||||
|
||||
TrainIteration iteration = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1);
|
||||
ModuleIteration build = iteration.getModule(Projects.BUILD);
|
||||
UpdateInformation information = new UpdateInformation(iteration, Phase.PREPARE);
|
||||
UpdateInformation information = UpdateInformation.of(iteration, Phase.PREPARE);
|
||||
|
||||
maven.updateProjectDescriptors(build, information);
|
||||
maven.prepareVersion(build, Phase.PREPARE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2016 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.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.release.model;
|
||||
package org.springframework.data.release.build;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -21,6 +21,11 @@ import static org.junit.Assert.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.release.model.Iteration;
|
||||
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.TrainIteration;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link UpdateInformation}.
|
||||
@@ -33,17 +38,17 @@ public class UpdateInformationUnitTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsNullTrainIteration() {
|
||||
new UpdateInformation(null, Phase.CLEANUP);
|
||||
UpdateInformation.of(null, Phase.CLEANUP);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsNullPhase() {
|
||||
new UpdateInformation(hopperM1, null);
|
||||
UpdateInformation.of(hopperM1, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exposesMilestoneRepositoryForMilestone() {
|
||||
assertThat(new UpdateInformation(hopperM1, Phase.PREPARE).getRepository().getId(), is("spring-libs-milestone"));
|
||||
assertThat(UpdateInformation.of(hopperM1, Phase.PREPARE).getRepository().getId(), is("spring-libs-milestone"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -51,7 +56,7 @@ public class UpdateInformationUnitTests {
|
||||
|
||||
Arrays.asList(Iteration.GA, Iteration.SR1).forEach(iteration -> {
|
||||
TrainIteration trainIteration = new TrainIteration(ReleaseTrains.HOPPER, iteration);
|
||||
assertThat(new UpdateInformation(trainIteration, Phase.PREPARE).getRepository().getId(),
|
||||
assertThat(UpdateInformation.of(trainIteration, Phase.PREPARE).getRepository().getId(),
|
||||
is("spring-libs-release"));
|
||||
});
|
||||
}
|
||||
@@ -59,10 +64,10 @@ public class UpdateInformationUnitTests {
|
||||
@Test
|
||||
public void calculatesProjectVersionToSetCorrectly() {
|
||||
|
||||
UpdateInformation updateInformation = new UpdateInformation(hopperM1, Phase.PREPARE);
|
||||
UpdateInformation updateInformation = UpdateInformation.of(hopperM1, Phase.PREPARE);
|
||||
assertThat(updateInformation.getProjectVersionToSet(Projects.JPA).toString(), is("1.10.0.M1"));
|
||||
|
||||
updateInformation = new UpdateInformation(hopperM1, Phase.CLEANUP);
|
||||
updateInformation = UpdateInformation.of(hopperM1, Phase.CLEANUP);
|
||||
assertThat(updateInformation.getProjectVersionToSet(Projects.JPA).toString(), is("1.10.0.BUILD-SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.release.jira;
|
||||
package org.springframework.data.release.issues.github;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.*;
|
||||
@@ -25,25 +25,31 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.AbstractIntegrationTests;
|
||||
import org.springframework.data.release.issues.Ticket;
|
||||
import org.springframework.data.release.issues.github.GitHub;
|
||||
import org.springframework.data.release.issues.github.GitHubProperties;
|
||||
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.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
|
||||
import com.github.tomakehurst.wiremock.common.ClasspathFileSource;
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
|
||||
/**
|
||||
* Integration Tests for {@link GitHubIssueTracker} using a local {@link WireMockRule} server.
|
||||
* Integration Tests for {@link GitHub} using a local {@link WireMockRule} server.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@@ -59,11 +65,17 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests
|
||||
|
||||
@Rule public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Autowired IssueTracker github;
|
||||
@Autowired GitHub github;
|
||||
@Autowired GitHubProperties properties;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(properties.getApiUrl()).build();
|
||||
Assume.assumeThat(uriComponents.getHost(), is("localhost"));
|
||||
|
||||
github.reset();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.release.jira;
|
||||
package org.springframework.data.release.issues.github;
|
||||
|
||||
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.ReleaseTrains;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.release.jira;
|
||||
package org.springframework.data.release.issues.jira;
|
||||
|
||||
import static org.hamcrest.core.Is.*;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -22,6 +22,8 @@ import static org.junit.Assert.*;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.release.issues.jira.JiraComponent;
|
||||
import org.springframework.data.release.issues.jira.JiraComponents;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link JiraComponents}.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.release.jira;
|
||||
package org.springframework.data.release.issues.jira;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.*;
|
||||
@@ -26,12 +26,18 @@ import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.AbstractIntegrationTests;
|
||||
import org.springframework.data.release.issues.Ticket;
|
||||
import org.springframework.data.release.issues.jira.Jira;
|
||||
import org.springframework.data.release.issues.jira.JiraConnector;
|
||||
import org.springframework.data.release.issues.jira.JiraProperties;
|
||||
import org.springframework.data.release.issues.jira.JiraReleaseVersion;
|
||||
import org.springframework.data.release.model.Iteration;
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.data.release.model.ProjectKey;
|
||||
@@ -39,6 +45,8 @@ import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.release.model.ReleaseTrains;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
|
||||
import com.github.tomakehurst.wiremock.common.ClasspathFileSource;
|
||||
@@ -49,7 +57,7 @@ import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class JiraIntegrationTests extends AbstractIntegrationTests {
|
||||
public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
|
||||
|
||||
public static final String CREATE_ISSUE_URI = "/rest/api/2/issue";
|
||||
public static final String CREATE_VERSION_URI = "/rest/api/2/version";
|
||||
@@ -64,9 +72,14 @@ public class JiraIntegrationTests extends AbstractIntegrationTests {
|
||||
@Rule public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Autowired JiraConnector jira;
|
||||
@Autowired JiraProperties properties;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(properties.getApiUrl()).build();
|
||||
Assume.assumeThat(uriComponents.getHost(), is("localhost"));
|
||||
|
||||
jira.reset();
|
||||
}
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.release.jira;
|
||||
package org.springframework.data.release.issues.jira;
|
||||
|
||||
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.ReleaseTrains;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.release.jira;
|
||||
package org.springframework.data.release.issues.jira;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -23,6 +23,9 @@ import static org.springframework.test.util.AssertionErrors.fail;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.release.issues.Ticket;
|
||||
import org.springframework.data.release.issues.Tickets;
|
||||
import org.springframework.data.release.issues.jira.JiraTicketStatus;
|
||||
import org.springframework.data.release.model.Iteration;
|
||||
import org.springframework.data.release.model.ReleaseTrains;
|
||||
|
||||
@@ -93,5 +96,4 @@ public class TicketsUnitTests {
|
||||
.getReleaseTickets(ReleaseTrains.HOPPER.getModuleIteration(Iteration.GA, "JPA").getTrainIteration());
|
||||
assertThat(result.getTickets().contains(ticket), is(true));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user