Skip to content

Add Spring test snippets for endpoints, DDD visibility and domain classes - #2059

Merged
igorwojda merged 1 commit into
developfrom
con/konsist-spring-snippet-tests
Oct 14, 2026
Merged

igorwojda merged 1 commit into
developfrom
con/konsist-spring-snippet-tests

Conversation

@igorwojda

Copy link
Copy Markdown
Contributor

Adds 3 Spring test snippets, plus dummy Spring classes (ResponseEntity, @Get/Post/Put/Patch/Delete/RequestMapping) so the snippets compile.

New snippets

Snippet Rule
classes in 'domain' package should be internal Domain classes stay module-private
classes with 'Service' or 'Repository' annotation should not be public @Service / @Repository classes are not public
endpoints in classes with 'RestController' annotation should return 'ResponseEntity' Mapping-annotated controller functions return ResponseEntity

Before / after examples

Domain classes

// ❌ fails
package com.app.domain
class Order

// ✅ passes
package com.app.domain
internal class Order

Service / Repository visibility

// ❌ fails
@Service
class UserService

// ✅ passes
@Service
internal class UserService

Endpoint return type

@RestController
class UserController {
    // ❌ fails
    @GetMapping
    fun users(): List<User> = ...

    // ✅ passes
    @GetMapping
    fun users(): ResponseEntity<List<User>> = ...
}

Verification

  • Snippet file compiles with kotlinc against the current Konsist jar and the dummy classes.
  • The Service/Repository and ResponseEntity rules were run against a sample Spring project; each flagged only the planted violation.

…sses

Add snippets checking that RestController endpoints return ResponseEntity, Service and Repository classes are not public, and domain classes are internal. Add dummy Spring classes (ResponseEntity, request mapping annotations) so the snippets compile.
@igorwojda
igorwojda enabled auto-merge (squash) October 14, 2026 21:27
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

📦 Konsist snapshot published

Version 1.0.0-alpha.1-20261014.213225-42
Latest snapshot 1.0.0-alpha.1-SNAPSHOT
Commit 043770c
Build Publish #92
Artifact konsist-1.0.0-alpha.1-20261014.213225-42.jar (pom)
repositories {
    maven("https://central.sonatype.com/repository/maven-snapshots/")
}

dependencies {
    testImplementation("com.lemonappdev:konsist:1.0.0-alpha.1-20261014.213225-42")
}

Snapshots are removed from the Central snapshots repository after 90 days.

@igorwojda
igorwojda merged commit 043770c into develop Oct 14, 2026
48 checks passed
@igorwojda
igorwojda deleted the con/konsist-spring-snippet-tests branch October 14, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant