Skip to content

Commit d93e0ef

Browse files
committed
moving to package info.jab.ms
1 parent e4b791c commit d93e0ef

File tree

14 files changed

+257
-72
lines changed

14 files changed

+257
-72
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo;
1+
package info.jab.ms;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -10,4 +10,4 @@ public static void main(String[] args) {
1010
SpringApplication.run(DemoApplication.class, args);
1111
}
1212

13-
}
13+
}
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.controller;
1+
package info.jab.ms.controller;
22

33
import org.springframework.web.bind.annotation.RestController;
44
import org.springframework.web.bind.annotation.GetMapping;
@@ -8,9 +8,9 @@
88
import org.springframework.http.ResponseEntity;
99
import org.springframework.http.HttpStatus;
1010
import org.springframework.http.ProblemDetail;
11-
import com.example.demo.service.FilmService;
12-
import com.example.demo.dto.FilmDTO;
13-
import com.example.demo.entity.Film;
11+
import info.jab.ms.service.FilmService;
12+
import info.jab.ms.dto.FilmDTO;
13+
import info.jab.ms.entity.Film;
1414

1515
import io.swagger.v3.oas.annotations.Operation;
1616
import io.swagger.v3.oas.annotations.Parameter;
@@ -203,11 +203,5 @@ private ResponseEntity<ProblemDetail> createErrorResponse(String errorMessage, H
203203
return ResponseEntity.badRequest().body(problemDetail);
204204
}
205205

206-
/**
207-
* Record to hold validation result with validation status and error message
208-
*
209-
* @param valid true if validation passed, false otherwise
210-
* @param errorMessage error message if validation failed, null if valid
211-
*/
212206
private record ValidationResult(boolean valid, String errorMessage) { }
213207
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.controller;
1+
package info.jab.ms.controller;
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.dto;
1+
package info.jab.ms.dto;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import java.util.List;
@@ -45,7 +45,7 @@ public record Film(
4545
* @param entity The Film entity to convert
4646
* @return Film record with mapped data
4747
*/
48-
public static Film fromEntity(com.example.demo.entity.Film entity) {
48+
public static Film fromEntity(info.jab.ms.entity.Film entity) {
4949
return new Film(entity.filmId(), entity.title());
5050
}
5151

@@ -69,7 +69,7 @@ public Map<String, Object> toMap() {
6969
* @param filterMap Map containing filter parameters
7070
* @return FilmDTO instance with complete response structure
7171
*/
72-
public static FilmDTO fromEntities(List<com.example.demo.entity.Film> entities, Map<String, Object> filterMap) {
72+
public static FilmDTO fromEntities(List<info.jab.ms.entity.Film> entities, Map<String, Object> filterMap) {
7373
List<Film> films = entities.stream()
7474
.map(Film::fromEntity)
7575
.toList();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.entity;
1+
package info.jab.ms.entity;
22

33
import org.springframework.data.annotation.Id;
44
import org.springframework.data.relational.core.mapping.Column;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.example.demo.repository;
1+
package info.jab.ms.repository;
22

3-
import com.example.demo.entity.Film;
3+
import info.jab.ms.entity.Film;
44
import org.springframework.data.jdbc.repository.query.Query;
55
import org.springframework.data.repository.ListCrudRepository;
66
import org.springframework.data.repository.query.Param;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.example.demo.service;
1+
package info.jab.ms.service;
22

3-
import com.example.demo.entity.Film;
4-
import com.example.demo.repository.FilmRepository;
3+
import info.jab.ms.entity.Film;
4+
import info.jab.ms.repository.FilmRepository;
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.dao.DataAccessException;
77
import org.springframework.dao.DataIntegrityViolationException;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.example.demo;
1+
package info.jab.ms;
22

3-
import com.example.demo.common.PostgreSQLTestBase;
3+
import info.jab.ms.common.PostgreSQLTestBase;
44
import org.junit.jupiter.api.Test;
55
import org.springframework.boot.test.context.SpringBootTest;
66

@@ -37,4 +37,4 @@ void contextLoads() {
3737
System.out.println("Spring Boot context loaded successfully with TestContainer database");
3838
System.out.println("Database URL: " + getPostgresContainer().getJdbcUrl());
3939
}
40-
}
40+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.example.demo.acceptance;
1+
package info.jab.ms.acceptance;
22

3-
import com.example.demo.common.PostgreSQLTestBase;
3+
import info.jab.ms.common.PostgreSQLTestBase;
44
import org.junit.jupiter.api.Test;
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.boot.test.context.SpringBootTest;
Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,30 @@
1-
package com.example.demo.common;
1+
package info.jab.ms.common;
22

3+
import java.time.Duration;
4+
5+
import org.springframework.boot.test.context.SpringBootTest;
36
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
4-
import org.springframework.test.context.ActiveProfiles;
57
import org.testcontainers.containers.PostgreSQLContainer;
68
import org.testcontainers.junit.jupiter.Container;
79
import org.testcontainers.junit.jupiter.Testcontainers;
810
import org.testcontainers.utility.MountableFile;
911

10-
import java.time.Duration;
11-
1212
/**
13-
* Base class for tests that require a PostgreSQL TestContainer with Sakila schema.
13+
* PostgreSQLTestBase - Base class for integration tests with PostgreSQL TestContainer
1414
*
15-
* This class provides a common PostgreSQL container setup that can be extended by
16-
* integration and acceptance tests. It includes:
17-
* - PostgreSQL 15 container with consistent database configuration
18-
* - Sakila schema and test data initialization
19-
* - Automatic Spring Boot configuration via @ServiceConnection
20-
* - Container logging for debugging purposes
15+
* This class provides common setup for all integration tests that need
16+
* PostgreSQL database connectivity using TestContainers.
2117
*
22-
* Usage: Extend this class and add @SpringBootTest, @Testcontainers annotations
23-
* to your test class as needed.
18+
* Features:
19+
* - Shared PostgreSQL TestContainer for all test classes
20+
* - Pre-loaded with Sakila schema and data
21+
* - Automatic Spring Boot configuration via @ServiceConnection
22+
* - Proper startup and shutdown lifecycle management
2423
*/
2524
@Testcontainers
26-
@ActiveProfiles("test")
25+
@SpringBootTest
2726
public abstract class PostgreSQLTestBase {
2827

29-
/**
30-
* PostgreSQL TestContainer configured with Sakila schema and test data.
31-
*
32-
* Features:
33-
* - Uses PostgreSQL 15 for consistency with production
34-
* - Loads Sakila-compatible schema for production-like testing
35-
* - Includes focused test data (51 films, 46 starting with 'A')
36-
* - Automatic Spring Boot configuration via @ServiceConnection
37-
* - Container logging enabled for debugging
38-
* - 2-minute startup timeout for reliable CI/CD environments
39-
*/
4028
@Container
4129
@ServiceConnection(name = "postgres")
4230
protected static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15")
@@ -56,13 +44,6 @@ public abstract class PostgreSQLTestBase {
5644
System.out.print("[POSTGRES] " + outputFrame.getUtf8String());
5745
});
5846

59-
/**
60-
* Get the PostgreSQL container instance for direct access if needed.
61-
* Useful for executing queries directly against the container or
62-
* accessing connection details.
63-
*
64-
* @return The PostgreSQL container instance
65-
*/
6647
protected static PostgreSQLContainer<?> getPostgresContainer() {
6748
return postgres;
6849
}

0 commit comments

Comments
 (0)