@@ -71,7 +71,7 @@ void setUp() {
7171 separateMongoClient = MongoClients .create (mongoDBContainer .getConnectionString ());
7272
7373 // Initialize test kit with MongoDB persistence
74- testKit = MongoDBSyncTestKit .create (new MongoDBSyncAuditStore ( sharedMongoClient , "test" ), sharedMongoClient , database );
74+ testKit = MongoDBSyncTestKit .create (MongoDBSyncAuditStore . from ( new MongoDBSyncTargetSystem ( "mongodb" , sharedMongoClient , "test" ) ), sharedMongoClient , database );
7575 auditHelper = testKit .getAuditHelper ();
7676 }
7777
@@ -87,6 +87,7 @@ void testCompleteAuditEntryPersistenceInMongoDB() {
8787 String changeId = "non-tx-transactional-false" ;
8888 LocalDateTime testStart = LocalDateTime .now ();
8989 LocalDateTime testEnd = testStart .plusMinutes (5 ); // Allow enough time for test execution
90+ MongoDBSyncTargetSystem mongoDBSyncTargetSystem = new MongoDBSyncTargetSystem ("mongodb" , sharedMongoClient , "test" );
9091
9192 // Given-When-Then - Test MongoDB audit persistence with AuditTestSupport
9293 AuditTestSupport .withTestKit (testKit )
@@ -96,8 +97,8 @@ void testCompleteAuditEntryPersistenceInMongoDB() {
9697 .WHEN (() -> {
9798 assertDoesNotThrow (() -> {
9899 testKit .createBuilder ()
99- .setAuditStore (new MongoDBSyncAuditStore ( sharedMongoClient , "test" ))
100- .addTargetSystem (new MongoDBSyncTargetSystem ( "mongodb" , sharedMongoClient , "test" ) )
100+ .setAuditStore (MongoDBSyncAuditStore . from ( mongoDBSyncTargetSystem ))
101+ .addTargetSystem (mongoDBSyncTargetSystem )
101102 .build ()
102103 .run ();
103104 });
@@ -124,6 +125,7 @@ void testCompleteAuditEntryPersistenceInMongoDB() {
124125 @ Test
125126 @ DisplayName ("Should persist NON_TX txStrategy for transactional=false scenarios" )
126127 void testNonTxScenarios () {
128+ MongoDBSyncTargetSystem mongoDBSyncTargetSystem = new MongoDBSyncTargetSystem ("mongodb" , sharedMongoClient , "test" );
127129 // Given-When-Then - Test NON_TX scenarios with AuditTestSupport
128130 AuditTestSupport .withTestKit (testKit )
129131 .GIVEN_Changes (
@@ -133,8 +135,8 @@ void testNonTxScenarios() {
133135 .WHEN (() -> {
134136 assertDoesNotThrow (() -> {
135137 testKit .createBuilder ()
136- .setAuditStore (new MongoDBSyncAuditStore ( sharedMongoClient , "test" ))
137- .addTargetSystem (new MongoDBSyncTargetSystem ( "mongodb" , sharedMongoClient , "test" ) )
138+ .setAuditStore (MongoDBSyncAuditStore . from ( mongoDBSyncTargetSystem ))
139+ .addTargetSystem (mongoDBSyncTargetSystem )
138140 .addTargetSystem (new NonTransactionalTargetSystem ("non-tx-system" )) // Non-transactional target system
139141 .build ()
140142 .run ();
@@ -171,6 +173,7 @@ void testNonTxScenarios() {
171173 @ Test
172174 @ DisplayName ("Should persist TX_SHARED txStrategy when targetSystem not defined in change" )
173175 void testTxSharedScenarios () {
176+ MongoDBSyncTargetSystem mongoDBSyncTargetSystem = new MongoDBSyncTargetSystem ("mongodb" , sharedMongoClient , "test" );
174177 MongoDBSyncTargetSystem sharedTargetSystem = new MongoDBSyncTargetSystem ("tx-shared-system" , sharedMongoClient , "test" ); // Same MongoClient as audit storage
175178
176179
@@ -182,8 +185,8 @@ void testTxSharedScenarios() {
182185 .WHEN (() -> {
183186 assertDoesNotThrow (() -> {
184187 testKit .createBuilder ()
185- .setAuditStore (new MongoDBSyncAuditStore ( sharedMongoClient , "test" ))
186- .addTargetSystem (new MongoDBSyncTargetSystem ( "mongodb" , sharedMongoClient , "test" ) )
188+ .setAuditStore (MongoDBSyncAuditStore . from ( mongoDBSyncTargetSystem ))
189+ .addTargetSystem (mongoDBSyncTargetSystem )
187190 .addTargetSystem (sharedTargetSystem )
188191 .build ()
189192 .run ();
@@ -207,6 +210,7 @@ void testTxSharedScenarios() {
207210 @ Test
208211 @ DisplayName ("Should persist TX_SEPARATE_NO_MARKER when targetSystem defined and different from auditStore" )
209212 void testTxNoMarkerWhenSameMongoClientButDifferentTargetSystem () {
213+ MongoDBSyncTargetSystem mongoDBSyncTargetSystem = new MongoDBSyncTargetSystem ("mongodb" , sharedMongoClient , "test" );
210214 MongoDBSyncTargetSystem sharedTargetSystem = new MongoDBSyncTargetSystem ("mongo-system" , sharedMongoClient , "test" ); // Same MongoClient as audit storage
211215
212216 // Given-When-Then - Test TX_SEPARATE_NO_MARKER scenarios with AuditTestSupport
@@ -217,8 +221,8 @@ void testTxNoMarkerWhenSameMongoClientButDifferentTargetSystem() {
217221 .WHEN (() -> {
218222 assertDoesNotThrow (() -> {
219223 testKit .createBuilder ()
220- .setAuditStore (new MongoDBSyncAuditStore ( sharedMongoClient , "test" ))
221- .addTargetSystem (new MongoDBSyncTargetSystem ( "mongodb" , sharedMongoClient , "test" ) )
224+ .setAuditStore (MongoDBSyncAuditStore . from ( mongoDBSyncTargetSystem ))
225+ .addTargetSystem (mongoDBSyncTargetSystem )
222226 .addTargetSystem (sharedTargetSystem )
223227 .build ()
224228 .run ();
@@ -242,6 +246,7 @@ void testTxNoMarkerWhenSameMongoClientButDifferentTargetSystem() {
242246 @ Test
243247 @ DisplayName ("Should persist TX_SEPARATE_NO_MARKER txStrategy for different MongoClient scenario" )
244248 void testTxSeparateNoMarkerScenario () {
249+ MongoDBSyncTargetSystem mongoDBSyncTargetSystem = new MongoDBSyncTargetSystem ("mongodb" , sharedMongoClient , "test" );
245250 MongoDatabase separateDatabase = separateMongoClient .getDatabase ("test" );
246251 MongoDBSyncTargetSystem separateTargetSystem = new MongoDBSyncTargetSystem ("tx-separate-system" , separateMongoClient , "test" ); // Different MongoClient from audit storage
247252
@@ -253,8 +258,8 @@ void testTxSeparateNoMarkerScenario() {
253258 .WHEN (() -> {
254259 assertDoesNotThrow (() -> {
255260 testKit .createBuilder ()
256- .setAuditStore (new MongoDBSyncAuditStore ( sharedMongoClient , "test" ))
257- .addTargetSystem (new MongoDBSyncTargetSystem ( "mongodb" , sharedMongoClient , "test" ) )
261+ .setAuditStore (MongoDBSyncAuditStore . from ( mongoDBSyncTargetSystem ))
262+ .addTargetSystem (mongoDBSyncTargetSystem )
258263 .addTargetSystem (separateTargetSystem )
259264 .build ()
260265 .run ();
@@ -278,6 +283,7 @@ void testTxSeparateNoMarkerScenario() {
278283 @ Test
279284 @ DisplayName ("Should persist correct targetSystemId for different target system configurations" )
280285 void testTargetSystemIdVariations () {
286+ MongoDBSyncTargetSystem mongoDBSyncTargetSystem = new MongoDBSyncTargetSystem ("mongodb" , sharedMongoClient , "test" );
281287 MongoDatabase separateDatabase = separateMongoClient .getDatabase ("test" );
282288
283289 // Given-When-Then - Test multiple target system configurations with AuditTestSupport
@@ -290,8 +296,8 @@ void testTargetSystemIdVariations() {
290296 .WHEN (() -> {
291297 assertDoesNotThrow (() -> {
292298 testKit .createBuilder ()
293- .setAuditStore (new MongoDBSyncAuditStore ( sharedMongoClient , "test" ))
294- .addTargetSystem (new MongoDBSyncTargetSystem ( "mongodb" , sharedMongoClient , "test" ) )
299+ .setAuditStore (MongoDBSyncAuditStore . from ( mongoDBSyncTargetSystem ))
300+ .addTargetSystem (mongoDBSyncTargetSystem )
295301 .addTargetSystem (new NonTransactionalTargetSystem ("non-tx-system" ))
296302 .addTargetSystem (new MongoDBSyncTargetSystem ("tx-separate-system" , separateMongoClient , "test" ))
297303 .build ()
@@ -317,6 +323,7 @@ void testTargetSystemIdVariations() {
317323 @ Test
318324 @ DisplayName ("Should persist multiple changes with different txStrategy configurations correctly" )
319325 void testMultipleChangesWithDifferentConfigurations () {
326+ MongoDBSyncTargetSystem mongoDBSyncTargetSystem = new MongoDBSyncTargetSystem ("mongodb" , sharedMongoClient , "test" );
320327
321328
322329 AuditTestSupport .withTestKit (testKit )
@@ -327,8 +334,8 @@ void testMultipleChangesWithDifferentConfigurations() {
327334 ).WHEN (() -> assertDoesNotThrow (() -> {
328335 MongoDatabase separateDatabase = separateMongoClient .getDatabase ("test" );
329336 testKit .createBuilder ()
330- .setAuditStore (new MongoDBSyncAuditStore ( sharedMongoClient , "test" ))
331- .addTargetSystem (new MongoDBSyncTargetSystem ( "mongodb" , sharedMongoClient , "test" ) )
337+ .setAuditStore (MongoDBSyncAuditStore . from ( mongoDBSyncTargetSystem ))
338+ .addTargetSystem (mongoDBSyncTargetSystem )
332339 .addTargetSystem (new MongoDBSyncTargetSystem ("tx-separate-system" , separateMongoClient , "test" ))
333340 .build ()
334341 .run ();
0 commit comments