---
description: Autonomously raise SonarQube coverage toward 91% — finds low-coverage classes, writes tests, validates with Maven
---

You are working on EQDEV-620. Your goal is to raise overall line coverage above 91%
by ADDING TESTS ONLY. You may only touch `src/test/**`. The permission harness will
block any write to `src/main` or `pom.xml` — do not attempt it.

## Step 1 — Ensure a coverage report exists
Check whether `target/site/jacoco/jacoco.xml` exists and is less than 30 minutes old.
If it is missing or stale, run:
```
mvn -B clean test
```
Wait for it to complete before continuing.

## Step 2 — Identify the worst-covered classes
Parse `target/site/jacoco/jacoco.xml`. Find the top 5 classes by MISSED line count
where TOTAL lines > 10 (skip trivial DTOs/generated classes). Build a ranked list:

| Rank | Class (FQCN) | Lines missed | Current % |
|------|-------------|-------------|-----------|

Print this table before doing anything else so I can see your starting point.

## Step 3 — Work through the list (one class at a time)
For each class in rank order:

a. Read the source file and its existing test (if any).
b. Identify the specific uncovered lines and branches from the XML report.
c. Write or extend the test under `src/test/java` in the matching package,
   following existing test conventions (JUnit 5, Mockito, AssertJ, Arrange-Act-Assert).
   - Cover branches, exception paths, and boundary conditions.
   - Every `@Test` method MUST contain at least one `assertThat(...)` or `verify(...)`.
     Tests that merely execute lines without asserting anything are WRONG.
d. Run: `mvn -B test -pl <module-containing-the-class>`
   (Use `mvn -B test` if single-module.)
   - If red, fix and retry. Hard cap: 3 attempts per class. If still failing after 3,
     skip this class, document why, and move to the next.
e. Report: class name, new test methods added, lines covered before/after.

## Step 4 — Stop conditions (check after each class)
- Stop immediately if overall project coverage crosses 91% (re-check the XML after
  each Maven run).
- Stop after completing all 5 classes in the ranked list even if 91% isn't reached.
- Stop if you have made 3 consecutive fix-retry failures — report what blocked you.

## Step 5 — Final summary
Print a table:

| Class | Tests added | Coverage before | Coverage after |
|-------|-------------|----------------|---------------|

Then print the new overall project line coverage from the latest JaCoCo XML.

Do NOT commit or push anything. I review and commit manually.
