package org.sonar.ce.task.projectanalysis.step;
+import java.util.OptionalInt;
import javax.annotation.Nullable;
import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
import org.sonar.ce.task.projectanalysis.view.TriggerViewRefreshDelegate;
@Override
public void execute(ComputationStep.Context context) {
if (triggerViewRefreshDelegate != null) {
- triggerViewRefreshDelegate.accept(analysisMetadata.getProject());
+ OptionalInt count = triggerViewRefreshDelegate.triggerFrom(analysisMetadata.getProject());
+ count.ifPresent(i -> context.getStatistics().add("refreshes", i));
}
}
}
package org.sonar.ce.task.projectanalysis.view;
-import java.util.function.Consumer;
+import java.util.OptionalInt;
import org.sonar.server.project.Project;
-public interface TriggerViewRefreshDelegate extends Consumer<Project> {
+public interface TriggerViewRefreshDelegate {
+
+ /**
+ * Triggers the refresh of portfolios and applications
+ * associated to the project.
+ *
+ * @return the number of portfolios and applications being refreshed,
+ * or {@link OptionalInt#empty()} if not applicable.
+ */
+ OptionalInt triggerFrom(Project project);
+
}
underTest.execute(new TestComputationStepContext());
verify(analysisMetadataHolder).getProject();
- verify(delegate).accept(project);
+ verify(delegate).triggerFrom(project);
}
}