Skip to content

Commit d5e321b

Browse files
dfcoffinclaude
andauthored
feat: Add TestContainers integration tests for MySQL and PostgreSQL (#42)
* feat: add TestContainers integration tests for MySQL and PostgreSQL Add comprehensive TestContainers-based integration tests to verify database compatibility with MySQL 8.0 and PostgreSQL 15. These tests use Docker to spin up real database instances, ensuring the Flyway migrations and JPA entity mappings work correctly across different database vendors. Changes: - Add BaseTestContainersTest base class with reusable MySQL and PostgreSQL containers - Add ComplexRelationshipMySQLIntegrationTest with 6 integration tests - Add ComplexRelationshipPostgreSQLIntegrationTest with 6 integration tests - Create profile-based test configurations (application-test-mysql.yml, application-test-postgresql.yml) - Remove legacy uuid, uuid_msb, and uuid_lsb columns from all Flyway migration scripts - Remove ApplicationInformation extension columns that don't match ESPI 4.0 XSD - Delete V4__Drop_ApplicationInformation_Extension_Columns.sql (no longer needed) - Fix uuid index references to use id column instead Test Coverage: - Customer → Statement relationships - UsagePoint → MeterReading → IntervalBlock hierarchy - RetailCustomer → UsagePoint relationships - Transaction boundary consistency - Bulk save and delete operations All tests passing: - H2: 58 repository tests passing - MySQL 8.0: 6/6 integration tests passing - PostgreSQL 15: 6/6 integration tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix: align MySQL Connector with TestContainers & configure Failsafe Database Driver Version Alignment: - Downgraded MySQL Connector/J from 9.1.0 to 8.4.0 to match MySQL 8.0 server version used in TestContainers integration tests - Ensures compatibility: MySQL server (mysql:8.0) + MySQL Connector/J 8.4.0 - PostgreSQL versions confirmed compatible: postgres:15-alpine + JDBC 42.7.7 Dependency Cleanup: - Removed duplicate TestContainers dependency declarations for junit-jupiter, mysql, and postgresql modules - Dependencies now managed only by TestContainers BOM 1.20.1 - Eliminates Maven warnings about duplicate dependency declarations Failsafe Plugin Configuration: - Configured maven-failsafe-plugin to recognize *IntegrationTest.java pattern - Integration tests now run automatically during 'mvn verify' phase - Supports both **/*IntegrationTest.java and **/*IT.java patterns Verification: - All 18 integration tests passing (6 H2, 6 PostgreSQL, 6 MySQL) - Tests verified with MySQL Connector/J 8.4.0 - Failsafe automatically executes integration tests in verify phase 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.5 <[email protected]>
1 parent 444b713 commit d5e321b

File tree

12 files changed

+718
-265
lines changed

12 files changed

+718
-265
lines changed

openespi-common/pom.xml

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@
411411
<dependency>
412412
<groupId>com.mysql</groupId>
413413
<artifactId>mysql-connector-j</artifactId>
414-
<version>9.1.0</version>
414+
<version>8.4.0</version>
415415
<scope>test</scope>
416416
</dependency>
417417

@@ -517,31 +517,6 @@
517517

518518
<!-- Flyway and database-specific dependencies moved to application pom.xml files -->
519519

520-
<!-- TestContainers for integration testing -->
521-
<dependency>
522-
<groupId>org.testcontainers</groupId>
523-
<artifactId>junit-jupiter</artifactId>
524-
<version>${testcontainers.version}</version>
525-
<scope>test</scope>
526-
</dependency>
527-
<dependency>
528-
<groupId>org.testcontainers</groupId>
529-
<artifactId>mysql</artifactId>
530-
<version>${testcontainers.version}</version>
531-
<scope>test</scope>
532-
</dependency>
533-
<dependency>
534-
<groupId>org.testcontainers</groupId>
535-
<artifactId>postgresql</artifactId>
536-
<version>${testcontainers.version}</version>
537-
<scope>test</scope>
538-
</dependency>
539-
<dependency>
540-
<groupId>org.testcontainers</groupId>
541-
<artifactId>testcontainers</artifactId>
542-
<version>${testcontainers.version}</version>
543-
<scope>test</scope>
544-
</dependency>
545520
</dependencies>
546521

547522
<build>
@@ -633,12 +608,12 @@
633608
<plugin>
634609
<groupId>org.apache.maven.plugins</groupId>
635610
<artifactId>maven-failsafe-plugin</artifactId>
636-
<!-- <scope>test</scope>-->
637-
<!-- <configuration>-->
638-
<!-- <argline>-->
639-
<!-- &#45;&#45;illegal-access=permit-->
640-
<!-- </argline>-->
641-
<!-- </configuration>-->
611+
<configuration>
612+
<includes>
613+
<include>**/*IntegrationTest.java</include>
614+
<include>**/*IT.java</include>
615+
</includes>
616+
</configuration>
642617
<executions>
643618
<execution>
644619
<goals>

openespi-common/src/main/resources/db/migration/V1__Create_Base_Tables.sql

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ CREATE INDEX idx_identified_object_related_links ON identified_object_related_li
3333
CREATE TABLE application_information
3434
(
3535
id CHAR(36) PRIMARY KEY,
36-
uuid_msb BIGINT,
37-
uuid_lsb BIGINT,
3836
description VARCHAR(255),
3937
created TIMESTAMP NOT NULL,
4038
updated TIMESTAMP NOT NULL,
@@ -47,10 +45,7 @@ CREATE TABLE application_information
4745
self_link_type VARCHAR(255),
4846

4947
-- Application specific fields
50-
kind VARCHAR(255),
5148
data_custodian_application_status VARCHAR(255),
52-
data_custodian_default_batch_resource TEXT,
53-
data_custodian_default_subscription_resource TEXT,
5449
client_name VARCHAR(255),
5550
client_id VARCHAR(255) NOT NULL UNIQUE,
5651
client_secret VARCHAR(255),
@@ -74,10 +69,7 @@ CREATE TABLE application_information
7469
authorization_server_registration_endpoint TEXT,
7570
authorization_server_token_endpoint TEXT,
7671
data_custodian_bulk_request_uri TEXT,
77-
data_custodian_third_party_selection_screen_uri TEXT,
7872
data_custodian_resource_endpoint TEXT,
79-
third_party_data_custodian_selection_screen_uri TEXT,
80-
third_party_login_screen_uri TEXT,
8173
third_party_scope_selection_screen_uri TEXT,
8274
third_party_user_portal_screen_uri TEXT,
8375
logo_uri TEXT,
@@ -89,7 +81,6 @@ CREATE TABLE application_information
8981
token_endpoint_auth_method VARCHAR(50),
9082
data_custodian_scope_selection_screen_uri TEXT,
9183
data_custodian_id VARCHAR(64),
92-
third_party_application_name VARCHAR(64) NOT NULL DEFAULT 'Default Third Party Application Name',
9384
response_types VARCHAR(255),
9485
grant_types VARCHAR(255),
9586
application_type VARCHAR(50),
@@ -150,9 +141,6 @@ CREATE INDEX idx_app_info_scopes ON application_information_scopes (application_
150141
CREATE TABLE retail_customers
151142
(
152143
id CHAR(36) PRIMARY KEY,
153-
uuid VARCHAR(36) NOT NULL UNIQUE,
154-
uuid_msb BIGINT,
155-
uuid_lsb BIGINT,
156144
description VARCHAR(255),
157145
created TIMESTAMP NOT NULL,
158146
updated TIMESTAMP NOT NULL,
@@ -179,7 +167,6 @@ CREATE TABLE retail_customers
179167
failed_login_attempts INTEGER DEFAULT 0
180168
);
181169

182-
CREATE INDEX idx_retail_customer_uuid ON retail_customers (uuid);
183170
CREATE INDEX idx_retail_customer_username ON retail_customers (username);
184171
CREATE INDEX idx_retail_customer_created ON retail_customers (created);
185172
CREATE INDEX idx_retail_customer_updated ON retail_customers (updated);
@@ -198,9 +185,6 @@ CREATE INDEX idx_retail_customer_related_links ON retail_customer_related_links
198185
CREATE TABLE service_delivery_points
199186
(
200187
id CHAR(36) PRIMARY KEY ,
201-
uuid VARCHAR(36) NOT NULL UNIQUE,
202-
uuid_msb BIGINT,
203-
uuid_lsb BIGINT,
204188
description VARCHAR(255),
205189
created TIMESTAMP NOT NULL,
206190
updated TIMESTAMP NOT NULL,
@@ -219,7 +203,6 @@ CREATE TABLE service_delivery_points
219203
sdp_customer_agreement VARCHAR(256)
220204
);
221205

222-
CREATE INDEX idx_sdp_uuid ON service_delivery_points (uuid);
223206
CREATE INDEX idx_sdp_name ON service_delivery_points (sdp_name);
224207
CREATE INDEX idx_sdp_tariff_profile ON service_delivery_points (sdp_tariff_profile);
225208
CREATE INDEX idx_sdp_customer_agreement ON service_delivery_points (sdp_customer_agreement);
@@ -240,8 +223,6 @@ CREATE INDEX idx_sdp_related_links ON service_delivery_point_related_links (serv
240223
CREATE TABLE authorizations
241224
(
242225
id CHAR(36) PRIMARY KEY ,
243-
uuid_msb BIGINT,
244-
uuid_lsb BIGINT,
245226
description VARCHAR(255),
246227
created TIMESTAMP NOT NULL,
247228
updated TIMESTAMP NOT NULL,
@@ -308,9 +289,6 @@ CREATE INDEX idx_authorization_related_links ON authorization_related_links (aut
308289
CREATE TABLE reading_types
309290
(
310291
id CHAR(36) PRIMARY KEY ,
311-
uuid VARCHAR(36) NOT NULL UNIQUE,
312-
uuid_msb BIGINT,
313-
uuid_lsb BIGINT,
314292
description VARCHAR(255),
315293
created TIMESTAMP NOT NULL,
316294
updated TIMESTAMP NOT NULL,
@@ -345,7 +323,6 @@ CREATE TABLE reading_types
345323
interharmonic_denominator BIGINT
346324
);
347325

348-
CREATE INDEX idx_reading_type_uuid ON reading_types (uuid);
349326
CREATE INDEX idx_reading_type_kind ON reading_types (kind);
350327
CREATE INDEX idx_reading_type_commodity ON reading_types (commodity);
351328
CREATE INDEX idx_reading_type_uom ON reading_types (uom);
@@ -366,9 +343,6 @@ CREATE INDEX idx_reading_type_related_links ON reading_type_related_links (readi
366343
CREATE TABLE subscriptions
367344
(
368345
id CHAR(36) PRIMARY KEY ,
369-
uuid VARCHAR(36) NOT NULL UNIQUE,
370-
uuid_msb BIGINT,
371-
uuid_lsb BIGINT,
372346
description VARCHAR(255),
373347
created TIMESTAMP NOT NULL,
374348
updated TIMESTAMP NOT NULL,
@@ -394,7 +368,6 @@ CREATE TABLE subscriptions
394368
FOREIGN KEY (retail_customer_id) REFERENCES retail_customers (id) ON DELETE CASCADE
395369
);
396370

397-
CREATE INDEX idx_subscription_uuid ON subscriptions (uuid);
398371
CREATE INDEX idx_subscription_app_id ON subscriptions (application_information_id);
399372
CREATE INDEX idx_subscription_customer_id ON subscriptions (retail_customer_id);
400373
CREATE INDEX idx_subscription_last_update ON subscriptions (last_update);
@@ -415,9 +388,6 @@ CREATE INDEX idx_subscription_related_links ON subscription_related_links (subsc
415388
CREATE TABLE batch_lists
416389
(
417390
id CHAR(36) PRIMARY KEY ,
418-
uuid VARCHAR(36) NOT NULL UNIQUE,
419-
uuid_msb BIGINT,
420-
uuid_lsb BIGINT,
421391
description VARCHAR(255),
422392
created TIMESTAMP NOT NULL,
423393
updated TIMESTAMP NOT NULL,
@@ -433,7 +403,6 @@ CREATE TABLE batch_lists
433403
resource_count INT DEFAULT 0
434404
);
435405

436-
CREATE INDEX idx_batch_list_uuid ON batch_lists (uuid);
437406
CREATE INDEX idx_batch_list_created ON batch_lists (created);
438407
CREATE INDEX idx_batch_list_resource_count ON batch_lists (resource_count);
439408
CREATE INDEX idx_batch_list_updated ON batch_lists (updated);

0 commit comments

Comments
 (0)