Add test for null originalVersion

This commit is contained in:
Oleg Zhurakousky
2022-01-27 13:06:20 +01:00
parent 42d8736d19
commit 513866390e
2 changed files with 29 additions and 6 deletions

View File

@@ -16,6 +16,8 @@
package releaser.reactor;
import static org.junit.jupiter.api.Assertions.fail;
import org.assertj.core.api.BDDAssertions;
import org.junit.jupiter.api.Test;
import org.mockito.BDDMockito;
@@ -53,6 +55,26 @@ class RestartSiteProjectPostReleaseTaskTests {
.restartApp(BDDMockito.eq("projectreactor"));
}
@Test
void should_fail_if_original_version_is_null() {
ProjectToRun p = new ProjectToRun(null,
new ProjectsFromBom(new Projects(), new ProjectVersion("foo", "1.0.0")),
null, new ReleaserProperties(),
BDDMockito.mock(Options.class)) {
@Override
public String name() {
return "reactor-core";
}
};
try {
Arguments.forProject(p);
fail();
}
catch (Exception e) {
// success
}
}
@Test
void should_not_update_the_website_if_project_not_reactor_core() {
Arguments arguments = Arguments.forProject(nonReactorCoreProject());

View File

@@ -82,13 +82,13 @@ public final class Arguments implements Serializable {
private Arguments(ProjectToRun thisProject, Projects projects,
ProjectVersion currentProjectFromBom) {
log.info("Creating Arguments for: " + thisProject.name() + "; Original version: "
+ thisProject.originalVersion);
this.project = thisProject.thisProjectFolder;
this.projects = projects;
this.originalVersion = thisProject.originalVersion;
log.info("Creating Arguments for: " + thisProject.name() + "; Original version: "
+ this.originalVersion);
Assert.isTrue(this.originalVersion != null,
"Original Version must not be empty for project: " + thisProject.name());
"Original Version must not be null for project: " + thisProject.name());
this.versionFromBom = currentProjectFromBom;
this.properties = thisProject.thisProjectReleaserProperties;
this.options = thisProject.options;
@@ -101,14 +101,15 @@ public final class Arguments implements Serializable {
// in this case the project will be the BOM
private Arguments(ProjectToRun thisProject,
List<ProcessedProject> processedProjects) {
log.info("Creating Arguments for: " + thisProject.name() + "; Original version: "
+ thisProject.originalVersion);
this.project = thisProject.thisProjectFolder;
this.projects = new Projects(processedProjects.stream()
.map(p -> p.newProjectVersion).collect(Collectors.toSet()));
this.originalVersion = thisProject.originalVersion;
log.info("Creating Arguments for: " + thisProject.name() + "; Original version: "
+ this.originalVersion);
Assert.isTrue(this.originalVersion != null,
"Original Version must not be empty for project: " + thisProject.name());
"Original Version must not be null for project: " + thisProject.name());
this.versionFromBom = thisProject.thisProjectVersionFromBom;
this.properties = thisProject.thisProjectReleaserProperties;
this.options = thisProject.options;