#145 - Migrate unit tests to JUnit 5 and AssertJ.

This commit is contained in:
Mark Paluch
2020-04-30 15:02:35 +02:00
parent 44517c9680
commit 1a1e0cd07d
42 changed files with 480 additions and 456 deletions

View File

@@ -18,7 +18,7 @@ package org.springframework.data.microbenchmark.r2dbc;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Value; import lombok.Value;
import lombok.experimental.Wither; import lombok.With;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.data.annotation.PersistenceConstructor;
@@ -30,12 +30,12 @@ import org.springframework.data.annotation.PersistenceConstructor;
@RequiredArgsConstructor(access = AccessLevel.PACKAGE, onConstructor = @__(@PersistenceConstructor)) @RequiredArgsConstructor(access = AccessLevel.PACKAGE, onConstructor = @__(@PersistenceConstructor))
class Book { class Book {
@Wither(AccessLevel.PACKAGE) @Id Long id; @With(AccessLevel.PACKAGE) @Id Long id;
String title; String title;
int pages; int pages;
public Book(String title, int pages) { public Book(String title, int pages) {
this.id = null; this.id = null;
this.title = title; this.title = title;
this.pages = pages; this.pages = pages;

View File

@@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.data.build</groupId> <groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-release-cli</artifactId> <artifactId>spring-data-release-cli</artifactId>
@@ -96,7 +96,7 @@
<dependency> <dependency>
<groupId>org.eclipse.jgit</groupId> <groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId> <artifactId>org.eclipse.jgit</artifactId>
<version>5.7.0.202003110725-r</version> <version>5.6.0.201912101111-r</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -120,7 +120,7 @@
<dependency> <dependency>
<groupId>com.github.tomakehurst</groupId> <groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId> <artifactId>wiremock</artifactId>
<version>1.58</version> <version>2.26.3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@@ -119,10 +119,9 @@ class GitCommands extends TimedCommand {
public void backportChangelogs(@CliOption(key = "", mandatory = true) TrainIteration iteration, // public void backportChangelogs(@CliOption(key = "", mandatory = true) TrainIteration iteration, //
@CliOption(key = "target") String trains) { @CliOption(key = "target") String trains) {
List<Train> targets = trains == null ? Collections.emptyList() List<Train> targets = trains == null ? Collections.emptyList() : Stream.of(trains.split(",")).//
: Stream.of(trains.split(",")).// map(it -> ReleaseTrains.getTrainByName(it)).//
map(it -> ReleaseTrains.getTrainByName(it)).// collect(Collectors.toList());
collect(Collectors.toList());
git.backportChangelogs(iteration, targets); git.backportChangelogs(iteration, targets);
} }

View File

@@ -64,7 +64,7 @@ public class Tickets implements Streamable<Ticket> {
public Ticket getReleaseTicket(ModuleIteration moduleIteration) { public Ticket getReleaseTicket(ModuleIteration moduleIteration) {
return findReleaseTicket(moduleIteration).orElseThrow( return findReleaseTicket(moduleIteration).orElseThrow(
() -> new IllegalStateException(String.format("Did not find a release ticket for %s!", moduleIteration))); () -> new IllegalArgumentException(String.format("Did not find a release ticket for %s!", moduleIteration)));
} }
public Tickets getIssueTickets(ModuleIteration moduleIteration) { public Tickets getIssueTickets(ModuleIteration moduleIteration) {

View File

@@ -530,7 +530,7 @@ class GitHub implements IssueTracker {
Optional<Milestone> milestone = findMilestone(moduleIteration, repositoryName); Optional<Milestone> milestone = findMilestone(moduleIteration, repositoryName);
return milestone return milestone
.orElseThrow(() -> new IllegalStateException(String.format("No milestone for %s found containing %s!", // .orElseThrow(() -> new IllegalArgumentException(String.format("No milestone for %s found containing %s!", //
moduleIteration.getProject().getFullName(), // moduleIteration.getProject().getFullName(), //
moduleIteration.getShortVersionString()))); moduleIteration.getShortVersionString())));
} }

View File

@@ -15,15 +15,12 @@
*/ */
package org.springframework.data.release; package org.springframework.data.release;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@ActiveProfiles({ "local", "test" }) @ActiveProfiles({ "local", "test" })
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class) @SpringBootTest(classes = Application.class)
public abstract class AbstractIntegrationTests {} public abstract class AbstractIntegrationTests {}

View File

@@ -15,13 +15,13 @@
*/ */
package org.springframework.data.release; package org.springframework.data.release;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class ApplicationTests extends AbstractIntegrationTests { class ApplicationTests extends AbstractIntegrationTests {
@Test @Test
public void bootstrapsApplication() {} void bootstrapsApplication() {}
} }

View File

@@ -15,10 +15,10 @@
*/ */
package org.springframework.data.release; package org.springframework.data.release;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.data.release.build.MavenArtifact; import org.springframework.data.release.build.MavenArtifact;
import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
@@ -28,15 +28,15 @@ import org.springframework.data.release.model.ReleaseTrains;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class ArtifactUnitTests { class ArtifactUnitTests {
@Test @Test
public void testname() { void testname() {
MavenArtifact artifact = new MavenArtifact(ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.JPA, Iteration.M1)); MavenArtifact artifact = new MavenArtifact(ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.JPA, Iteration.M1));
assertThat(artifact.getArtifactId(), is("spring-data-jpa")); assertThat(artifact.getArtifactId()).isEqualTo("spring-data-jpa");
assertThat(artifact.getVersion(), is(ArtifactVersion.of("1.6.0.M1"))); assertThat(artifact.getVersion()).isEqualTo(ArtifactVersion.of("1.6.0.M1"));
assertThat(artifact.getNextDevelopmentVersion(), is(ArtifactVersion.of("1.6.0.BUILD-SNAPSHOT"))); assertThat(artifact.getNextDevelopmentVersion()).isEqualTo(ArtifactVersion.of("1.6.0.BUILD-SNAPSHOT"));
} }
} }

View File

@@ -0,0 +1,49 @@
/*
* Copyright 2020 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;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
/**
* @author Mark Paluch
*/
public class WireMockExtension extends WireMockServer implements BeforeEachCallback, AfterEachCallback {
private final WireMockConfiguration configuration;
public WireMockExtension(WireMockConfiguration configuration) {
super(configuration);
this.configuration = configuration;
}
@Override
public void beforeEach(ExtensionContext context) {
WireMock.configureFor(configuration.portNumber());
this.start();
}
@Override
public void afterEach(ExtensionContext context) {
this.stop();
this.resetAll();
}
}

View File

@@ -15,10 +15,10 @@
*/ */
package org.springframework.data.release.build; package org.springframework.data.release.build;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.data.release.build.CommandLine.Argument; import org.springframework.data.release.build.CommandLine.Argument;
import org.springframework.data.release.model.Password; import org.springframework.data.release.model.Password;
@@ -26,34 +26,35 @@ import org.springframework.data.release.model.Password;
* Unit tests for {@link Argument}. * Unit tests for {@link Argument}.
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author Mark Paluch
*/ */
public class ArgumentUnitTest { class ArgumentUnitTest {
@Test @Test
public void masksMaskedForToString() { void masksMaskedForToString() {
Argument argument = Argument.of("password").withValue(Password.of("password")); Argument argument = Argument.of("password").withValue(Password.of("password"));
assertThat(argument.toCommandLineArgument(), is("password=password")); assertThat(argument.toCommandLineArgument()).isEqualTo("password=password");
assertThat(argument.toString(), startsWith("password=********")); assertThat(argument.toString()).startsWith("password=********");
} }
@Test @Test
public void quotesValue() { void quotesValue() {
Argument argument = Argument.of("quoted").withQuotedValue("value"); Argument argument = Argument.of("quoted").withQuotedValue("value");
assertThat(argument.toCommandLineArgument(), is("quoted=\"value\"")); assertThat(argument.toCommandLineArgument()).isEqualTo("quoted=\"value\"");
} }
@Test @Test
public void argCreatesJvmArgument() { void argCreatesJvmArgument() {
assertThat(Argument.arg("foo").toCommandLineArgument(), is("-Dfoo")); assertThat(Argument.arg("foo").toCommandLineArgument()).isEqualTo("-Dfoo");
} }
@Test @Test
public void profileCreatesMavenProfile() { void profileCreatesMavenProfile() {
assertThat(Argument.profile("foo").toCommandLineArgument(), is("-Pfoo")); assertThat(Argument.profile("foo").toCommandLineArgument()).isEqualTo("-Pfoo");
assertThat(Argument.profile("foo", "bar").toCommandLineArgument(), is("-Pfoo,bar")); assertThat(Argument.profile("foo", "bar").toCommandLineArgument()).isEqualTo("-Pfoo,bar");
} }
} }

View File

