From 66595dc007006d82150a6d46b2fbe96b3074e410 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 26 Jan 2024 12:53:12 +0100 Subject: [PATCH] Remove SCM parameter, since this value should be stored in factory. --- .../forensics/delta/DeltaCalculator.java | 21 +++++++++++++++++++ .../delta/DeltaCalculatorFactoryITest.java | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/forensics/delta/DeltaCalculator.java b/src/main/java/io/jenkins/plugins/forensics/delta/DeltaCalculator.java index 1672b879..a6bfa7d3 100644 --- a/src/main/java/io/jenkins/plugins/forensics/delta/DeltaCalculator.java +++ b/src/main/java/io/jenkins/plugins/forensics/delta/DeltaCalculator.java @@ -3,6 +3,8 @@ import java.io.Serializable; import java.util.Optional; +import org.apache.commons.lang3.StringUtils; + import edu.hm.hafner.util.FilteredLog; import hudson.model.Run; @@ -15,6 +17,23 @@ public abstract class DeltaCalculator implements Serializable { private static final long serialVersionUID = 8641535877389921937L; + /** + * Calculates the {@link Delta} between two passed Jenkins builds. + * + * @param build + * the currently processed build + * @param referenceBuild + * The reference build + * @param logger + * The used log + * + * @return the delta if it could be calculated + */ + public Optional calculateDelta(final Run build, final Run referenceBuild, + final FilteredLog logger) { + return calculateDelta(build, referenceBuild, StringUtils.EMPTY, logger); + } + /** * Calculates the {@link Delta} between two passed Jenkins builds. * @@ -28,7 +47,9 @@ public abstract class DeltaCalculator implements Serializable { * The used log * * @return the delta if it could be calculated + * @deprecated use {@link #calculateDelta(Run, Run, FilteredLog)} instead */ + @Deprecated public abstract Optional calculateDelta(Run build, Run referenceBuild, String scmKeyFilter, FilteredLog logger); diff --git a/src/test/java/io/jenkins/plugins/forensics/delta/DeltaCalculatorFactoryITest.java b/src/test/java/io/jenkins/plugins/forensics/delta/DeltaCalculatorFactoryITest.java index 0196821b..48858d6e 100644 --- a/src/test/java/io/jenkins/plugins/forensics/delta/DeltaCalculatorFactoryITest.java +++ b/src/test/java/io/jenkins/plugins/forensics/delta/DeltaCalculatorFactoryITest.java @@ -38,7 +38,7 @@ void shouldSelectNullDeltaCalculatorIfNoCalculatorIsFound() { DeltaCalculator nullCalculator = createDeltaCalculator("/", log); assertThat(nullCalculator).isInstanceOf(NullDeltaCalculator.class); - assertThat(nullCalculator.calculateDelta(mock(Run.class), mock(Run.class), "", log)).isEmpty(); + assertThat(nullCalculator.calculateDelta(mock(Run.class), mock(Run.class), log)).isEmpty(); assertThat(log.getInfoMessages()).containsOnly(NO_SUITABLE_DELTA_CALCULATOR_FOUND, ACTUAL_FACTORY_NULL_DELTA_CALCULATOR, EMPTY_FACTORY_NULL_DELTA_CALCULATOR); assertThat(log.getErrorMessages()).isEmpty();