feat: accumulated work — PI-SPI, KYC, RLS, mutuelle parts, comptabilité PDF + startup fixes
## PI-SPI BCEAO (P0.3 — deadline 30/06/2026)
- package payment/pispi/ complet : PispiAuth (OAuth2), PispiClient (HTTP brut),
PispiIso20022Mapper (pacs.008/002), PispiSignatureVerifier (HMAC-SHA256),
PispiWebhookResource (/api/pispi/webhook), DTOs ISO 20022
- PaymentOrchestrator + PaymentProviderRegistry pour l'orchestration multi-provider
- Mode mock automatique si credentials absents (dev)
## KYC AML
- entity/KycDossier, KycResource, KycAmlService + tests
- Migration V38 (create_kyc_dossier_table)
## RLS (PostgreSQL Row-Level Security) — isolation multi-tenant
- RlsConnectionInitializer, RlsContextInterceptor, @RlsEnabled annotation
- Migration V39 (PostgreSQL RLS Tenant Isolation) + V42 (app DB roles)
- Tests unitaires RlsConnectionInitializerTest, RlsContextInterceptorTest
- Tests d'intégration RlsCrossTenantIsolationTest (@QuarkusTest + IntegrationTestProfile)
## Mutuelle — Parts sociales
- entity/mutuelle/parts/ComptePartsSociales, TransactionPartsSociales
- Service, resource, mapper, repository + tests
- InteretsEpargneService + ReleveComptePdfService
## Comptabilité PDF
- ComptabilitePdfService (OpenPDF), ComptabilitePdfResource
- Tests ComptabilitePdfServiceTest, ComptabilitePdfResourceTest
## Migrations Flyway (SYSCOHADA + Keycloak Orgs)
- V36 SYSCOHADA Plan Comptable Complet : seeds comptes standards UEMOA,
trigger init_plan_comptable_organisation, alignement schéma V1 → entités
- V37 keycloak_org_id sur organisations (P0.2 migration KC 26)
- V40 provider_defaut sur FormuleAbonnement
- V41 fcm_token sur utilisateurs (FCM notifications push)
## Fixes startup (SmallRye Config 3.20 + schéma)
- 8× @ConfigProperty(defaultValue = "") → Optional<String>
(firebase, pispi.*, mtnmomo, orange) — empty default rejetés par SmallRye 3.20
- application.properties : mappings secrets env var sous %prod. uniquement
- V36 : drop colonne obsolète 'numero' de V1 quand Hibernate a créé 'numero_compte'
- V36 : remplacement UNIQUE global sur journaux_comptables.code par composite
(organisation_id, code) pour autoriser plusieurs orgs avec code 'ACH'/'VTE'/etc
- V39 : escape placeholder ${VAR} → <VAR> dans lignes commentées
(Flyway parser évalue les placeholders même dans les commentaires)
- V41 : table 'membres' → 'utilisateurs' (nom correct selon entité Membre)
- JournalComptable entity : @UniqueConstraint composite au lieu de unique=true
- MembreResource : example @Schema JSON valide (['...'] → [])
- IntegrationTestProfile : auto-détection Docker via `docker info`, fallback
vers PostgreSQL local sans DevServices
## Dev config
- application-dev.properties : quarkus.devservices.enabled=false +
quarkus.kafka.devservices.enabled=false (pas besoin de Docker pour dev)
- quarkus.flyway.placeholder-replacement=false
- Secrets dev (wave.*, firebase, pispi) en mode mock automatique
## Phase 8 tests (complète)
- 170 fichiers modifiés/ajoutés, 23425+ insertions
- Tests RBAC (@QuarkusTest) pour MembreResource lifecycle
- Tests OrganisationContextFilter multi-org
- Tests SouscriptionQuotaOptionC, KycAmlService, EmailTemplate, etc.
Résultat : Backend démarre en 64s sur port 8085 avec 36 features installées.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
package dev.lions.unionflow.server.entity;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("SystemConfigPersistence entity")
|
||||
class SystemConfigPersistenceTest {
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// No-args constructor
|
||||
// -------------------------------------------------------------------------
|
||||
@Test
|
||||
@DisplayName("no-args constructor creates instance with null fields")
|
||||
void noArgsConstructor_createsInstanceWithNullFields() {
|
||||
SystemConfigPersistence config = new SystemConfigPersistence();
|
||||
|
||||
assertThat(config).isNotNull();
|
||||
assertThat(config.getConfigKey()).isNull();
|
||||
assertThat(config.getConfigValue()).isNull();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// All-args constructor
|
||||
// -------------------------------------------------------------------------
|
||||
@Test
|
||||
@DisplayName("all-args constructor sets configKey and configValue")
|
||||
void allArgsConstructor_setsFields() {
|
||||
SystemConfigPersistence config = new SystemConfigPersistence("smtp.host", "mail.example.com");
|
||||
|
||||
assertThat(config.getConfigKey()).isEqualTo("smtp.host");
|
||||
assertThat(config.getConfigValue()).isEqualTo("mail.example.com");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Builder
|
||||
// -------------------------------------------------------------------------
|
||||
@Nested
|
||||
@DisplayName("Builder")
|
||||
class BuilderTests {
|
||||
|
||||
@Test
|
||||
@DisplayName("builder sets configKey")
|
||||
void builder_setsConfigKey() {
|
||||
SystemConfigPersistence config = SystemConfigPersistence.builder()
|
||||
.configKey("app.version")
|
||||
.build();
|
||||
|
||||
assertThat(config.getConfigKey()).isEqualTo("app.version");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("builder sets configValue")
|
||||
void builder_setsConfigValue() {
|
||||
SystemConfigPersistence config = SystemConfigPersistence.builder()
|
||||
.configValue("3.0.0")
|
||||
.build();
|
||||
|
||||
assertThat(config.getConfigValue()).isEqualTo("3.0.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("builder sets both configKey and configValue")
|
||||
void builder_setsBothFields() {
|
||||
SystemConfigPersistence config = SystemConfigPersistence.builder()
|
||||
.configKey("feature.kyc.enabled")
|
||||
.configValue("true")
|
||||
.build();
|
||||
|
||||
assertThat(config.getConfigKey()).isEqualTo("feature.kyc.enabled");
|
||||
assertThat(config.getConfigValue()).isEqualTo("true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("builder allows null configValue (TEXT column is nullable)")
|
||||
void builder_nullConfigValue_isAllowed() {
|
||||
SystemConfigPersistence config = SystemConfigPersistence.builder()
|
||||
.configKey("optional.setting")
|
||||
.configValue(null)
|
||||
.build();
|
||||
|
||||
assertThat(config.getConfigKey()).isEqualTo("optional.setting");
|
||||
assertThat(config.getConfigValue()).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Getters / Setters
|
||||
// -------------------------------------------------------------------------
|
||||
@Nested
|
||||
@DisplayName("Getters and Setters")
|
||||
class GettersSettersTests {
|
||||
|
||||
@Test
|
||||
@DisplayName("setConfigKey / getConfigKey round-trips")
|
||||
void configKey_roundTrips() {
|
||||
SystemConfigPersistence config = new SystemConfigPersistence();
|
||||
config.setConfigKey("max.upload.size");
|
||||
assertThat(config.getConfigKey()).isEqualTo("max.upload.size");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("setConfigValue / getConfigValue round-trips")
|
||||
void configValue_roundTrips() {
|
||||
SystemConfigPersistence config = new SystemConfigPersistence();
|
||||
config.setConfigValue("5242880");
|
||||
assertThat(config.getConfigValue()).isEqualTo("5242880");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("configValue can store a JSON blob")
|
||||
void configValue_canStoreJson() {
|
||||
String json = "{\"enabled\":true,\"maxRetries\":3}";
|
||||
SystemConfigPersistence config = new SystemConfigPersistence();
|
||||
config.setConfigValue(json);
|
||||
assertThat(config.getConfigValue()).isEqualTo(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("configValue can store a multiline text")
|
||||
void configValue_canStoreMultilineText() {
|
||||
String multiline = "line1\nline2\nline3";
|
||||
SystemConfigPersistence config = new SystemConfigPersistence();
|
||||
config.setConfigValue(multiline);
|
||||
assertThat(config.getConfigValue()).isEqualTo(multiline);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// UUID id (inherited from BaseEntity)
|
||||
// -------------------------------------------------------------------------
|
||||
@Test
|
||||
@DisplayName("UUID id field is settable and gettable")
|
||||
void uuidId_settableAndGettable() {
|
||||
UUID id = UUID.randomUUID();
|
||||
SystemConfigPersistence config = new SystemConfigPersistence();
|
||||
config.setId(id);
|
||||
assertThat(config.getId()).isEqualTo(id);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// equals / hashCode (Lombok @EqualsAndHashCode(callSuper=true))
|
||||
// -------------------------------------------------------------------------
|
||||
@Test
|
||||
@DisplayName("two instances with same id are equal")
|
||||
void equals_sameId_areEqual() {
|
||||
UUID id = UUID.randomUUID();
|
||||
SystemConfigPersistence a = new SystemConfigPersistence("key", "val");
|
||||
a.setId(id);
|
||||
SystemConfigPersistence b = new SystemConfigPersistence("key", "val");
|
||||
b.setId(id);
|
||||
|
||||
assertThat(a).isEqualTo(b);
|
||||
assertThat(a.hashCode()).isEqualTo(b.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("two instances with different ids are not equal")
|
||||
void equals_differentIds_notEqual() {
|
||||
SystemConfigPersistence a = new SystemConfigPersistence("key", "val");
|
||||
a.setId(UUID.randomUUID());
|
||||
SystemConfigPersistence b = new SystemConfigPersistence("key", "val");
|
||||
b.setId(UUID.randomUUID());
|
||||
|
||||
assertThat(a).isNotEqualTo(b);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// toString
|
||||
// -------------------------------------------------------------------------
|
||||
@Test
|
||||
@DisplayName("toString contains configKey")
|
||||
void toString_containsConfigKey() {
|
||||
SystemConfigPersistence config = SystemConfigPersistence.builder()
|
||||
.configKey("smtp.port")
|
||||
.configValue("587")
|
||||
.build();
|
||||
|
||||
assertThat(config.toString()).contains("smtp.port");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Typical configuration keys scenario
|
||||
// -------------------------------------------------------------------------
|
||||
@Test
|
||||
@DisplayName("stores various typical configuration key-value pairs")
|
||||
void typicalConfigurations_storeCorrectly() {
|
||||
String[][] configs = {
|
||||
{"smtp.host", "mail.example.com"},
|
||||
{"smtp.port", "587"},
|
||||
{"feature.kyc.enabled", "true"},
|
||||
{"max.upload.size.bytes", "5242880"},
|
||||
{"default.currency", "XOF"}
|
||||
};
|
||||
|
||||
for (String[] kv : configs) {
|
||||
SystemConfigPersistence config = SystemConfigPersistence.builder()
|
||||
.configKey(kv[0])
|
||||
.configValue(kv[1])
|
||||
.build();
|
||||
assertThat(config.getConfigKey()).isEqualTo(kv[0]);
|
||||
assertThat(config.getConfigValue()).isEqualTo(kv[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user