@@ -23,8 +23,9 @@ import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
@@ -32,6 +33,7 @@ import org.springframework.data.release.git.GitOperations;
import org.springframework.data.release.io.Workspace; import org.springframework.data.release.io.Workspace;
import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
import org.xmlbeam.ProjectionFactory; import org.xmlbeam.ProjectionFactory;
import org.xmlbeam.evaluation.XPathEvaluator; import org.xmlbeam.evaluation.XPathEvaluator;
import org.xmlbeam.io.XBFileIO; import org.xmlbeam.io.XBFileIO;
@@ -40,15 +42,15 @@ import org.xmlbeam.io.XBFileIO;
* @author Oliver Gierke * @author Oliver Gierke
* @author Mark Paluch * @author Mark Paluch
*/ */
public class MavenIntegrationTests extends AbstractIntegrationTests { class MavenIntegrationTests extends AbstractIntegrationTests {
@Autowired Workspace workspace; @Autowired Workspace workspace;
@Autowired ProjectionFactory projection; @Autowired ProjectionFactory projection;
@Autowired MavenBuildSystem maven; @Autowired MavenBuildSystem maven;
@Autowired GitOperations git; @Autowired GitOperations git;
@BeforeClass @BeforeAll
public static void beforeClass() { static void beforeClass() {
try { try {
URL url = new URL("https://github.com"); URL url = new URL("https://github.com");
@@ -61,7 +63,7 @@ public class MavenIntegrationTests extends AbstractIntegrationTests {
} }
@Test @Test
public void modifiesParentPomCorrectly() throws IOException { void modifiesParentPomCorrectly() throws IOException {
XBFileIO io = projection.io().file(new ClassPathResource("parent-pom.xml").getFile()); XBFileIO io = projection.io().file(new ClassPathResource("parent-pom.xml").getFile());
@@ -77,7 +79,7 @@ public class MavenIntegrationTests extends AbstractIntegrationTests {
} }
@Test @Test
public void updatesRepositoriesCorrectly() throws Exception { void updatesRepositoriesCorrectly() throws Exception {
XBFileIO io = projection.io().file(new ClassPathResource("sample-pom.xml").getFile()); XBFileIO io = projection.io().file(new ClassPathResource("sample-pom.xml").getFile());
@@ -90,7 +92,7 @@ public class MavenIntegrationTests extends AbstractIntegrationTests {
} }
@Test @Test
public void findsSnapshotDependencies() throws Exception { void findsSnapshotDependencies() throws Exception {
Pom pom = projection.io().file(workspace.getFile("bom/pom.xml", Projects.BUILD)).read(Pom.class); Pom pom = projection.io().file(workspace.getFile("bom/pom.xml", Projects.BUILD)).read(Pom.class);

View File

@@ -15,25 +15,24 @@
*/ */
package org.springframework.data.release.build; package org.springframework.data.release.build;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import java.util.Collections; import java.util.Collections;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Unit tests for {@link MavenProperties}. * Unit tests for {@link MavenProperties}.
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class MavenPropertiesUnitTests { class MavenPropertiesUnitTests {
MavenProperties properties; MavenProperties properties;
@Before @BeforeEach
public void setUp() { void setUp() {
this.properties = new MavenProperties(); this.properties = new MavenProperties();
this.properties.setPlugins(Collections.singletonMap("versions", "org.codehaus.mojo:versions-maven-plugin:2.2")); this.properties.setPlugins(Collections.singletonMap("versions", "org.codehaus.mojo:versions-maven-plugin:2.2"));
@@ -43,25 +42,25 @@ public class MavenPropertiesUnitTests {
* @see #8 * @see #8
*/ */
@Test @Test
public void expandsGoalsCorrectly() { void expandsGoalsCorrectly() {
assertThat(properties.getFullyQualifiedPlugin("versions:set"), assertThat(properties.getFullyQualifiedPlugin("versions:set"))
is("org.codehaus.mojo:versions-maven-plugin:2.2:set")); .isEqualTo("org.codehaus.mojo:versions-maven-plugin:2.2:set");
} }
/** /**
* @see #8 * @see #8
*/ */
@Test @Test
public void doesNotExpandGoalStartingWithDash() { void doesNotExpandGoalStartingWithDash() {
assertThat(properties.getFullyQualifiedPlugin("-versions:set"), is("-versions:set")); assertThat(properties.getFullyQualifiedPlugin("-versions:set")).isEqualTo("-versions:set");
} }
/** /**
* @see #8 * @see #8
*/ */
@Test @Test
public void doesNotExpandGoalWithoutColon() { void doesNotExpandGoalWithoutColon() {
assertThat(properties.getFullyQualifiedPlugin("versions-set"), is("versions-set")); assertThat(properties.getFullyQualifiedPlugin("versions-set")).isEqualTo("versions-set");
} }
} }

View File

@@ -15,12 +15,13 @@
*/ */
package org.springframework.data.release.build; package org.springframework.data.release.build;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import java.util.Arrays; import java.util.Arrays;
import org.junit.Test; import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.Phase; import org.springframework.data.release.model.Phase;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
@@ -31,57 +32,59 @@ import org.springframework.data.release.model.TrainIteration;
* Unit tests for {@link UpdateInformation}. * Unit tests for {@link UpdateInformation}.
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author Mark Paluch
*/ */
public class UpdateInformationUnitTests { class UpdateInformationUnitTests {
TrainIteration hopperM1 = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1); TrainIteration hopperM1 = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1);
@Test(expected = IllegalArgumentException.class) @Test
public void rejectsNullTrainIteration() { void rejectsNullTrainIteration() {
UpdateInformation.of(null, Phase.CLEANUP); Assertions.assertThatIllegalArgumentException().isThrownBy(() -> UpdateInformation.of(null, Phase.CLEANUP));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsNullPhase() {
UpdateInformation.of(hopperM1, null);
} }
@Test @Test
public void exposesMilestoneRepositoryForMilestone() { void rejectsNullPhase() {
assertThat(UpdateInformation.of(hopperM1, Phase.PREPARE).getRepository().getId(), is("spring-libs-milestone")); Assertions.assertThatIllegalArgumentException().isThrownBy(() -> UpdateInformation.of(hopperM1, null));
} }
@Test @Test
public void exposesReleaseRepositoryForGA() { void exposesMilestoneRepositoryForMilestone() {
assertThat(UpdateInformation.of(hopperM1, Phase.PREPARE).getRepository().getId())
.isEqualTo("spring-libs-milestone");
}
@Test
void exposesReleaseRepositoryForGA() {
Arrays.asList(Iteration.GA, Iteration.SR1).forEach(iteration -> { Arrays.asList(Iteration.GA, Iteration.SR1).forEach(iteration -> {
TrainIteration trainIteration = new TrainIteration(ReleaseTrains.HOPPER, iteration); TrainIteration trainIteration = new TrainIteration(ReleaseTrains.HOPPER, iteration);
assertThat(UpdateInformation.of(trainIteration, Phase.PREPARE).getRepository().getId(), assertThat(UpdateInformation.of(trainIteration, Phase.PREPARE).getRepository().getId())
is("spring-libs-release")); .isEqualTo("spring-libs-release");
}); });
} }
@Test @Test
public void calculatesProjectVersionToSetCorrectly() { void calculatesProjectVersionToSetCorrectly() {
UpdateInformation updateInformation = UpdateInformation.of(hopperM1, Phase.PREPARE); UpdateInformation updateInformation = UpdateInformation.of(hopperM1, Phase.PREPARE);
assertThat(updateInformation.getProjectVersionToSet(Projects.JPA).toString(), is("1.10.0.M1")); assertThat(updateInformation.getProjectVersionToSet(Projects.JPA).toString()).isEqualTo("1.10.0.M1");
updateInformation = UpdateInformation.of(hopperM1, Phase.CLEANUP); updateInformation = UpdateInformation.of(hopperM1, Phase.CLEANUP);
assertThat(updateInformation.getProjectVersionToSet(Projects.JPA).toString(), is("1.10.0.BUILD-SNAPSHOT")); assertThat(updateInformation.getProjectVersionToSet(Projects.JPA).toString()).isEqualTo("1.10.0.BUILD-SNAPSHOT");
} }
/** /**
* @see #22 * @see #22
*/ */
@Test @Test
public void returnsCorrectReleaseTrainVersions() { void returnsCorrectReleaseTrainVersions() {
TrainIteration hopperGa = new TrainIteration(ReleaseTrains.HOPPER, Iteration.GA); TrainIteration hopperGa = new TrainIteration(ReleaseTrains.HOPPER, Iteration.GA);
TrainIteration hopperSr1 = new TrainIteration(ReleaseTrains.HOPPER, Iteration.SR1); TrainIteration hopperSr1 = new TrainIteration(ReleaseTrains.HOPPER, Iteration.SR1);
assertThat(UpdateInformation.of(hopperGa, Phase.PREPARE).getReleaseTrainVersion(), is("Hopper-RELEASE")); assertThat(UpdateInformation.of(hopperGa, Phase.PREPARE).getReleaseTrainVersion()).isEqualTo("Hopper-RELEASE");
assertThat(UpdateInformation.of(hopperM1, Phase.PREPARE).getReleaseTrainVersion(), is("Hopper-M1")); assertThat(UpdateInformation.of(hopperM1, Phase.PREPARE).getReleaseTrainVersion()).isEqualTo("Hopper-M1");
assertThat(UpdateInformation.of(hopperSr1, Phase.PREPARE).getReleaseTrainVersion(), is("Hopper-SR1")); assertThat(UpdateInformation.of(hopperSr1, Phase.PREPARE).getReleaseTrainVersion()).isEqualTo("Hopper-SR1");
} }
} }

View File

@@ -15,16 +15,17 @@
*/ */
package org.springframework.data.release.cli; package org.springframework.data.release.cli;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import static org.junit.Assume.*; import static org.junit.Assume.*;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.git.GitOperations; import org.springframework.data.release.git.GitOperations;
@@ -33,13 +34,14 @@ import org.springframework.data.release.model.ReleaseTrains;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class ReleaseCommandsIntegrationTests extends AbstractIntegrationTests { @Disabled("Skip GitHub interaction")
class ReleaseCommandsIntegrationTests extends AbstractIntegrationTests {
@Autowired ReleaseCommands releaseCommands; @Autowired ReleaseCommands releaseCommands;
@Autowired GitOperations git; @Autowired GitOperations git;
@BeforeClass @BeforeAll
public static void beforeClass() { static void beforeClass() {
try { try {
URL url = new URL("https://github.com"); URL url = new URL("https://github.com");
@@ -52,10 +54,10 @@ public class ReleaseCommandsIntegrationTests extends AbstractIntegrationTests {
} }
@Test @Test
public void predictsReleaseTrainCorrectly() throws Exception { void predictsReleaseTrainCorrectly() throws Exception {
git.update(ReleaseTrains.MOORE); git.update(ReleaseTrains.MOORE);
assertThat(releaseCommands.predictTrainAndIteration(), is("Neumann")); assertThat(releaseCommands.predictTrainAndIteration()).isEqualTo("Neumann");
} }
} }

View File

@@ -15,10 +15,10 @@
*/ */
package org.springframework.data.release.deployment; package org.springframework.data.release.deployment;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
@@ -32,20 +32,20 @@ import org.springframework.data.release.model.TrainIteration;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class DeploymentInformationIntegrationTests extends AbstractIntegrationTests { class DeploymentInformationIntegrationTests extends AbstractIntegrationTests {
@Autowired DeploymentProperties properties; @Autowired DeploymentProperties properties;
@Test @Test
public void createsDeploymentInformation() { void createsDeploymentInformation() {
TrainIteration iteration = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1); TrainIteration iteration = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1);
ModuleIteration buildModule = iteration.getModule(Projects.BUILD); ModuleIteration buildModule = iteration.getModule(Projects.BUILD);
DeploymentInformation information = new DefaultDeploymentInformation(buildModule, properties); DeploymentInformation information = new DefaultDeploymentInformation(buildModule, properties);
assertThat(information.getDeploymentTargetUrl(), containsString(properties.getServer().getUri().toString())); assertThat(information.getDeploymentTargetUrl()).contains(properties.getServer().getUri().toString());
assertThat(information.getBuildName(), is("Spring Data Build - Release")); assertThat(information.getBuildName()).isEqualTo("Spring Data Build - Release");
assertThat(information.getTargetRepository(), is("test-libs-milestone-local")); assertThat(information.getTargetRepository()).isEqualTo("test-libs-milestone-local");
} }
} }

View File

@@ -15,8 +15,9 @@
*/ */
package org.springframework.data.release.deployment; package org.springframework.data.release.deployment;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.build.BuildOperations; import org.springframework.data.release.build.BuildOperations;
@@ -31,8 +32,8 @@ import org.springframework.data.release.model.Train;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@Ignore("I will deploy an artifact") @Disabled("I will deploy an artifact")
public class DeploymentOperationsIntegrationTests extends AbstractIntegrationTests { class DeploymentOperationsIntegrationTests extends AbstractIntegrationTests {
@Autowired GitOperations git; @Autowired GitOperations git;
@Autowired BuildOperations build; @Autowired BuildOperations build;
@@ -40,7 +41,7 @@ public class DeploymentOperationsIntegrationTests extends AbstractIntegrationTes
@Autowired ArtifactoryClient client; @Autowired ArtifactoryClient client;
@Test @Test
public void testname() { void testname() {
Train train = ReleaseTrains.HOPPER; Train train = ReleaseTrains.HOPPER;
ModuleIteration buildModule = train.getModuleIteration(Projects.BUILD, Iteration.M1); ModuleIteration buildModule = train.getModuleIteration(Projects.BUILD, Iteration.M1);

View File

@@ -17,7 +17,7 @@ package org.springframework.data.release.deployment;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
@@ -29,10 +29,10 @@ import org.springframework.data.release.utils.Logger;
* *
* @author Oliver Drotbohm * @author Oliver Drotbohm
*/ */
public class DeploymentOperationsUnitTests { class DeploymentOperationsUnitTests {
@Test // #113 @Test // #113
public void skipsPromotionForPublicArtifacts() { void skipsPromotionForPublicArtifacts() {
Logger logger = mock(Logger.class); Logger logger = mock(Logger.class);
ArtifactoryClient client = mock(ArtifactoryClient.class); ArtifactoryClient client = mock(ArtifactoryClient.class);

View File

@@ -15,12 +15,12 @@
*/ */
package org.springframework.data.release.git; package org.springframework.data.release.git;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import java.util.Arrays; import java.util.Arrays;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
@@ -33,7 +33,7 @@ import org.springframework.data.release.model.TrainIteration;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class BackportTargetsUnitTests { class BackportTargetsUnitTests {
Branch goslingBranch = getBranch(ReleaseTrains.GOSLING); Branch goslingBranch = getBranch(ReleaseTrains.GOSLING);
Branch fowlerBranch = getBranch(ReleaseTrains.FOWLER); Branch fowlerBranch = getBranch(ReleaseTrains.FOWLER);
@@ -42,30 +42,30 @@ public class BackportTargetsUnitTests {
* @see #11 * @see #11
*/ */
@Test @Test
public void returnsModuleBranchesForTrains() { void returnsModuleBranchesForTrains() {
TrainIteration iteration = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1); TrainIteration iteration = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1);
ModuleIteration module = iteration.getModule(Projects.COMMONS); ModuleIteration module = iteration.getModule(Projects.COMMONS);
BackportTargets targets = new BackportTargets(module, Arrays.asList(ReleaseTrains.GOSLING, ReleaseTrains.FOWLER)); BackportTargets targets = new BackportTargets(module, Arrays.asList(ReleaseTrains.GOSLING, ReleaseTrains.FOWLER));
assertThat(targets, is(iterableWithSize(2))); assertThat(targets).hasSize(2);
assertThat(targets, hasItems(goslingBranch, fowlerBranch)); assertThat(targets).contains(goslingBranch, fowlerBranch);
} }
/** /**
* @see #11 * @see #11
*/ */
@Test @Test
public void includesMasterBranchForServiceReleaseSource() { void includesMasterBranchForServiceReleaseSource() {
TrainIteration iteration = new TrainIteration(ReleaseTrains.GOSLING, Iteration.SR2); TrainIteration iteration = new TrainIteration(ReleaseTrains.GOSLING, Iteration.SR2);
ModuleIteration module = iteration.getModule(Projects.COMMONS); ModuleIteration module = iteration.getModule(Projects.COMMONS);
BackportTargets targets = new BackportTargets(module, Arrays.asList(ReleaseTrains.FOWLER)); BackportTargets targets = new BackportTargets(module, Arrays.asList(ReleaseTrains.FOWLER));
assertThat(targets, is(iterableWithSize(2))); assertThat(targets).hasSize(2);
assertThat(targets, hasItems(Branch.MASTER, fowlerBranch)); assertThat(targets).contains(Branch.MASTER, fowlerBranch);
} }
private static Branch getBranch(Train train) { private static Branch getBranch(Train train) {

View File

@@ -15,10 +15,10 @@
*/ */
package org.springframework.data.release.git; package org.springframework.data.release.git;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.IterationVersion; import org.springframework.data.release.model.IterationVersion;
import org.springframework.data.release.model.SimpleIterationVersion; import org.springframework.data.release.model.SimpleIterationVersion;
@@ -28,31 +28,31 @@ import org.springframework.data.release.model.Version;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class BranchUnitTests { class BranchUnitTests {
@Test @Test
public void testname() { void testname() {
IterationVersion iterationVersion = new SimpleIterationVersion(Version.of(1, 4), Iteration.RC1); IterationVersion iterationVersion = new SimpleIterationVersion(Version.of(1, 4), Iteration.RC1);
assertThat(Branch.from(iterationVersion).toString(), is("master")); assertThat(Branch.from(iterationVersion).toString()).isEqualTo("master");
} }
@Test @Test
public void createsBugfixBranchForServiceRelease() { void createsBugfixBranchForServiceRelease() {
IterationVersion iterationVersion = new SimpleIterationVersion(Version.of(1, 4), Iteration.SR1); IterationVersion iterationVersion = new SimpleIterationVersion(Version.of(1, 4), Iteration.SR1);
assertThat(Branch.from(iterationVersion).toString(), is("1.4.x")); assertThat(Branch.from(iterationVersion).toString()).isEqualTo("1.4.x");
} }
/** /**
* @see #2 * @see #2
*/ */
@Test @Test
public void detectsIssueBranches() { void detectsIssueBranches() {
Branch branch = Branch.from("issue/DATACMNS-4711"); Branch branch = Branch.from("issue/DATACMNS-4711");
assertThat(branch.isIssueBranch(Tracker.JIRA), is(true)); assertThat(branch.isIssueBranch(Tracker.JIRA)).isTrue();
assertThat(branch.isIssueBranch(Tracker.GITHUB), is(false)); assertThat(branch.isIssueBranch(Tracker.GITHUB)).isFalse();
} }
} }

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Optional; import java.util.Optional;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.data.release.issues.Ticket; import org.springframework.data.release.issues.Ticket;
@@ -28,17 +28,17 @@ import org.springframework.data.release.issues.TicketStatus;
/** /**
* @author Mark Paluch * @author Mark Paluch
*/ */
public class CommitUnitTests { class CommitUnitTests {
@Test @Test
public void shouldRenderCommitMessage() { void shouldRenderCommitMessage() {
assertThat(new Commit(new Ticket("1234", "Hello", Mockito.mock(TicketStatus.class)), "Summary", Optional.empty())) assertThat(new Commit(new Ticket("1234", "Hello", Mockito.mock(TicketStatus.class)), "Summary", Optional.empty()))
.hasToString("1234 - Summary."); .hasToString("1234 - Summary.");
} }
@Test @Test
public void shouldRenderCommitMessageWithDetail() { void shouldRenderCommitMessageWithDetail() {
assertThat( assertThat(
new Commit(new Ticket("1234", "Hello", Mockito.mock(TicketStatus.class)), "Summary", Optional.of("detail"))) new Commit(new Ticket("1234", "Hello", Mockito.mock(TicketStatus.class)), "Summary", Optional.of("detail")))

View File

@@ -15,8 +15,7 @@
*/ */
package org.springframework.data.release.git; package org.springframework.data.release.git;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import static org.junit.Assume.*; import static org.junit.Assume.*;
import static org.springframework.data.release.model.Projects.*; import static org.springframework.data.release.model.Projects.*;
@@ -24,8 +23,10 @@ import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.model.ReleaseTrains; import org.springframework.data.release.model.ReleaseTrains;
@@ -34,12 +35,13 @@ import org.springframework.data.release.model.TestReleaseTrains;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class GitOperationsIntegrationTests extends AbstractIntegrationTests { @Disabled
class GitOperationsIntegrationTests extends AbstractIntegrationTests {
@Autowired GitOperations gitOperations; @Autowired GitOperations gitOperations;
@BeforeClass @BeforeAll
public static void beforeClass() { static void beforeClass() {
try { try {
URL url = new URL("https://github.com"); URL url = new URL("https://github.com");
@@ -52,25 +54,25 @@ public class GitOperationsIntegrationTests extends AbstractIntegrationTests {
} }
@Test @Test
public void updatesGitRepositories() throws Exception { void updatesGitRepositories() throws Exception {
gitOperations.update(ReleaseTrains.GOSLING); gitOperations.update(ReleaseTrains.GOSLING);
} }
@Test @Test
public void showTags() throws Exception { void showTags() throws Exception {
gitOperations.update(TestReleaseTrains.SAMPLE); gitOperations.update(TestReleaseTrains.SAMPLE);
assertThat(gitOperations.getTags(BUILD).asList(), is(not(emptyIterable()))); assertThat(gitOperations.getTags(BUILD).asList()).isNotEmpty();
} }
@Test @Test
public void foo() throws Exception { void foo() throws Exception {
gitOperations.update(TestReleaseTrains.SAMPLE); gitOperations.update(TestReleaseTrains.SAMPLE);
} }
@Test @Test
public void obtainsVersionTagsForRepoThatAlsoHasOtherTags() { void obtainsVersionTagsForRepoThatAlsoHasOtherTags() {
gitOperations.getTags(MONGO_DB); gitOperations.getTags(MONGO_DB);
} }
} }

View File

@@ -15,10 +15,10 @@
*/ */
package org.springframework.data.release.git; package org.springframework.data.release.git;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.data.release.model.Module; import org.springframework.data.release.model.Module;
import org.springframework.data.release.model.Project; import org.springframework.data.release.model.Project;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
@@ -30,10 +30,10 @@ import org.springframework.data.release.model.Train;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class GitProjectUnitTests { class GitProjectUnitTests {
@Test @Test
public void buildsGitHubRepositoryUriCorrectly() { void buildsGitHubRepositoryUriCorrectly() {
Train codd = ReleaseTrains.CODD; Train codd = ReleaseTrains.CODD;
GitServer server = new GitServer(); GitServer server = new GitServer();
@@ -44,7 +44,7 @@ public class GitProjectUnitTests {
String projectUri = gitProject.getProjectUri(); String projectUri = gitProject.getProjectUri();
assertThat(projectUri, startsWith(server.getUri())); assertThat(projectUri).startsWith(server.getUri());
assertThat(projectUri, endsWith("spring-data-commons")); assertThat(projectUri).endsWith("spring-data-commons");
} }
} }

View File

@@ -15,23 +15,23 @@
*/ */
package org.springframework.data.release.git; package org.springframework.data.release.git;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class GitPropertiesIntegrationTests extends AbstractIntegrationTests { class GitPropertiesIntegrationTests extends AbstractIntegrationTests {
@Autowired GitProperties gitProperties; @Autowired GitProperties gitProperties;
@Test @Test
public void hasBasicPropertiesConfigured() { void hasBasicPropertiesConfigured() {
assertThat(gitProperties.getAuthor(), is(notNullValue())); assertThat(gitProperties.getAuthor()).isNotNull();
assertThat(gitProperties.getEmail(), is(notNullValue())); assertThat(gitProperties.getEmail()).isNotNull();
} }
} }

View File

@@ -15,22 +15,22 @@
*/ */
package org.springframework.data.release.io; package org.springframework.data.release.io;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class IoPropertiesIntegrationTests extends AbstractIntegrationTests { class IoPropertiesIntegrationTests extends AbstractIntegrationTests {
@Autowired IoProperties ioProperties; @Autowired IoProperties ioProperties;
@Test @Test
public void configuresWorkingDirectoryFromApplicationProperties() { void configuresWorkingDirectoryFromApplicationProperties() {
assertThat(ioProperties.getWorkDir(), is(notNullValue())); assertThat(ioProperties.getWorkDir()).isNotNull();
} }
} }

View File

@@ -17,20 +17,19 @@ package org.springframework.data.release.issues.github;
import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.*; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.*;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*; import static org.assertj.core.api.Assumptions.*;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
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.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.WireMockExtension;
import org.springframework.data.release.issues.Ticket; import org.springframework.data.release.issues.Ticket;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
@@ -43,34 +42,31 @@ import org.springframework.web.util.UriComponentsBuilder;
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
import com.github.tomakehurst.wiremock.common.ClasspathFileSource; import com.github.tomakehurst.wiremock.common.ClasspathFileSource;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
/** /**
* Integration Tests for {@link GitHub} using a local {@link WireMockRule} server. * Integration Tests for {@link GitHub} using a local {@link WireMockExtension} server.
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests { class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests {
public static final String ISSUES_URI = "/repos/spring-projects/spring-data-build/issues"; 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"; 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"; static final String MILESTONES_URI = "/repos/spring-projects/spring-data-build/milestones";
public static final ModuleIteration BUILD_HOPPER_RC1 = ReleaseTrains.HOPPER.getModuleIteration(Projects.BUILD, static final ModuleIteration BUILD_HOPPER_RC1 = ReleaseTrains.HOPPER.getModuleIteration(Projects.BUILD,
Iteration.RC1); Iteration.RC1);
@Rule public WireMockRule mockService = new WireMockRule( @RegisterExtension WireMockExtension mockService = new WireMockExtension(
wireMockConfig().port(8888).fileSource(new ClasspathFileSource("integration/github"))); wireMockConfig().port(8888).fileSource(new ClasspathFileSource("integration/github")));
@Rule public ExpectedException expectedException = ExpectedException.none();
@Autowired GitHub github; @Autowired GitHub github;
@Autowired GitHubProperties properties; @Autowired GitHubProperties properties;
@Before @BeforeEach
public void before() throws Exception { void before() {
UriComponents uriComponents = UriComponentsBuilder.fromUriString(properties.getApiUrl()).build(); UriComponents uriComponents = UriComponentsBuilder.fromUriString(properties.getApiUrl()).build();
Assume.assumeThat(uriComponents.getHost(), is("localhost")); assumeThat(uriComponents.getHost()).isEqualTo("localhost");
github.reset(); github.reset();
} }
@@ -79,83 +75,79 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests
* @see #5 * @see #5
*/ */
@Test @Test
public void findTicketsByTicketIds() throws Exception { void findTicketsByTicketIds() {
mockGetIssueWith("issue.json", 233); mockGetIssueWith("issue.json", 233);
Collection<Ticket> tickets = github.findTickets(Projects.BUILD, Arrays.asList("233")); Collection<Ticket> tickets = github.findTickets(Projects.BUILD, Collections.singletonList("233"));
assertThat(tickets, hasSize(1)); assertThat(tickets).hasSize(1);
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void ignoresUnknownTicketsByTicketId() throws Exception { void ignoresUnknownTicketsByTicketId() {
Collection<Ticket> tickets = github.findTickets(Projects.BUILD, Arrays.asList("123")); Collection<Ticket> tickets = github.findTickets(Projects.BUILD, Collections.singletonList("123"));
assertThat(tickets, hasSize(0)); assertThat(tickets).hasSize(0);
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void emptyResultWithEmptyTicketIds() throws Exception { void emptyResultWithEmptyTicketIds() {
Collection<Ticket> tickets = github.findTickets(Projects.COMMONS, Arrays.asList()); Collection<Ticket> tickets = github.findTickets(Projects.COMMONS, Collections.emptyList());
assertThat(tickets, hasSize(0)); assertThat(tickets).hasSize(0);
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void getReleaseTicketForReturnsTheReleaseTicket() throws Exception { void getReleaseTicketForReturnsTheReleaseTicket() {
mockGetMilestonesWith("milestones.json"); mockGetMilestonesWith("milestones.json");
mockGetIssuesWith("issues.json"); mockGetIssuesWith("issues.json");
Ticket releaseTicket = github.getReleaseTicketFor(BUILD_HOPPER_RC1); Ticket releaseTicket = github.getReleaseTicketFor(BUILD_HOPPER_RC1);
assertThat(releaseTicket.getId(), is(Matchers.equalTo("#233"))); assertThat(releaseTicket.getId()).isEqualTo("#233");
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void noReleaseTicketFound() throws Exception { void noReleaseTicketFound() {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("No milestone for Spring Data Build found containing 1.8 RC1!");
mockGetMilestonesWith("emptyMilestones.json"); mockGetMilestonesWith("emptyMilestones.json");
github.getReleaseTicketFor(BUILD_HOPPER_RC1); assertThatIllegalArgumentException().isThrownBy(() -> github.getReleaseTicketFor(BUILD_HOPPER_RC1))
.withMessageContaining("No milestone for Spring Data Build found containing 1.8 RC1!");
fail("Missing IllegalStateException");
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseVersionShouldCreateAVersion() throws Exception { void createReleaseVersionShouldCreateAVersion() {
mockGetMilestonesWith("emptyMilestones.json"); mockGetMilestonesWith("emptyMilestones.json");
mockCreateMilestoneWith("milestone.json"); mockCreateMilestoneWith("milestone.json");
github.createReleaseVersion(BUILD_HOPPER_RC1); github.createReleaseVersion(BUILD_HOPPER_RC1);
verify(postRequestedFor(urlPathMatching(MILESTONES_URI)).withRequestBody( verify(postRequestedFor(urlPathMatching(MILESTONES_URI))
equalToJson("{\"title\":\"1.8 RC1 (Hopper)\", \"description\":\"Hopper RC1\"}"))); .withRequestBody(equalToJson("{\"title\":\"1.8 RC1 (Hopper)\", \"description\":\"Hopper RC1\"}")));
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseVersionShouldFindExistingReleaseVersion() throws Exception { void createReleaseVersionShouldFindExistingReleaseVersion() {
mockGetMilestonesWith("milestones.json"); mockGetMilestonesWith("milestones.json");
@@ -168,7 +160,7 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseTicketShouldCreateReleaseTicket() throws Exception { void createReleaseTicketShouldCreateReleaseTicket() {
mockGetMilestonesWith("milestones.json"); mockGetMilestonesWith("milestones.json");
mockGetIssuesWith("emptyIssues.json"); mockGetIssuesWith("emptyIssues.json");
@@ -184,26 +176,22 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseTicketShouldFailWithNoReleaseVersion() throws Exception { void createReleaseTicketShouldFailWithNoReleaseVersion() {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("No milestone for Spring Data Build found containing 1.8 RC1!");
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.BUILD, Iteration.RC1); ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.BUILD, Iteration.RC1);
mockGetIssuesWith("emptyIssues.json"); mockGetIssuesWith("emptyIssues.json");
mockGetMilestonesWith("emptyMilestones.json"); mockGetMilestonesWith("emptyMilestones.json");
github.createReleaseTicket(moduleIteration); assertThatIllegalArgumentException().isThrownBy(() -> github.createReleaseTicket(moduleIteration))
.withMessageContaining("No milestone for Spring Data Build found containing 1.8 RC1!");
fail("Missing IllegalStateException");
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseTicketShouldFindExistingTicket() throws Exception { void createReleaseTicketShouldFindExistingTicket() {
mockGetMilestonesWith("milestones.json"); mockGetMilestonesWith("milestones.json");
mockGetIssuesWith("issues.json"); mockGetIssuesWith("issues.json");
@@ -217,7 +205,7 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests
* @see #55 * @see #55
*/ */
@Test @Test
public void assignTicketToMe() { void assignTicketToMe() {
mockGetMilestonesWith("milestones.json"); mockGetMilestonesWith("milestones.json");
mockGetIssuesWith("issues.json"); mockGetIssuesWith("issues.json");
@@ -235,7 +223,7 @@ public class GitHubIssueTrackerIntegrationTests extends AbstractIntegrationTests
* @see #94 * @see #94
*/ */
@Test @Test
public void closeIterationShouldResolveReleaseTicket() { void closeIterationShouldResolveReleaseTicket() {
mockGetMilestonesWith("milestones.json"); mockGetMilestonesWith("milestones.json");
mockGetIssuesWith("issues.json"); mockGetIssuesWith("issues.json");

View File

@@ -19,27 +19,28 @@ import static org.assertj.core.api.Assertions.*;
import java.io.IOException; import java.io.IOException;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest; import org.springframework.boot.test.autoconfigure.json.JsonTest;
import org.springframework.boot.test.json.JacksonTester; import org.springframework.boot.test.json.JacksonTester;
import org.springframework.data.release.issues.github.GitHubIssue.Milestone; import org.springframework.data.release.issues.github.GitHubIssue.Milestone;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit.jupiter.SpringExtension;
/** /**
* Unit tests for {@link GitHubIssue}. * Unit tests for {@link GitHubIssue}.
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
@RunWith(SpringRunner.class)
@JsonTest @JsonTest
public class GitHubIssueUnitTests { @ExtendWith(SpringExtension.class)
class GitHubIssueUnitTests {
@Autowired private JacksonTester<Milestone> json; @Autowired private JacksonTester<Milestone> json;
@Test @Test
public void shouldNotRenderOpenProperty() throws IOException { void shouldNotRenderOpenProperty() throws IOException {
Milestone milestone = Milestone.of("my-title", "my-description"); Milestone milestone = Milestone.of("my-title", "my-description");

View File

@@ -15,10 +15,10 @@
*/ */
package org.springframework.data.release.issues.github; package org.springframework.data.release.issues.github;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
@@ -29,10 +29,10 @@ import org.springframework.data.release.model.ReleaseTrains;
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
public class GithubMilestoneUnitTests { class GithubMilestoneUnitTests {
@Test @Test
public void rendersGithubGaVersionCorrectly() { void rendersGithubGaVersionCorrectly() {
assertIterationVersion(Iteration.M1, "1.8 M1 (Dijkstra)"); assertIterationVersion(Iteration.M1, "1.8 M1 (Dijkstra)");
assertIterationVersion(Iteration.RC1, "1.8 RC1 (Dijkstra)"); assertIterationVersion(Iteration.RC1, "1.8 RC1 (Dijkstra)");
@@ -45,30 +45,30 @@ public class GithubMilestoneUnitTests {
} }
@Test @Test
public void usesCustomModuleIterationStartVersion() { void usesCustomModuleIterationStartVersion() {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1); ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1);
GithubMilestone version = new GithubMilestone(module); GithubMilestone version = new GithubMilestone(module);
assertThat(version.toString(), is("1.0 M1 (Dijkstra)")); assertThat(version.toString()).isEqualTo("1.0 M1 (Dijkstra)");
} }
@Test @Test
public void doesNotUseCustomIterationOnNonFirstiterations() { void doesNotUseCustomIterationOnNonFirstiterations() {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.RC1); ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.RC1);
GithubMilestone version = new GithubMilestone(module); GithubMilestone version = new GithubMilestone(module);
assertThat(version.toString(), is("1.0 RC1 (Dijkstra)")); assertThat(version.toString()).isEqualTo("1.0 RC1 (Dijkstra)");
} }
@Test @Test
public void rendersDescriptionCorrectly() { void rendersDescriptionCorrectly() {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1); ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1);
GithubMilestone version = new GithubMilestone(module); GithubMilestone version = new GithubMilestone(module);
assertThat(version.getDescription(), is("Dijkstra M2")); assertThat(version.getDescription()).isEqualTo("Dijkstra M2");
} }
private void assertIterationVersion(Iteration iteration, String expected) { private void assertIterationVersion(Iteration iteration, String expected) {
@@ -76,6 +76,6 @@ public class GithubMilestoneUnitTests {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.COMMONS, iteration); ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.COMMONS, iteration);
GithubMilestone version = new GithubMilestone(module); GithubMilestone version = new GithubMilestone(module);
assertThat(version.toString(), is(expected)); assertThat(version.toString()).isEqualTo(expected);
} }
} }

View File

@@ -13,55 +13,50 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.release.issues.jira; package org.springframework.data.release.issues.jira;
import static org.hamcrest.core.Is.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import java.util.Collections; import java.util.Collections;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Unit tests for {@link JiraComponents}. * Unit tests for {@link JiraComponents}.
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
public class JiraComponentsUnitTests { class JiraComponentsUnitTests {
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void returnsComponentByName() throws Exception { void returnsComponentByName() {
JiraComponent fooComponent = new JiraComponent("123", "foo"); JiraComponent fooComponent = new JiraComponent("123", "foo");
JiraComponents jiraComponents = JiraComponents.of(Collections.singleton(fooComponent)); JiraComponents jiraComponents = JiraComponents.of(Collections.singleton(fooComponent));
assertThat(jiraComponents.findComponent("foo").isPresent(), is(true)); assertThat(jiraComponents.findComponent("foo").isPresent()).isTrue();
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void returnsEmptyIfComponentMissing() throws Exception { void returnsEmptyIfComponentMissing() {
JiraComponent fooComponent = new JiraComponent("123", "foo"); JiraComponent fooComponent = new JiraComponent("123", "foo");
JiraComponents jiraComponents = JiraComponents.of(Collections.singleton(fooComponent)); JiraComponents jiraComponents = JiraComponents.of(Collections.singleton(fooComponent));
assertThat(jiraComponents.findComponent("baz").isPresent(), is(false)); assertThat(jiraComponents.findComponent("baz").isPresent()).isFalse();
} }
/** /**
* @see #5 * @see #5
*/ */
@Test(expected = IllegalArgumentException.class) @Test
public void failsOnNullArgumentConstruction() throws Exception { void failsOnNullArgumentConstruction() {
assertThatIllegalArgumentException().isThrownBy(() -> JiraComponents.of(null));
JiraComponents.of(null);
fail("Missing IllegalArgumentException");
} }
} }

View File

@@ -17,21 +17,20 @@ package org.springframework.data.release.issues.jira;
import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.*; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.*;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*; import static org.assertj.core.api.Assumptions.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import org.hamcrest.Matchers; import org.junit.jupiter.api.BeforeEach;
import org.junit.Assume; import org.junit.jupiter.api.Test;
import org.junit.Before; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.WireMockExtension;
import org.springframework.data.release.issues.Ticket; import org.springframework.data.release.issues.Ticket;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
@@ -45,14 +44,13 @@ import org.springframework.web.util.UriComponentsBuilder;
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
import com.github.tomakehurst.wiremock.common.ClasspathFileSource; import com.github.tomakehurst.wiremock.common.ClasspathFileSource;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
/** /**
* Integration Tests for {@link Jira} using a local {@link WireMockRule} server. * Integration Tests for {@link Jira} using a local {@link WireMockExtension} server.
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
public class JiraConnectorIntegrationTests extends AbstractIntegrationTests { class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
static final String CREATE_ISSUE_URI = "/rest/api/2/issue"; static final String CREATE_ISSUE_URI = "/rest/api/2/issue";
static final String CREATE_VERSION_URI = "/rest/api/2/version"; static final String CREATE_VERSION_URI = "/rest/api/2/version";
@@ -62,19 +60,17 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
static final String PROJECT_COMPONENTS_URI = "/rest/api/2/project/%s/components"; static final String PROJECT_COMPONENTS_URI = "/rest/api/2/project/%s/components";
static final ModuleIteration REST_HOPPER_RC1 = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); static final ModuleIteration REST_HOPPER_RC1 = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1);
@Rule public WireMockRule mockService = new WireMockRule( @RegisterExtension WireMockExtension mockService = new WireMockExtension(
wireMockConfig().port(8888).fileSource(new ClasspathFileSource("integration/jira"))); wireMockConfig().port(8888).fileSource(new ClasspathFileSource("integration/jira")));
@Rule public ExpectedException expectedException = ExpectedException.none();
@Autowired JiraConnector jira; @Autowired JiraConnector jira;
@Autowired JiraProperties properties; @Autowired JiraProperties properties;
@Before @BeforeEach
public void before() throws Exception { void before() {
UriComponents uriComponents = UriComponentsBuilder.fromUriString(properties.getApiUrl()).build(); UriComponents uriComponents = UriComponentsBuilder.fromUriString(properties.getApiUrl()).build();
Assume.assumeThat(uriComponents.getHost(), is("localhost")); assumeThat(uriComponents.getHost()).isEqualTo("localhost");
properties.setUsername("dummy"); properties.setUsername("dummy");
jira.reset(); jira.reset();
@@ -84,83 +80,79 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #5 * @see #5
*/ */
@Test @Test
public void findResolvedTicketsByTicketIds() throws Exception { void findResolvedTicketsByTicketIds() {
mockSearchWith("DATAREDIS-1andDATAJPA-1.json"); mockSearchWith("DATAREDIS-1andDATAJPA-1.json");
Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList("DATAREDIS-1", "DATAJPA-1")); Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList("DATAREDIS-1", "DATAJPA-1"));
assertThat(tickets, hasSize(2)); assertThat(tickets).hasSize(2);
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void ignoresUnknownTicketsByTicketId() throws Exception { void ignoresUnknownTicketsByTicketId() {
mockSearchWith("emptyTickets.json"); mockSearchWith("emptyTickets.json");
Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList("XYZ-1", "UNKOWN-1")); Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList("XYZ-1", "UNKOWN-1"));
assertThat(tickets, hasSize(0)); assertThat(tickets).hasSize(0);
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void emptyResultWithEmptyTicketIds() throws Exception { void emptyResultWithEmptyTicketIds() {
Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList()); Collection<Ticket> tickets = jira.findTickets(Projects.COMMONS, Arrays.asList());
assertThat(tickets, hasSize(0)); assertThat(tickets).hasSize(0);
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void getReleaseTicketForReturnsTheReleaseTicket() throws Exception { void getReleaseTicketForReturnsTheReleaseTicket() {
mockSearchWith("releaseTickets.json"); mockSearchWith("releaseTickets.json");
Ticket releaseTicket = jira.getReleaseTicketFor(REST_HOPPER_RC1); Ticket releaseTicket = jira.getReleaseTicketFor(REST_HOPPER_RC1);
assertThat(releaseTicket.getId(), is(Matchers.equalTo("DATAREST-782"))); assertThat(releaseTicket.getId()).isEqualTo("DATAREST-782");
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void noReleaseTicketFound() throws Exception { void noReleaseTicketFound() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Did not find a release ticket for Spring Data REST 2.5 RC1");
mockSearchWith("emptyTickets.json"); mockSearchWith("emptyTickets.json");
jira.getReleaseTicketFor(REST_HOPPER_RC1); assertThatIllegalArgumentException().isThrownBy(() -> jira.getReleaseTicketFor(REST_HOPPER_RC1))
.withMessageContaining("Did not find a release ticket for Spring Data REST 2.5 RC1");
fail("Missing IllegalStateException");
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void getReleaseVersion() throws Exception { void getReleaseVersion() {
mockGetProjectVersionsWith("releaseVersions.json", REST_HOPPER_RC1.getProjectKey()); mockGetProjectVersionsWith("releaseVersions.json", REST_HOPPER_RC1.getProjectKey());
Optional<JiraReleaseVersion> optional = jira.findJiraReleaseVersion(REST_HOPPER_RC1); Optional<JiraReleaseVersion> optional = jira.findJiraReleaseVersion(REST_HOPPER_RC1);
assertThat(optional.isPresent(), is(true)); assertThat(optional.isPresent()).isTrue();
assertThat(optional.get().getName(), is(Matchers.equalTo("2.5 RC1 (Hopper)"))); assertThat(optional.get().getName()).isEqualTo("2.5 RC1 (Hopper)");
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseVersionShouldCreateAVersion() throws Exception { void createReleaseVersionShouldCreateAVersion() {
mockGetProjectVersionsWith("emptyReleaseVersions.json", REST_HOPPER_RC1.getProjectKey()); mockGetProjectVersionsWith("emptyReleaseVersions.json", REST_HOPPER_RC1.getProjectKey());
mockCreateVersionWith("versionCreated.json"); mockCreateVersionWith("versionCreated.json");
@@ -175,7 +167,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseVersionShouldFindExistingReleaseVersion() throws Exception { void createReleaseVersionShouldFindExistingReleaseVersion() {
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1);
@@ -190,7 +182,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #56 * @see #56
*/ */
@Test @Test
public void archiveReleaseVersionShouldArchiveReleaseVersion() throws Exception { void archiveReleaseVersionShouldArchiveReleaseVersion() {
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1);
@@ -209,7 +201,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseTicketShouldCreateReleaseTicket() throws Exception { void createReleaseTicketShouldCreateReleaseTicket() {
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1);
@@ -231,7 +223,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseTicketShouldCreateReleaseTicketWithoutComponent() throws Exception { void createReleaseTicketShouldCreateReleaseTicketWithoutComponent() {
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1);
@@ -252,26 +244,22 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseTicketShouldFailWithNoReleaseVersion() throws Exception { void createReleaseTicketShouldFailWithNoReleaseVersion() {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Did not find a release version for Spring Data REST 2.5 RC1");
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1);
mockSearchWith("emptyTickets.json"); mockSearchWith("emptyTickets.json");
mockGetProjectVersionsWith("emptyReleaseVersions.json", moduleIteration.getProjectKey()); mockGetProjectVersionsWith("emptyReleaseVersions.json", moduleIteration.getProjectKey());
jira.createReleaseTicket(moduleIteration); assertThatIllegalStateException().isThrownBy(() -> jira.createReleaseTicket(moduleIteration))
.withMessageContaining("Did not find a release version for Spring Data REST 2.5 RC1");
fail("Missing IllegalStateException");
} }
/** /**
* @see #5 * @see #5
*/ */
@Test @Test
public void createReleaseTicketShouldFindExistingTicket() throws Exception { void createReleaseTicketShouldFindExistingTicket() {
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1);
@@ -288,7 +276,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #5, #54 * @see #5, #54
*/ */
@Test @Test
public void assignTicketToMe() { void assignTicketToMe() {
mockService.stubFor(get(urlPathMatching("/rest/api/2/issue/DATAREDIS-302")).// mockService.stubFor(get(urlPathMatching("/rest/api/2/issue/DATAREDIS-302")).//
willReturn(json("existingTicket.json"))); willReturn(json("existingTicket.json")));
@@ -306,7 +294,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #5, #53 * @see #5, #53
*/ */
@Test @Test
public void skipTicketAssignmentIfAssigned() { void skipTicketAssignmentIfAssigned() {
properties.setUsername("mp911de"); properties.setUsername("mp911de");
@@ -325,7 +313,7 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
* @see #94 * @see #94
*/ */
@Test @Test
public void closeIterationShouldResolveReleaseTicket() { void closeIterationShouldResolveReleaseTicket() {
ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1); ModuleIteration moduleIteration = ReleaseTrains.HOPPER.getModuleIteration(Projects.REST, Iteration.RC1);
@@ -337,9 +325,12 @@ public class JiraConnectorIntegrationTests extends AbstractIntegrationTests {
mockService.stubFor(get(urlPathMatching("/rest/api/2/issue/DATAREST-782")).// mockService.stubFor(get(urlPathMatching("/rest/api/2/issue/DATAREST-782")).//
willReturn(json("releaseTicket.json"))); willReturn(json("releaseTicket.json")));
mockService.stubFor(post(urlPathMatching("/rest/api/2/issue/DATAREST-782/transitions")) //
.willReturn(ResponseDefinitionBuilder.responseDefinition().withStatus(200)));
jira.closeIteration(moduleIteration); jira.closeIteration(moduleIteration);
verify(postRequestedFor(urlPathMatching("/rest/api/2/issue/DATAREST-782")).withRequestBody( verify(postRequestedFor(urlPathMatching("/rest/api/2/issue/DATAREST-782/transitions")).withRequestBody(
equalToJson("{\"update\":{},\"transition\":{\"id\":5},\"fields\":{\"resolution\":{\"name\":\"Complete\"}}}"))); equalToJson("{\"update\":{},\"transition\":{\"id\":5},\"fields\":{\"resolution\":{\"name\":\"Complete\"}}}")));
} }

View File

@@ -15,10 +15,10 @@
*/ */
package org.springframework.data.release.issues.jira; package org.springframework.data.release.issues.jira;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
@@ -29,10 +29,10 @@ import org.springframework.data.release.model.ReleaseTrains;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class JiraVersionUnitTests { class JiraVersionUnitTests {
@Test @Test
public void rendersJiraGaVersionCorrectly() { void rendersJiraGaVersionCorrectly() {
assertIterationVersion(Iteration.M1, "1.8 M1 (Dijkstra)"); assertIterationVersion(Iteration.M1, "1.8 M1 (Dijkstra)");
assertIterationVersion(Iteration.RC1, "1.8 RC1 (Dijkstra)"); assertIterationVersion(Iteration.RC1, "1.8 RC1 (Dijkstra)");
@@ -45,30 +45,30 @@ public class JiraVersionUnitTests {
} }
@Test @Test
public void usesCustomModuleIterationStartVersion() { void usesCustomModuleIterationStartVersion() {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1); ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1);
JiraVersion version = new JiraVersion(module); JiraVersion version = new JiraVersion(module);
assertThat(version.toString(), is("1.0 M1 (Dijkstra)")); assertThat(version.toString()).isEqualTo("1.0 M1 (Dijkstra)");
} }
@Test @Test
public void doesNotUseCustomIterationOnNonFirstiterations() { void doesNotUseCustomIterationOnNonFirstiterations() {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.RC1); ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.RC1);
JiraVersion version = new JiraVersion(module); JiraVersion version = new JiraVersion(module);
assertThat(version.toString(), is("1.0 RC1 (Dijkstra)")); assertThat(version.toString()).isEqualTo("1.0 RC1 (Dijkstra)");
} }
@Test @Test
public void rendersDescriptionCorrectly() { void rendersDescriptionCorrectly() {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1); ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.ELASTICSEARCH, Iteration.M1);
JiraVersion version = new JiraVersion(module); JiraVersion version = new JiraVersion(module);
assertThat(version.getDescription(), is("Dijkstra M2")); assertThat(version.getDescription()).isEqualTo("Dijkstra M2");
} }
private void assertIterationVersion(Iteration iteration, String expected) { private void assertIterationVersion(Iteration iteration, String expected) {
@@ -76,6 +76,6 @@ public class JiraVersionUnitTests {
ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.COMMONS, iteration); ModuleIteration module = ReleaseTrains.DIJKSTRA.getModuleIteration(Projects.COMMONS, iteration);
JiraVersion version = new JiraVersion(module); JiraVersion version = new JiraVersion(module);
assertThat(version.toString(), is(expected)); assertThat(version.toString()).isEqualTo(expected);
} }
} }

View File

@@ -13,16 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.release.issues.jira; package org.springframework.data.release.issues.jira;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import static org.springframework.test.util.AssertionErrors.fail;
import java.util.Collections; import java.util.Collections;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.release.issues.Ticket; import org.springframework.data.release.issues.Ticket;
import org.springframework.data.release.issues.Tickets; import org.springframework.data.release.issues.Tickets;
import org.springframework.data.release.model.Iteration; import org.springframework.data.release.model.Iteration;
@@ -34,68 +32,68 @@ import org.springframework.data.release.model.ReleaseTrains;
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
public class TicketsUnitTests { class TicketsUnitTests {
@Test @Test
public void hasReleaseTicketShouldReturnTrue() throws Exception { void hasReleaseTicketShouldReturnTrue() {
Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(false, "", "")); Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(false, "", ""));
Tickets tickets = new Tickets(Collections.singletonList(ticket)); Tickets tickets = new Tickets(Collections.singletonList(ticket));
boolean result = tickets.hasReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); boolean result = tickets.hasReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA));
assertThat(result, is(true)); assertThat(result).isTrue();
} }
@Test @Test
public void hasReleaseTickeForTicketWithoutTrainNameShouldReturnFalse() throws Exception { void hasReleaseTickeForTicketWithoutTrainNameShouldReturnFalse() {
Ticket ticket = new Ticket("1234", "Release 1.10 GA", JiraTicketStatus.of(false, "", "")); Ticket ticket = new Ticket("1234", "Release 1.10 GA", JiraTicketStatus.of(false, "", ""));
Tickets tickets = new Tickets(Collections.singletonList(ticket)); Tickets tickets = new Tickets(Collections.singletonList(ticket));
boolean result = tickets.hasReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); boolean result = tickets.hasReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA));
assertThat(result, is(false)); assertThat(result).isFalse();
} }
@Test @Test
public void getReleaseTicketReturnsReleaseTicket() throws Exception { void getReleaseTicketReturnsReleaseTicket() {
Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(false, "", "")); Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(false, "", ""));
Tickets tickets = new Tickets(Collections.singletonList(ticket)); Tickets tickets = new Tickets(Collections.singletonList(ticket));
Ticket releaseTicket = tickets Ticket releaseTicket = tickets
.getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); .getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA));
assertThat(releaseTicket, is(ticket)); assertThat(releaseTicket).isEqualTo(ticket);
} }
@Test(expected = IllegalStateException.class) @Test
public void getReleaseTicketThrowsExceptionWithoutAReleaseTicket() throws Exception { void getReleaseTicketThrowsExceptionWithoutAReleaseTicket() {
Ticket ticket = new Ticket("1234", "Release 1.10 GA", JiraTicketStatus.of(false, "", "")); Ticket ticket = new Ticket("1234", "Release 1.10 GA", JiraTicketStatus.of(false, "", ""));
Tickets tickets = new Tickets(Collections.singletonList(ticket)); Tickets tickets = new Tickets(Collections.singletonList(ticket));
tickets.getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); assertThatIllegalArgumentException().isThrownBy(
fail("Missing IllegalStateException"); () -> tickets.getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)));
} }
@Test @Test
public void getResolvedReleaseTicket() throws Exception { void getResolvedReleaseTicket() {
Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(true, "", "")); Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(true, "", ""));
Tickets tickets = new Tickets(Collections.singletonList(ticket)); Tickets tickets = new Tickets(Collections.singletonList(ticket));
Ticket releaseTicket = tickets Ticket releaseTicket = tickets
.getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA)); .getReleaseTicket(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA));
assertThat(releaseTicket, is(ticket)); assertThat(releaseTicket).isEqualTo(ticket);
} }
@Test @Test
public void getReleaseTicketsReturnsReleaseTickets() throws Exception { void getReleaseTicketsReturnsReleaseTickets() {
Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(false, "", "")); Ticket ticket = new Ticket("1234", "Release 1.10 GA (Hopper)", JiraTicketStatus.of(false, "", ""));
Tickets tickets = new Tickets(Collections.singletonList(ticket)); Tickets tickets = new Tickets(Collections.singletonList(ticket));
Tickets result = tickets Tickets result = tickets
.getReleaseTickets(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA).getTrainIteration()); .getReleaseTickets(ReleaseTrains.HOPPER.getModuleIteration(Projects.JPA, Iteration.GA).getTrainIteration());
assertThat(result.getTickets().contains(ticket), is(true)); assertThat(result.getTickets().contains(ticket)).isTrue();
} }
} }

View File

@@ -15,113 +15,114 @@
*/ */
package org.springframework.data.release.model; package org.springframework.data.release.model;
import static org.hamcrest.Matchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.Test; import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class ArtifactVersionUnitTests { class ArtifactVersionUnitTests {
@Test(expected = IllegalArgumentException.class) @Test
public void rejectsInvalidVersionSuffix() { void rejectsInvalidVersionSuffix() {
ArtifactVersion.of("1.4.5.GA"); Assertions.assertThatIllegalArgumentException().isThrownBy(() -> ArtifactVersion.of("1.4.5.GA"));
} }
@Test @Test
public void parsesReleaseVersionCorrectly() { void parsesReleaseVersionCorrectly() {
ArtifactVersion version = ArtifactVersion.of("1.4.5.RELEASE"); ArtifactVersion version = ArtifactVersion.of("1.4.5.RELEASE");
assertThat(version.isReleaseVersion(), is(true)); assertThat(version.isReleaseVersion()).isTrue();
assertThat(version.getNextDevelopmentVersion(), is(ArtifactVersion.of("1.4.6.BUILD-SNAPSHOT"))); assertThat(version.getNextDevelopmentVersion()).isEqualTo(ArtifactVersion.of("1.4.6.BUILD-SNAPSHOT"));
} }
@Test @Test
public void createsMilestoneVersionCorrectly() { void createsMilestoneVersionCorrectly() {
ArtifactVersion version = ArtifactVersion.of("1.4.5.M1"); ArtifactVersion version = ArtifactVersion.of("1.4.5.M1");
assertThat(version.isReleaseVersion(), is(false)); assertThat(version.isReleaseVersion()).isFalse();
assertThat(version.isMilestoneVersion(), is(true)); assertThat(version.isMilestoneVersion()).isTrue();
} }
@Test @Test
public void createsReleaseVersionByDefault() { void createsReleaseVersionByDefault() {
ArtifactVersion version = ArtifactVersion.of(Version.of(1, 4, 5)); ArtifactVersion version = ArtifactVersion.of(Version.of(1, 4, 5));
assertThat(version.isReleaseVersion(), is(true)); assertThat(version.isReleaseVersion()).isTrue();
assertThat(version.toString(), is("1.4.5.RELEASE")); assertThat(version.toString()).isEqualTo("1.4.5.RELEASE");
} }
@Test @Test
public void createsMilestoneVersionFromIteration() { void createsMilestoneVersionFromIteration() {
IterationVersion oneFourMilestoneOne = new SimpleIterationVersion(Version.of(1, 4), Iteration.M1); IterationVersion oneFourMilestoneOne = new SimpleIterationVersion(Version.of(1, 4), Iteration.M1);
ArtifactVersion version = ArtifactVersion.of(oneFourMilestoneOne); ArtifactVersion version = ArtifactVersion.of(oneFourMilestoneOne);
assertThat(version.isMilestoneVersion(), is(true)); assertThat(version.isMilestoneVersion()).isTrue();
assertThat(version.toString(), is("1.4.0.M1")); assertThat(version.toString()).isEqualTo("1.4.0.M1");
} }
@Test @Test
public void createsReleaseVersionFromIteration() { void createsReleaseVersionFromIteration() {
IterationVersion oneFourGA = new SimpleIterationVersion(Version.of(1, 4), Iteration.GA); IterationVersion oneFourGA = new SimpleIterationVersion(Version.of(1, 4), Iteration.GA);
ArtifactVersion version = ArtifactVersion.of(oneFourGA); ArtifactVersion version = ArtifactVersion.of(oneFourGA);
assertThat(version.isReleaseVersion(), is(true)); assertThat(version.isReleaseVersion()).isTrue();
assertThat(version.toString(), is("1.4.0.RELEASE")); assertThat(version.toString()).isEqualTo("1.4.0.RELEASE");
} }
@Test @Test
public void createsServiceReleaseVersionFromIteration() { void createsServiceReleaseVersionFromIteration() {
IterationVersion oneFourServiceReleaseTwo = new SimpleIterationVersion(Version.of(1, 4), Iteration.SR2); IterationVersion oneFourServiceReleaseTwo = new SimpleIterationVersion(Version.of(1, 4), Iteration.SR2);
ArtifactVersion version = ArtifactVersion.of(oneFourServiceReleaseTwo); ArtifactVersion version = ArtifactVersion.of(oneFourServiceReleaseTwo);
assertThat(version.isReleaseVersion(), is(true)); assertThat(version.isReleaseVersion()).isTrue();
assertThat(version.toString(), is("1.4.2.RELEASE")); assertThat(version.toString()).isEqualTo("1.4.2.RELEASE");
} }
@Test @Test
public void returnsNextMinorSnapshotVersionForGARelease() { void returnsNextMinorSnapshotVersionForGARelease() {
ArtifactVersion version = ArtifactVersion.of("1.5.0.RELEASE").getNextDevelopmentVersion(); ArtifactVersion version = ArtifactVersion.of("1.5.0.RELEASE").getNextDevelopmentVersion();
assertThat(version.isMilestoneVersion(), is(false)); assertThat(version.isMilestoneVersion()).isFalse();
assertThat(version.isReleaseVersion(), is(false)); assertThat(version.isReleaseVersion()).isFalse();
assertThat(version, is(ArtifactVersion.of("1.6.0.BUILD-SNAPSHOT"))); assertThat(version).isEqualTo(ArtifactVersion.of("1.6.0.BUILD-SNAPSHOT"));
} }
@Test @Test
public void ordersCorrectly() { void ordersCorrectly() {
ArtifactVersion oneNine = ArtifactVersion.of("1.9.0.RELEASE"); ArtifactVersion oneNine = ArtifactVersion.of("1.9.0.RELEASE");
ArtifactVersion oneTen = ArtifactVersion.of("1.10.0.RELEASE"); ArtifactVersion oneTen = ArtifactVersion.of("1.10.0.RELEASE");
assertThat(oneNine.compareTo(oneTen), is(lessThan(0))); assertThat(oneNine.compareTo(oneTen)).isLessThan(0);
} }
@Test @Test
public void ordersSnapshotsOfSameVersionSmaller() { void ordersSnapshotsOfSameVersionSmaller() {
ArtifactVersion oneTenRelease = ArtifactVersion.of("1.10.0.RELEASE"); ArtifactVersion oneTenRelease = ArtifactVersion.of("1.10.0.RELEASE");
ArtifactVersion oneTenSnapshot = ArtifactVersion.of("1.10.0.BUILD-SNAPSHOT"); ArtifactVersion oneTenSnapshot = ArtifactVersion.of("1.10.0.BUILD-SNAPSHOT");
assertThat(oneTenRelease.compareTo(oneTenSnapshot), is(greaterThan(0))); assertThat(oneTenRelease.compareTo(oneTenSnapshot)).isGreaterThan(0);
} }
@Test @Test
public void returnsCorrectBugfixVersions() { void returnsCorrectBugfixVersions() {
assertThat(ArtifactVersion.of("1.0.0.RELEASE").getNextBugfixVersion(), assertThat(ArtifactVersion.of("1.0.0.RELEASE").getNextBugfixVersion())
is(ArtifactVersion.of("1.0.1.BUILD-SNAPSHOT"))); .isEqualTo(ArtifactVersion.of("1.0.1.BUILD-SNAPSHOT"));
assertThat(ArtifactVersion.of("1.0.0.M1").getNextBugfixVersion(), is(ArtifactVersion.of("1.0.0.BUILD-SNAPSHOT"))); assertThat(ArtifactVersion.of("1.0.0.M1").getNextBugfixVersion())
assertThat(ArtifactVersion.of("1.0.1.RELEASE").getNextBugfixVersion(), .isEqualTo(ArtifactVersion.of("1.0.0.BUILD-SNAPSHOT"));
is(ArtifactVersion.of("1.0.2.BUILD-SNAPSHOT"))); assertThat(ArtifactVersion.of("1.0.1.RELEASE").getNextBugfixVersion())
.isEqualTo(ArtifactVersion.of("1.0.2.BUILD-SNAPSHOT"));
} }
} }

View File

@@ -17,17 +17,17 @@ package org.springframework.data.release.model;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Unit tests for {@link Calver}. * Unit tests for {@link Calver}.
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
public class CalverVersionUnitTests { class CalverVersionUnitTests {
@Test @Test
public void shouldParseRelease() { void shouldParseRelease() {
Calver version = Calver.parse("2020.0.1"); Calver version = Calver.parse("2020.0.1");
@@ -37,7 +37,7 @@ public class CalverVersionUnitTests {
} }
@Test @Test
public void shouldParseM1Release() { void shouldParseM1Release() {
Calver version = Calver.parse("2020.0.1-M1"); Calver version = Calver.parse("2020.0.1-M1");
@@ -48,7 +48,7 @@ public class CalverVersionUnitTests {
} }
@Test @Test
public void shouldCompareReleasesCorrectly() { void shouldCompareReleasesCorrectly() {
Calver version = Calver.parse("2020.0.1-RC2"); Calver version = Calver.parse("2020.0.1-RC2");
@@ -66,7 +66,7 @@ public class CalverVersionUnitTests {
} }
@Test @Test
public void shouldParseSnapshot() { void shouldParseSnapshot() {
Calver version = Calver.parse("2020.0.1-SNAPSHOT"); Calver version = Calver.parse("2020.0.1-SNAPSHOT");

View File

@@ -17,17 +17,17 @@ package org.springframework.data.release.model;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Unit tests for {@link Iteration}. * Unit tests for {@link Iteration}.
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
public class IterationUnitTests { class IterationUnitTests {
@Test @Test
public void shouldCompareMilestoneIterationsCorrectly() { void shouldCompareMilestoneIterationsCorrectly() {
assertThat(Iteration.M1).isEqualByComparingTo(Iteration.M1); assertThat(Iteration.M1).isEqualByComparingTo(Iteration.M1);
assertThat(Iteration.M1).isLessThan(Iteration.RC1); assertThat(Iteration.M1).isLessThan(Iteration.RC1);
@@ -39,7 +39,7 @@ public class IterationUnitTests {
} }
@Test @Test
public void shouldCompareReleaseCandidateIterationsCorrectly() { void shouldCompareReleaseCandidateIterationsCorrectly() {
assertThat(Iteration.RC1).isGreaterThan(Iteration.M1); assertThat(Iteration.RC1).isGreaterThan(Iteration.M1);
assertThat(Iteration.RC1).isEqualByComparingTo(Iteration.RC1); assertThat(Iteration.RC1).isEqualByComparingTo(Iteration.RC1);
@@ -51,7 +51,7 @@ public class IterationUnitTests {
} }
@Test @Test
public void shouldCompareGAIterationsCorrectly() { void shouldCompareGAIterationsCorrectly() {
assertThat(Iteration.GA).isGreaterThan(Iteration.M1); assertThat(Iteration.GA).isGreaterThan(Iteration.M1);
assertThat(Iteration.GA).isGreaterThan(Iteration.RC1); assertThat(Iteration.GA).isGreaterThan(Iteration.RC1);
@@ -60,7 +60,7 @@ public class IterationUnitTests {
} }
@Test @Test
public void shouldCompareServiceReleaseIterationsCorrectly() { void shouldCompareServiceReleaseIterationsCorrectly() {
assertThat(Iteration.SR1).isGreaterThan(Iteration.M1); assertThat(Iteration.SR1).isGreaterThan(Iteration.M1);
assertThat(Iteration.SR1).isGreaterThan(Iteration.RC1); assertThat(Iteration.SR1).isGreaterThan(Iteration.RC1);

View File

@@ -15,35 +15,34 @@
*/ */
package org.springframework.data.release.model; package org.springframework.data.release.model;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class ModuleIterationUnitTests { class ModuleIterationUnitTests {
@Test @Test
public void abbreviatesTrailingZerosForNonServiceReleases() { void abbreviatesTrailingZerosForNonServiceReleases() {
TrainIteration iteration = new TrainIteration(ReleaseTrains.DIJKSTRA, Iteration.M1); TrainIteration iteration = new TrainIteration(ReleaseTrains.DIJKSTRA, Iteration.M1);
ModuleIteration module = iteration.getModule(Projects.JPA); ModuleIteration module = iteration.getModule(Projects.JPA);
assertThat(module.getShortVersionString(), is("1.6 M1")); assertThat(module.getShortVersionString()).isEqualTo("1.6 M1");
assertThat(module.getMediumVersionString(), is("1.6 M1 (Dijkstra)")); assertThat(module.getMediumVersionString()).isEqualTo("1.6 M1 (Dijkstra)");
assertThat(module.getFullVersionString(), is("1.6.0.M1 (Dijkstra M1)")); assertThat(module.getFullVersionString()).isEqualTo("1.6.0.M1 (Dijkstra M1)");
} }
@Test @Test
public void doesNotListIterationSuffixForServiceReleases() { void doesNotListIterationSuffixForServiceReleases() {
TrainIteration iteration = new TrainIteration(ReleaseTrains.DIJKSTRA, Iteration.SR1); TrainIteration iteration = new TrainIteration(ReleaseTrains.DIJKSTRA, Iteration.SR1);
ModuleIteration module = iteration.getModule(Projects.JPA); ModuleIteration module = iteration.getModule(Projects.JPA);
assertThat(module.getShortVersionString(), is("1.6.1")); assertThat(module.getShortVersionString()).isEqualTo("1.6.1");
assertThat(module.getMediumVersionString(), is("1.6.1 (Dijkstra SR1)")); assertThat(module.getMediumVersionString()).isEqualTo("1.6.1 (Dijkstra SR1)");
assertThat(module.getFullVersionString(), is("1.6.1.RELEASE (Dijkstra SR1)")); assertThat(module.getFullVersionString()).isEqualTo("1.6.1.RELEASE (Dijkstra SR1)");
} }
} }

View File

@@ -15,22 +15,20 @@
*/ */
package org.springframework.data.release.model; package org.springframework.data.release.model;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.*;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class ProjectUnitTests { class ProjectUnitTests {
@Test @Test
public void testname() { void testname() {
List<Project> projects = new ArrayList<>(Projects.PROJECTS); List<Project> projects = new ArrayList<>(Projects.PROJECTS);
// Collections.reverse(projects); // Collections.reverse(projects);
@@ -38,27 +36,27 @@ public class ProjectUnitTests {
projects.stream().map(Project::getName).forEach(System.out::println); projects.stream().map(Project::getName).forEach(System.out::println);
assertThat(projects.get(0), is(Projects.BUILD)); assertThat(projects.get(0)).isEqualTo(Projects.BUILD);
assertThat(projects.get(1), is(Projects.COMMONS)); assertThat(projects.get(1)).isEqualTo(Projects.COMMONS);
} }
/** /**
* @see #28 * @see #28
*/ */
@Test @Test
public void findsProjectByKey() { void findsProjectByKey() {
assertThat(Projects.requiredByName("DATACMNS"), is(Projects.COMMONS)); assertThat(Projects.requiredByName("DATACMNS")).isEqualTo(Projects.COMMONS);
} }
@Test @Test
public void returnsCustomFullNameIfSet() { void returnsCustomFullNameIfSet() {
assertThat(Projects.BUILD.getFullName(), is("Spring Data Build")); assertThat(Projects.BUILD.getFullName()).isEqualTo("Spring Data Build");
assertThat(Projects.CASSANDRA.getFullName(), is("Spring Data for Apache Cassandra")); assertThat(Projects.CASSANDRA.getFullName()).isEqualTo("Spring Data for Apache Cassandra");
} }
@Test @Test
public void returnsAllDependencies() { void returnsAllDependencies() {
assertThat(Projects.REDIS.getDependencies())// assertThat(Projects.REDIS.getDependencies())//
.contains(Projects.COMMONS, Projects.KEY_VALUE, Projects.BUILD); .contains(Projects.COMMONS, Projects.KEY_VALUE, Projects.BUILD);

View File

@@ -16,47 +16,45 @@
package org.springframework.data.release.model; package org.springframework.data.release.model;
import static org.hamcrest.core.Is.*; import static org.assertj.core.api.Assertions.*;
import static org.hamcrest.core.IsEqual.*;
import static org.junit.Assert.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* @author Mark Paluch * @author Mark Paluch
*/ */
public class TrackerTest { class TrackerTest {
@Test @Test
public void testMatchesTicketNumber() throws Exception { void testMatchesTicketNumber() throws Exception {
Pattern pattern = Pattern.compile(Tracker.JIRA.getTicketPattern()); Pattern pattern = Pattern.compile(Tracker.JIRA.getTicketPattern());
Matcher matcher = pattern.matcher("DATAREDIS-1"); Matcher matcher = pattern.matcher("DATAREDIS-1");
matcher.find(); matcher.find();
assertThat(matcher.group(1), is(equalTo("DATAREDIS-1"))); assertThat(matcher.group(1)).isEqualTo("DATAREDIS-1");
} }
@Test @Test
public void testMatchesBranchNamedLikeTicket() throws Exception { void testMatchesBranchNamedLikeTicket() throws Exception {
Pattern pattern = Pattern.compile(Tracker.JIRA.getTicketPattern()); Pattern pattern = Pattern.compile(Tracker.JIRA.getTicketPattern());
Matcher matcher = pattern.matcher("issues/DATAREDIS-1-dummy"); Matcher matcher = pattern.matcher("issues/DATAREDIS-1-dummy");
matcher.find(); matcher.find();
assertThat(matcher.group(1), is(equalTo("DATAREDIS-1"))); assertThat(matcher.group(1)).isEqualTo("DATAREDIS-1");
} }
@Test @Test
public void testVersionBranch() throws Exception { void testVersionBranch() throws Exception {
Pattern pattern = Pattern.compile(Tracker.GITHUB.getTicketPattern()); Pattern pattern = Pattern.compile(Tracker.GITHUB.getTicketPattern());
Matcher matcher = pattern.matcher("1.2.x"); Matcher matcher = pattern.matcher("1.2.x");
matcher.find(); matcher.find();
assertThat(matcher.group(1), is(equalTo("1"))); assertThat(matcher.group(1)).isEqualTo("1");
} }
} }

View File

@@ -15,28 +15,27 @@
*/ */
package org.springframework.data.release.model; package org.springframework.data.release.model;
import static org.hamcrest.CoreMatchers.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Unit tests for release {@link Train}s. * Unit tests for release {@link Train}s.
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class TrainsUnitTest { class TrainsUnitTest {
@Test @Test
public void prefersNewVersionOfAdditionalModule() { void prefersNewVersionOfAdditionalModule() {
Module module = ReleaseTrains.HOPPER.getModule(Projects.NEO4J); Module module = ReleaseTrains.HOPPER.getModule(Projects.NEO4J);
assertThat(module.getVersion(), is(Version.parse("4.1"))); assertThat(module.getVersion()).isEqualTo(Version.parse("4.1"));
} }
@Test @Test
public void addsNewlyAddedModule() { void addsNewlyAddedModule() {
assertThat(ReleaseTrains.HOPPER.getModule(Projects.ENVERS), is(notNullValue())); assertThat(ReleaseTrains.HOPPER.getModule(Projects.ENVERS)).isNotNull();
} }
} }

View File

@@ -17,7 +17,7 @@ package org.springframework.data.release.sagan;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
import org.springframework.data.release.model.ReleaseTrains; import org.springframework.data.release.model.ReleaseTrains;
@@ -27,10 +27,10 @@ import org.springframework.data.release.model.ReleaseTrains;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class MaintainedVersionUnitTests { class MaintainedVersionUnitTests {
@Test @Test
public void newerVersionIsOrderedFirst() { void newerVersionIsOrderedFirst() {
MaintainedVersion ingalls = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.13.0.RELEASE"), MaintainedVersion ingalls = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.13.0.RELEASE"),
ReleaseTrains.INGALLS); ReleaseTrains.INGALLS);

View File

@@ -17,7 +17,7 @@ package org.springframework.data.release.sagan;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
import org.springframework.data.release.model.ReleaseTrains; import org.springframework.data.release.model.ReleaseTrains;
@@ -27,10 +27,10 @@ import org.springframework.data.release.model.ReleaseTrains;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class MaintainedVersionsUnitTests { class MaintainedVersionsUnitTests {
@Test @Test
public void considersMostRecentReleaseVersionTheMainOne() { void considersMostRecentReleaseVersionTheMainOne() {
MaintainedVersion ingalls = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.13.0.RELEASE"), MaintainedVersion ingalls = MaintainedVersion.of(Projects.COMMONS, ArtifactVersion.of("1.13.0.RELEASE"),
ReleaseTrains.INGALLS); ReleaseTrains.INGALLS);

View File

@@ -15,7 +15,7 @@
*/ */
package org.springframework.data.release.sagan; package org.springframework.data.release.sagan;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
import org.springframework.data.release.model.ReleaseTrains; import org.springframework.data.release.model.ReleaseTrains;
@@ -28,10 +28,10 @@ import com.fasterxml.jackson.databind.ObjectWriter;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public class ProjectMetadataSerializationTests { class ProjectMetadataSerializationTests {
@Test @Test
public void serializesMaintainedVersionsIntoProjectMetadata() throws Exception { void serializesMaintainedVersionsIntoProjectMetadata() throws Exception {
ObjectWriter mapper = new ObjectMapper().writerWithDefaultPrettyPrinter(); ObjectWriter mapper = new ObjectMapper().writerWithDefaultPrettyPrinter();

View File

@@ -15,8 +15,9 @@
*/ */
package org.springframework.data.release.sagan; package org.springframework.data.release.sagan;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
@@ -27,14 +28,14 @@ import org.springframework.data.release.model.ReleaseTrains;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@Ignore("I will write to production systems") @Disabled("I will write to production systems")
public class SaganOperationsIntegrationTests extends AbstractIntegrationTests { class SaganOperationsIntegrationTests extends AbstractIntegrationTests {
@Autowired SaganOperations sagan; @Autowired SaganOperations sagan;
@Autowired SaganClient client; @Autowired SaganClient client;
@Test @Test
public void detectVersionsToUpdate() { void detectVersionsToUpdate() {
sagan.findVersions(ReleaseTrains.LOVELACE, ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER) sagan.findVersions(ReleaseTrains.LOVELACE, ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER)
.forEach((project, versions) -> { .forEach((project, versions) -> {
@@ -53,12 +54,12 @@ public class SaganOperationsIntegrationTests extends AbstractIntegrationTests {
} }
@Test @Test
public void updateVersions() { void updateVersions() {
sagan.updateProjectMetadata(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER); sagan.updateProjectMetadata(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER);
} }
@Test @Test
public void updateJpa() { void updateJpa() {
MaintainedVersions versions = sagan.findVersions(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER) MaintainedVersions versions = sagan.findVersions(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER)
.get(Projects.JPA); .get(Projects.JPA);
@@ -69,12 +70,12 @@ public class SaganOperationsIntegrationTests extends AbstractIntegrationTests {
} }
@Test @Test
public void getJpa() { void getJpa() {
System.out.println(client.getProjectMetadata(Projects.JPA)); System.out.println(client.getProjectMetadata(Projects.JPA));
} }
@Test @Test
public void updateBuild() { void updateBuild() {
MaintainedVersions versions = sagan.findVersions(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER) MaintainedVersions versions = sagan.findVersions(ReleaseTrains.KAY, ReleaseTrains.INGALLS, ReleaseTrains.HOPPER)
.get(Projects.BUILD); .get(Projects.BUILD);