GapFacade.java

1
// SPDX-License-Identifier: Apache-2.0
2
// Copyright 2026 Egothor
3
// Copyright 2026 Accenture
4
package org.egothor.methodatlas.gap;
5
6
import java.io.IOException;
7
import java.nio.file.Path;
8
9
import org.egothor.methodatlas.emit.TestMethodSink;
10
11
/**
12
 * Single public entry point used by {@code MethodAtlasApp} to drive {@code -gap-report}.
13
 *
14
 * <p>
15
 * The package's data records, collector, and writer are all package-private so they
16
 * remain implementation details. The facade exposes only the operations the CLI needs:
17
 * </p>
18
 * <ol>
19
 *   <li>prepare a collector (returning a handle that must be threaded through the
20
 *       orchestrator as an extra sink);</li>
21
 *   <li>after the scan, ask the same handle to write the report.</li>
22
 * </ol>
23
 *
24
 * @since 3.0.0
25
 */
26
public final class GapFacade {
27
28
    /** Default filename used when {@code -gap-report-file} is not supplied. */
29
    public static final String DEFAULT_GAP_REPORT_FILENAME = "security-gap-report.json";
30
31
    private GapFacade() {
32
        // Utility class.
33
    }
34
35
    /**
36
     * Prepares a gap-report collector.
37
     *
38
     * @param minConfidence AI minimum-confidence threshold; AI-only evidence below this
39
     *                      value is excluded from the gap report
40
     * @return handle ready for use by the orchestrator and writer
41
     * @since 3.0.0
42
     */
43
    public static Handle prepare(double minConfidence) {
44
        GapCollector collector = new GapCollector(minConfidence);
45 1 1. prepare : replaced return value with null for org/egothor/methodatlas/gap/GapFacade::prepare → NO_COVERAGE
        return new Handle(collector);
46
    }
47
48
    /**
49
     * Opaque handle returned by {@link #prepare(double)}. Carries the collector
50
     * through the scan and yields the report when the scan is done.
51
     */
52
    public static final class Handle {
53
54
        /** Backing collector — owned by this handle, never exposed directly. */
55
        private final GapCollector collector;
56
57
        private Handle(GapCollector collector) {
58
            this.collector = collector;
59
        }
60
61
        /**
62
         * Returns the {@link TestMethodSink} that the orchestrator must receive every
63
         * per-method record on.
64
         *
65
         * @return collector as a sink
66
         */
67
        public TestMethodSink asSink() {
68 1 1. asSink : replaced return value with null for org/egothor/methodatlas/gap/GapFacade$Handle::asSink → NO_COVERAGE
            return collector;
69
        }
70
71
        /**
72
         * Builds the report and writes it to {@code outputFile}.
73
         *
74
         * @param toolVersion resolved tool version string
75
         * @param outputFile  destination path
76
         * @throws IOException if the file cannot be written
77
         */
78
        public void write(String toolVersion, Path outputFile) throws IOException {
79
            GapReport report = collector.buildReport(toolVersion);
80
            GapReportWriter.write(report, outputFile);
81
        }
82
    }
83
}

Mutations

45

1.1
Location : prepare
Killed by : none
replaced return value with null for org/egothor/methodatlas/gap/GapFacade::prepare → NO_COVERAGE

68

1.1
Location : asSink
Killed by : none
replaced return value with null for org/egothor/methodatlas/gap/GapFacade$Handle::asSink → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.30.1 support