This commit is contained in:
Marcin Grzejszczak
2018-11-18 12:22:19 +01:00
parent a98207e100
commit e0da24bc1a
31 changed files with 152 additions and 196 deletions

View File

@@ -50,10 +50,10 @@ class Task {
if (interactive) {
boolean skipStep = stepSkipper.skipStep();
if (!skipStep) {
consumer.accept(args);
this.consumer.accept(args);
}
} else {
consumer.accept(args);
this.consumer.accept(args);
}
} catch (Exception e) {
log.error("\n\n\nBUILD FAILED!!!\n\nException occurred for task <" +
@@ -63,6 +63,6 @@ class Task {
}
private void printLog(boolean interactive) {
log.info("\n\n\n=== {} ===\n\n{} {}\n\n", header, description, interactive ? MSG : "");
log.info("\n\n\n=== {} ===\n\n{} {}\n\n", this.header, this.description, interactive ? MSG : "");
}
}

View File

@@ -1,8 +1,5 @@
package org.springframework.cloud.release.internal.spring;
import static org.assertj.core.api.BDDAssertions.then;
import static org.mockito.Matchers.anyString;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
@@ -28,6 +25,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.BDDMockito;
import org.mockito.Mockito;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.cloud.release.internal.Releaser;
import org.springframework.cloud.release.internal.ReleaserProperties;
@@ -49,11 +47,13 @@ import org.springframework.cloud.release.internal.sagan.Project;
import org.springframework.cloud.release.internal.sagan.Release;
import org.springframework.cloud.release.internal.sagan.SaganClient;
import org.springframework.cloud.release.internal.sagan.SaganUpdater;
import org.springframework.cloud.release.internal.template.ReleaseNotesTemplateGeneratorCacheClearer;
import org.springframework.cloud.release.internal.template.TemplateGenerator;
import org.springframework.context.ApplicationContext;
import org.springframework.util.FileSystemUtils;
import static org.assertj.core.api.BDDAssertions.then;
import static org.mockito.Matchers.anyString;
/**
* @author Marcin Grzejszczak
*/
@@ -86,7 +86,6 @@ public class AcceptanceTests {
BDDMockito.given(this.saganClient.getProject(anyString()))
.willReturn(newProject());
Task.stepSkipper = () -> false;
ReleaseNotesTemplateGeneratorCacheClearer.clear();
}
@After
@@ -138,7 +137,7 @@ public class AcceptanceTests {
this.releaserProperties.getGit().setFetchVersionsFromGit(false);
this.releaserProperties.getFixedVersions().put("spring-cloud-release", "Finchley.RELEASE");
this.releaserProperties.getFixedVersions().put("spring-cloud-consul", "2.3.4.RELEASE");
File temporaryDestination = tmp.newFolder();
File temporaryDestination = this.tmp.newFolder();
this.releaserProperties.getGit().setCloneDestinationDir(temporaryDestination.getAbsolutePath());
releaser.release();
@@ -265,7 +264,7 @@ public class AcceptanceTests {
}
private void thenSaganWasCalled() {
BDDMockito.then(saganUpdater).should(BDDMockito.atLeastOnce())
BDDMockito.then(this.saganUpdater).should(BDDMockito.atLeastOnce())
.updateSagan(BDDMockito.anyString(),
BDDMockito.any(ProjectVersion.class), BDDMockito
.any(ProjectVersion.class));
@@ -277,7 +276,7 @@ public class AcceptanceTests {
.forEach(project -> {
then(Arrays.asList("spring-cloud-starter-build",
"spring-cloud-consul")).contains(pom(project).getArtifactId());
then(capture.toString()).contains("executed_build", "executed_deploy", "executed_docs");
then(this.capture.toString()).contains("executed_build", "executed_deploy", "executed_docs");
});
}
@@ -290,7 +289,7 @@ public class AcceptanceTests {
this.releaserProperties.getMetaRelease().getProjectsToSkip().add("spring-cloud-release");
this.releaserProperties.getMetaRelease().getProjectsToSkip().add("spring-cloud-consul");
this.releaserProperties.getGit().setUpdateReleaseTrainWiki(false);
File temporaryDestination = tmp.newFolder();
File temporaryDestination = this.tmp.newFolder();
this.releaserProperties.getGit().setCloneDestinationDir(temporaryDestination.getAbsolutePath());
releaser.release(new OptionsBuilder().metaRelease(true).options());
@@ -317,7 +316,7 @@ public class AcceptanceTests {
.stream().filter(file -> file.getName().equals("spring-cloud-consul"))
.forEach(project -> {
then(pom(project).getArtifactId()).isEqualTo("spring-cloud-consul");
then(capture.toString()).contains("executed_build", "executed_deploy", "executed_docs");
then(this.capture.toString()).contains("executed_build", "executed_deploy", "executed_docs");
});
thenSaganWasCalled();
thenDocumentationWasUpdated();
@@ -344,7 +343,7 @@ public class AcceptanceTests {
.forEach(project -> {
then(Collections.singletonList("spring-cloud-consul"))
.contains(pom(project).getArtifactId());
then(capture.toString()).contains("executed_build", "executed_deploy",
then(this.capture.toString()).contains("executed_build", "executed_deploy",
"executed_docs");
});
thenSaganWasCalled();
@@ -353,13 +352,13 @@ public class AcceptanceTests {
}
private void thenDocumentationWasUpdated() {
BDDMockito.then(documentationUpdater).should()
BDDMockito.then(this.documentationUpdater).should()
.updateDocsRepo(BDDMockito.any(ProjectVersion.class), BDDMockito
.anyString());
}
private void thenWikiPageWasUpdated() {
BDDMockito.then(documentationUpdater).should()
BDDMockito.then(this.documentationUpdater).should()
.updateReleaseTrainWiki(BDDMockito.any(Projects.class));
}
@@ -582,7 +581,7 @@ public class AcceptanceTests {
options.interactive = false;
super.postReleaseOptions(options, defaultArgs);
}
}, updater);
}, this.updater);
}
private SpringReleaser metaReleaserWithFullDeployment(ReleaserProperties properties) throws Exception {
@@ -596,7 +595,7 @@ public class AcceptanceTests {
options.interactive = false;
super.postReleaseOptions(options, defaultArgs);
}
}, updater);
}, this.updater);
}
private SpringReleaser releaserWithSnapshotScRelease(File projectFile, String projectName,
@@ -617,7 +616,7 @@ public class AcceptanceTests {
options.interactive = true;
super.postReleaseOptions(options, defaultArgs);
}
}, updater);
}, this.updater);
}
private Releaser defaultReleaser(String expectedVersion, String projectName,
@@ -628,19 +627,19 @@ public class AcceptanceTests {
expectedVersion, projectName);
TemplateGenerator templateGenerator = new TemplateGenerator(properties, handler);
GradleUpdater gradleUpdater = new GradleUpdater(properties);
SaganUpdater saganUpdater = new SaganUpdater(this.saganClient, releaserProperties);
SaganUpdater saganUpdater = new SaganUpdater(this.saganClient, this.releaserProperties);
DocumentationUpdater documentationUpdater = new TestDocumentationUpdater(properties,
new TestDocumentationUpdater.TestProjectDocumentationUpdater(properties, handler, "Brixton.SR1"),
new TestDocumentationUpdater.TestReleaseContentsUpdater(properties, handler, templateGenerator)) {
@Override public File updateDocsRepo(ProjectVersion currentProject,
String springCloudReleaseBranch) {
File file = super.updateDocsRepo(currentProject, springCloudReleaseBranch);
documentationFolder = file;
AcceptanceTests.this.documentationFolder = file;
return file;
}
};
Releaser releaser = new Releaser(pomUpdater, projectBuilder, handler,
templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, postReleaseActions);
templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, this.postReleaseActions);
this.gitHandler = handler;
return releaser;
}
@@ -651,26 +650,26 @@ public class AcceptanceTests {
NonAssertingTestProjectGitHandler handler = new NonAssertingTestProjectGitHandler(properties);
TemplateGenerator templateGenerator = Mockito.spy(new TemplateGenerator(properties, handler));
GradleUpdater gradleUpdater = new GradleUpdater(properties);
SaganUpdater saganUpdater = Mockito.spy(new SaganUpdater(this.saganClient, releaserProperties));
SaganUpdater saganUpdater = Mockito.spy(new SaganUpdater(this.saganClient, this.releaserProperties));
DocumentationUpdater documentationUpdater = Mockito.spy(new TestDocumentationUpdater(properties,
new TestDocumentationUpdater.TestProjectDocumentationUpdater(properties, handler, "Brixton.SR1"),
new TestDocumentationUpdater.TestReleaseContentsUpdater(properties, handler, templateGenerator) {
@Override
public File updateProjectRepo(Projects projects) {
File file = super.updateProjectRepo(projects);
cloudProjectFolder = file;
AcceptanceTests.this.cloudProjectFolder = file;
return file;
}
}) {
@Override public File updateDocsRepo(ProjectVersion currentProject,
String springCloudReleaseBranch) {
File file = super.updateDocsRepo(currentProject, springCloudReleaseBranch);
documentationFolder = file;
AcceptanceTests.this.documentationFolder = file;
return file;
}
});
Releaser releaser = Mockito.spy(new Releaser(pomUpdater, projectBuilder, handler,
templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, postReleaseActions));
templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, this.postReleaseActions));
this.nonAssertingGitHandler = handler;
this.templateGenerator = templateGenerator;
this.saganUpdater = saganUpdater;

