Skip to content

Commit 362e938

Browse files
authored
Merge pull request #11 from nkcoder/refactor/merge_domain
Refactor/merge domain
2 parents 271cda7 + 41136b5 commit 362e938

72 files changed

Lines changed: 2535 additions & 1594 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -305,29 +305,9 @@ spring:
305305
password: ${DATABASE_PASSWORD}
306306
```
307307
308-
## Troubleshooting
308+
## References
309309
310-
### Common Issues
311-
312-
**JWT Secret Too Short**
313-
314-
```
315-
Error: JWT secret must be at least 64 bytes for HS512
316-
Solution: Generate proper length secrets using the KeyGenerator utility
317-
```
318-
319-
**Database Connection Issues**
320-
321-
```
322-
Check: DATABASE_URL, DATABASE_USERNAME, DATABASE_PASSWORD in .env
323-
Verify: PostgreSQL is running and accessible
324-
```
325-
326-
**Port Already in Use**
327-
328-
```
329-
Change port in application.yml or stop conflicting services
330-
```
310+
- [Implementing Domain Driven Design with Spring](https://github.com/maciejwalkowiak/implementing-ddd-with-spring-talk)
331311
332312
## License
333313

auto/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22

33
export SPRING_PROFILES_ACTIVE=test
4-
./gradlew test --stacktrace jacocoTestCoverageVerification
4+
./gradlew test jacocoTestCoverageVerification

build.gradle.kts

Lines changed: 2 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -183,111 +183,5 @@ tasks.test {
183183
outputs.cacheIf { true }
184184
}
185185

186-
// Test coverage: jacoco
187-
jacoco {
188-
toolVersion = "0.8.14"
189-
}
190-
191-
tasks.jacocoTestReport {
192-
dependsOn(tasks.test)
193-
reports {
194-
xml.required.set(true) // For CI/CD integration
195-
html.required.set(true) // For human-readable reports
196-
csv.required.set(false)
197-
}
198-
199-
classDirectories.setFrom(
200-
files(classDirectories.files.map {
201-
fileTree(it) {
202-
exclude(
203-
// Infrastructure - config and cross-cutting concerns
204-
"**/infrastructure/config/**",
205-
"**/infrastructure/security/**",
206-
"**/infrastructure/resolver/**",
207-
"**/infrastructure/persistence/**",
208-
"**/infrastructure/adapter/**",
209-
// DTOs, requests, responses, mappers (data carriers)
210-
"**/dto/**",
211-
"**/request/**",
212-
"**/response/**",
213-
"**/mapper/**",
214-
// Domain value objects and events
215-
"**/domain/model/*Id.class",
216-
"**/domain/model/*Name.class",
217-
"**/domain/model/*Role.class",
218-
"**/domain/event/**",
219-
// Shared kernel and local utilities
220-
"**/shared/**",
221-
// Interfaces layer (controllers, REST)
222-
"**/interfaces/rest/**",
223-
"**/interfaces/grpc/**",
224-
// Application entry point
225-
"**/*Application*",
226-
// Generated code
227-
"**/proto/**",
228-
"**/generated/**"
229-
)
230-
}
231-
})
232-
)
233-
}
234-
tasks.jacocoTestCoverageVerification {
235-
dependsOn(tasks.jacocoTestReport)
236-
violationRules {
237-
rule {
238-
limit {
239-
minimum = "0.80".toBigDecimal()
240-
}
241-
}
242-
rule {
243-
element = "CLASS"
244-
includes = listOf(
245-
"org.nkcoder.auth.application.service.*",
246-
"org.nkcoder.user.application.service.*"
247-
)
248-
limit {
249-
minimum = "0.80".toBigDecimal()
250-
}
251-
}
252-
classDirectories.setFrom(
253-
// Same exclusions as jacocoTestReport
254-
files(classDirectories.files.map {
255-
fileTree(it) {
256-
exclude(
257-
// Infrastructure - config and cross-cutting concerns
258-
"**/infrastructure/config/**",
259-
"**/infrastructure/security/**",
260-
"**/infrastructure/resolver/**",
261-
"**/infrastructure/persistence/**",
262-
"**/infrastructure/adapter/**",
263-
// DTOs, requests, responses, mappers (data carriers)
264-
"**/dto/**",
265-
"**/request/**",
266-
"**/response/**",
267-
"**/mapper/**",
268-
// Domain value objects and events
269-
"**/domain/model/*Id.class",
270-
"**/domain/model/*Name.class",
271-
"**/domain/model/*Role.class",
272-
"**/domain/event/**",
273-
// Shared kernel and local utilities
274-
"**/shared/**",
275-
// Interfaces layer (controllers, REST)
276-
"**/interfaces/rest/**",
277-
"**/interfaces/grpc/**",
278-
// Application entry point
279-
"**/*Application*",
280-
// Generated code
281-
"**/proto/**",
282-
"**/generated/**"
283-
)
284-
}
285-
})
286-
)
287-
}
288-
}
289-
tasks.check {
290-
dependsOn(tasks.jacocoTestCoverageVerification)
291-
}
292-
293-
186+
// Test coverage configuration (JaCoCo)
187+
apply(from = "gradle/jacoco.gradle.kts")

gradle/jacoco.gradle.kts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
* JaCoCo test coverage configuration.
3+
*
4+
* This file configures code coverage reporting and verification thresholds.
5+
* Apply this script in build.gradle.kts with: apply(from = "gradle/jacoco.gradle.kts")
6+
*/
7+
8+
// JaCoCo plugin configuration
9+
configure<JacocoPluginExtension> {
10+
toolVersion = "0.8.14"
11+
}
12+
13+
// Shared exclusion patterns for classes that don't need coverage
14+
val jacocoExclusions = listOf(
15+
// Top-level infrastructure config (Spring wiring, no business logic)
16+
"**/infrastructure/config/**",
17+
"**/infrastructure/resolver/**",
18+
// DTOs, commands, requests, responses (data carriers, no logic)
19+
"**/dto/**",
20+
"**/request/**",
21+
"**/response/**",
22+
"**/entity/**",
23+
// Mappers (simple transformations)
24+
"**/mapper/**",
25+
// Domain value objects (simple wrappers with no business logic)
26+
"**/domain/model/*Id.class",
27+
"**/domain/model/*Role.class",
28+
"**/domain/model/TokenFamily.class",
29+
"**/domain/model/TokenPair.class",
30+
"**/domain/model/HashedPassword.class",
31+
// Domain events (data carriers)
32+
"**/domain/event/**",
33+
// Domain repository interfaces (just interfaces, no implementation)
34+
"**/domain/repository/**",
35+
// Domain service interfaces (PasswordEncoder, TokenGenerator - just interfaces)
36+
"**/domain/service/PasswordEncoder.class",
37+
"**/domain/service/TokenGenerator*.class",
38+
// Shared kernel (framework utilities)
39+
"**/shared/**",
40+
// Application entry point
41+
"**/*Application.class",
42+
// Generated code (protobuf, grpc)
43+
"**/proto/**",
44+
"**/generated/**"
45+
)
46+
47+
// Classes that require strict 80% coverage (core business logic)
48+
val strictCoverageClasses = listOf(
49+
// Application services - orchestration logic
50+
"org.nkcoder.user.application.service.*",
51+
// Domain services - business logic
52+
"org.nkcoder.user.domain.service.AuthenticationService",
53+
"org.nkcoder.user.domain.service.TokenRotationService",
54+
// Domain model - core business rules
55+
"org.nkcoder.user.domain.model.User",
56+
"org.nkcoder.user.domain.model.RefreshToken",
57+
"org.nkcoder.user.domain.model.Email",
58+
"org.nkcoder.user.domain.model.UserName",
59+
// Infrastructure - repository persistence
60+
"org.nkcoder.user.infrastructure.persistence.repository",
61+
)
62+
63+
tasks.named<JacocoReport>("jacocoTestReport") {
64+
dependsOn(tasks.named("test"))
65+
reports {
66+
xml.required.set(true) // For CI/CD integration
67+
html.required.set(true) // For human-readable reports
68+
csv.required.set(false)
69+
}
70+
71+
classDirectories.setFrom(
72+
files(classDirectories.files.map {
73+
fileTree(it) {
74+
exclude(jacocoExclusions)
75+
}
76+
})
77+
)
78+
}
79+
80+
tasks.named<JacocoCoverageVerification>("jacocoTestCoverageVerification") {
81+
dependsOn(tasks.named("jacocoTestReport"))
82+
violationRules {
83+
// Global minimum
84+
rule {
85+
limit {
86+
minimum = "0.80".toBigDecimal()
87+
}
88+
}
89+
// Strict requirements for core business logic (domain + application layers)
90+
rule {
91+
element = "CLASS"
92+
includes = strictCoverageClasses
93+
limit {
94+
minimum = "0.90".toBigDecimal()
95+
}
96+
}
97+
classDirectories.setFrom(
98+
files(classDirectories.files.map {
99+
fileTree(it) {
100+
exclude(jacocoExclusions)
101+
}
102+
})
103+
)
104+
}
105+
}
106+
107+
tasks.named("check") {
108+
dependsOn(tasks.named("jacocoTestCoverageVerification"))
109+
}

src/main/java/org/nkcoder/auth/application/dto/command/RefreshTokenCommand.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/main/java/org/nkcoder/auth/domain/event/UserLoggedInEvent.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/main/java/org/nkcoder/auth/domain/event/UserRegisteredEvent.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/main/java/org/nkcoder/auth/domain/model/AuthRole.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)