Skip to content

Commit 6979757

Browse files
feat: Enhance Concept Service with validation and auditing configuration
- Added Spring Boot validation dependency to support input validation for CRUD operations. - Updated implementation plan to reflect completion of phases 1-9, confirming the service is fully implemented and production-ready. - Introduced `JpaConfig` class to enable JPA auditing with a custom date-time provider, ensuring accurate timestamping for entity changes. - Removed unnecessary `@EnableJpaAuditing` annotation from `ConceptSvc` class.
1 parent d5adde0 commit 6979757

File tree

4 files changed

+59
-12
lines changed

4 files changed

+59
-12
lines changed

concept-svc/IMPLEMENTATION_PLAN.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Overview
44
Implementation of the Concept Service following patterns established by the User Service. The service will handle event concept CRUD operations, PDF generation, and integrate with AI suggestions through the standard update endpoint.
55

6-
**Status: Phases 1-8 Complete** - The core concept service is fully implemented and ready for testing.
6+
**Status: Phases 1-9 Complete** - The concept service is fully implemented, tested, and production-ready.
77

88
## Phase 1: Database & Infrastructure Setup
99

@@ -135,17 +135,44 @@ Implementation of the Concept Service following patterns established by the User
135135
## Phase 9: Testing & Validation
136136

137137
### 9.1 Basic Testing
138-
- [ ] Test all CRUD endpoints with Postman/curl
139-
- [ ] Test JWT authentication integration
140-
- [ ] Test user isolation (users can only see their concepts)
141-
- [ ] Test PDF generation functionality
142-
- [ ] Test error scenarios (invalid IDs, unauthorized access)
138+
- [x] Test all CRUD endpoints with Postman/curl
139+
- [x] GET /health - Service health check ✅
140+
- [x] GET /api/concepts - List concepts with pagination ✅
141+
- [x] POST /api/concepts - Create concept with initial requirements ✅
142+
- [x] GET /api/concepts/{id} - Get concept by ID ✅
143+
- [x] PUT /api/concepts/{id} - Update concept ✅
144+
- [x] DELETE /api/concepts/{id} - Soft delete (ARCHIVED) ✅
145+
- [x] GET /api/concepts/{id}/pdf - Download PDF ✅
146+
- [x] POST /api/concepts/{id}/apply-suggestion - Mock AI suggestions ✅
147+
- [x] Test JWT authentication integration
148+
- [x] 401 for missing token ✅
149+
- [x] 401 for invalid token ✅
150+
- [x] Valid token authentication ✅
151+
- [x] Test user isolation (users can only see their concepts)
152+
- [x] Ownership verification with findByIdAndUserId() ✅
153+
- [x] 404 for non-existent/not-owned concepts ✅
154+
- [x] Test PDF generation functionality
155+
- [x] Correct headers and content-disposition ✅
156+
- [x] PDF content with concept details ✅
157+
- [x] Test error scenarios (invalid IDs, unauthorized access)
158+
- [x] Security best practices - no information leakage ✅
159+
- [x] Proper ErrorResponse objects ✅
143160

144161
### 9.2 Integration Testing
145-
- [ ] Test with Docker Compose setup
146-
- [ ] Verify database connectivity and data persistence
147-
- [ ] Test frontend integration with concept service
148-
- [ ] Verify suggestion workflow through update endpoint
162+
- [x] Test with Docker Compose setup
163+
- [x] Fixed validation dependency and JPA audit configuration ✅
164+
- [x] PostgreSQL database connectivity ✅
165+
- [x] Service builds and starts successfully ✅
166+
- [x] Verify database connectivity and data persistence
167+
- [x] Concept creation persists correctly ✅
168+
- [x] Updates increment version and timestamp ✅
169+
- [x] Soft delete changes status to ARCHIVED ✅
170+
- [x] Test frontend integration with concept service
171+
- [x] CORS and security headers working ✅
172+
- [x] OpenAPI-compliant JSON responses ✅
173+
- [x] Verify suggestion workflow through update endpoint
174+
- [x] Mock AI suggestion endpoint working ✅
175+
- [x] Notes field updated correctly ✅
149176

150177
## Phase 10: Deployment & Documentation
151178

concept-svc/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ dependencies {
3434
// PDF generation
3535
implementation 'com.itextpdf:itext7-core:7.2.5'
3636

37+
// Validation
38+
implementation 'org.springframework.boot:spring-boot-starter-validation'
39+
3740
// OpenAPI generated code dependencies
3841
implementation 'org.openapitools:jackson-databind-nullable:0.2.6'
3942
implementation 'io.swagger.core.v3:swagger-annotations:2.2.20'

concept-svc/src/main/java/de/tum/aet/devops25/conceptsvc/ConceptSvc.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5-
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
65

76
@SpringBootApplication
8-
@EnableJpaAuditing
97
public class ConceptSvc {
108

119
public static void main(String[] args) {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package de.tum.aet.devops25.conceptsvc;
2+
3+
import java.time.OffsetDateTime;
4+
import java.util.Optional;
5+
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.data.auditing.DateTimeProvider;
9+
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
10+
11+
@Configuration
12+
@EnableJpaAuditing(dateTimeProviderRef = "auditingDateTimeProvider")
13+
public class JpaConfig {
14+
15+
@Bean
16+
public DateTimeProvider auditingDateTimeProvider() {
17+
return () -> Optional.of(OffsetDateTime.now());
18+
}
19+
}

0 commit comments

Comments
 (0)