View File

@@ -29,11 +29,11 @@ public class OptionsProcessorTests {
FirstConsumer first = new FirstConsumer();
SecondConsumer second = new SecondConsumer();
ThirdConsumer third = new ThirdConsumer();
Task firstTask = task("first", "1", "", "", first);
Task firstTask = task("first", "1", "", "", this.first);
List<Task> tasks = Arrays.asList(new Task[] {
firstTask,
task("second", "2", "", "", second),
task("third", "3", "", "", third)
this.firstTask,
task("second", "2", "", "", this.second),
task("third", "3", "", "", this.third)
});
OptionsProcessor optionsProcessor;
@@ -214,7 +214,7 @@ public class OptionsProcessorTests {
public void should_execute_full_release() throws Exception {
this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks) {
@Override Task releaseTask() {
return firstTask;
return OptionsProcessorTests.this.firstTask;
}
@Override String chosenOption() {
@@ -234,7 +234,7 @@ public class OptionsProcessorTests {
public void should_execute_full_verbose_release() throws Exception {
this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks) {
@Override Task releaseVerboseTask() {
return firstTask;
return OptionsProcessorTests.this.firstTask;
}
@Override String chosenOption() {

View File

@@ -62,7 +62,7 @@ public class SpringReleaserTests {
if (this.counter == 0) {
log.info("First run");
this.counter = this.counter + 1;
return releaserUpdater;
return SpringReleaserTests.this.releaserUpdater;
}
log.info("Second run");
return new File("does/not/exist");

View File

@@ -1,11 +0,0 @@
package org.springframework.cloud.release.internal.template;
/**
* @author Marcin Grzejszczak
*/
public class ReleaseNotesTemplateGeneratorCacheClearer {
public static void clear() {
ReleaseNotesTemplateGenerator.CACHE.clear();
}
}