Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api-only-transcriberj-restdocs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ dependencies {

testImplementation libs.api.only.transcriberj
testImplementation libs.spring.restdocs.core
// The tests compile generated code, which carries the coverage marker annotation.
testImplementation libs.sedr.library
testImplementation libs.junit.jupiter
testImplementation libs.assertj.core
testRuntimeOnly libs.junit.platform.launcher
Expand Down
7 changes: 6 additions & 1 deletion api-only-transcriberj-restdocs/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ junit-platform = "6.1.3"
assertj = "3.27.7"
# The API-Only TranscriberJ this emitter is built against; its emitter interface is part
# of the plugin artifact, published to the Gradle Plugin Portal.
api-only-transcriberj = "0.0.1"
api-only-transcriberj = "0.2.0"
# The Spring REST Docs the generated code is tested with; also the version the plugin
# adds to a project that declares none (RestDocsEmitter.dependencies()).
spring-restdocs = "4.0.1"
# The marker annotation the generated code carries, so a coverage rule does not measure
# code nobody wrote. The TranscriberJ manages it for the projects it generates into; the
# tests here need it because they compile that generated code.
sedr-library = "1.0.0"

[libraries]

Expand All @@ -25,3 +29,4 @@ junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher
assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" }
api-only-transcriberj = { module = "com.arc-e-tect:api-only-transcriberj", version.ref = "api-only-transcriberj" }
spring-restdocs-core = { module = "org.springframework.restdocs:spring-restdocs-core", version.ref = "spring-restdocs" }
sedr-library = { module = "com.arc-e-tect.sedr.utils:sedr-library", version.ref = "sedr-library" }
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ static String fields(String header, String pkg, String base) {
/**
* Spring REST Docs descriptors from the field descriptions in {@code %2$s}.
*/
@com.arc_e_tect.sedr.utils.jacoco.marker.ExcludeFromJacocoGeneratedCodeCoverage(justification = "Generated by API-Only TranscriberJ")
public final class RestDocsFields {

private RestDocsFields() {
Expand Down Expand Up @@ -80,6 +81,7 @@ static String companion(String header, String pkg, String base, String name, Str
/**
* Spring REST Docs descriptors and snippets of {@link %3$s}.
*/
@com.arc_e_tect.sedr.utils.jacoco.marker.ExcludeFromJacocoGeneratedCodeCoverage(justification = "Generated by API-Only TranscriberJ")
public final class %3$sDocs {

private %3$sDocs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ void everyJsonTypeAndADelegatingResponseAreDescribed() throws Exception {
assertThat(relaxed(call(loader, "FoundDocs", "responseFields"))).isFalse();
}

@Test
void everyCompanionSaysItIsGeneratedSoCoverageLeavesItAlone() throws Exception {
userAccount();

for (String name : List.of("UserV1Docs", "RestDocsFields")) {
assertThat(directory.resolve("sources/com/example/contract/restdocs/" + name + ".java"))
.as(name).content().contains(
"@com.arc_e_tect.sedr.utils.jacoco.marker.ExcludeFromJacocoGeneratedCodeCoverage("
+ "justification = \"Generated by API-Only TranscriberJ\")");
}
}

@Test
void aDegradedCoreMethodIsNotHiddenByTheCompanion() throws Exception {
Path contract = directory.resolve("openapi.yaml");
Expand Down
Loading