Skip to content

Commit a83e788

Browse files
Fixing failed unit tests which were trying to mock a static function (#303)
1 parent ea075c4 commit a83e788

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

components/sbm-core/src/main/java/org/springframework/sbm/engine/git/GitSupport.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public Commit commit(File repo, String message) {
107107
*
108108
* @param repo the location of the repo
109109
*/
110-
public static Optional<Commit> getLatestCommit(File repo) {
110+
public Optional<Commit> getLatestCommit(File repo) {
111111
try {
112112
Git git = getRepository(repo);
113113
Iterable<RevCommit> revCommits = git.log()

components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/recipes/Boot_24_25_UpgradeReportRecipeTest.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515
*/
1616
package org.springframework.sbm.boot.upgrade_24_25.recipes;
1717

18-
import org.springframework.sbm.engine.git.Commit;
1918
import org.springframework.sbm.engine.git.GitSupport;
19+
import org.springframework.sbm.project.resource.SbmApplicationProperties;
2020
import org.springframework.sbm.test.RecipeIntegrationTestSupport;
2121
import org.jetbrains.annotations.NotNull;
2222
import org.junit.jupiter.api.Tag;
2323
import org.junit.jupiter.api.Test;
2424
import org.springframework.core.io.ClassPathResource;
25-
26-
import java.io.File;
2725
import java.io.IOException;
2826
import java.nio.charset.Charset;
2927
import java.nio.charset.StandardCharsets;
@@ -47,7 +45,8 @@ void generateReportTest() throws IOException {
4745
Path resultDir = RecipeIntegrationTestSupport.getResultDir(applicationDir);
4846
String generatedReportContent = replaceDynamicPartsInReport(resultDir.resolve("Upgrade-Spring-Boot-2.4-to-2.5.html"), resultDir);
4947

50-
String revision = GitSupport.getLatestCommit(resultDir.toAbsolutePath().toFile()).get().getHash();
48+
GitSupport gitSupport = new GitSupport(new SbmApplicationProperties());
49+
String revision = gitSupport.getLatestCommit(resultDir.toAbsolutePath().toFile()).get().getHash();
5150

5251
String expectedReport =
5352
getContent(new ClassPathResource("/expected-report").getFile().toPath())
@@ -70,5 +69,4 @@ private String getContent(Path report) throws IOException {
7069
Charset charset = StandardCharsets.UTF_8;
7170
return new String(Files.readAllBytes(report), charset).replaceAll("\n$", "");
7271
}
73-
7472
}

0 commit comments

Comments
 (0)