diff --git a/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/CodeCoverage.java b/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/CodeCoverage.java index 032ae84a..c23d17db 100644 --- a/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/CodeCoverage.java +++ b/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/CodeCoverage.java @@ -126,8 +126,8 @@ private void generateReport(Runtime runtime) { try { var reportProducer = new LcovReportProducer(runtime.getService(ProcessDefinition.class)); + reportProducer.onSteps(steps.list()); - steps.stream().forEach(reportProducer::onStep); steps.cleanup(); persistenceService.persistFile(COVERAGE_INFO_FILENAME, reportProducer::produce, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); diff --git a/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/CodecoverageModule.java b/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/CodecoverageModule.java index a51d0992..283e034d 100644 --- a/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/CodecoverageModule.java +++ b/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/CodecoverageModule.java @@ -33,6 +33,6 @@ public class CodecoverageModule implements Module { @Override public void configure (Binder binder){ var executionListeners = Multibinder.newSetBinder(binder, ExecutionListener.class); - taskProviders.addBinding().to(CodeCoverage.class); + executionListeners.addBinding().to(CodeCoverage.class); } } diff --git a/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/LcovReportProducer.java b/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/LcovReportProducer.java index 6e029abc..548933bb 100644 --- a/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/LcovReportProducer.java +++ b/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/LcovReportProducer.java @@ -29,6 +29,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.util.HashMap; +import java.util.List; import java.util.Map; public class LcovReportProducer { @@ -41,6 +42,10 @@ public LcovReportProducer(ProcessDefinition processDefinition) { init(processDefinition); } + public void onSteps(List steps) { + steps.forEach(this::onStep); + } + public void onStep(StepInfo step) { var fileName = step.fileName(); @@ -70,6 +75,7 @@ public void onStep(StepInfo step) { } } + public void produce(OutputStream out) throws IOException { try (var writer = new BufferedWriter(new OutputStreamWriter(out))) { for (var statsEntry : statsPerFile.entrySet()) { diff --git a/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/StepsRecorder.java b/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/StepsRecorder.java index 50643a06..1e113706 100644 --- a/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/StepsRecorder.java +++ b/runtime/codecoverage/src/main/java/com/walmartlabs/concord/plugins/codecoverage/StepsRecorder.java @@ -62,12 +62,12 @@ public synchronized void record(StepInfo step) { StandardOpenOption.CREATE, StandardOpenOption.APPEND); } - public synchronized Stream stream() { + public List list() { var result = persistenceService.loadPersistedFile(FILE_NAME, in -> objectMapper.readValue(in, STEPS_TYPE)); if (result == null) { - return Stream.empty(); + return List.of(); } - return result.stream(); + return result; } public synchronized void cleanup() {