@@ -277,6 +277,50 @@ void testReorderSpreadsheetConfigs() throws Exception {
277
277
assertThat (updatedConfigIds ).isEqualTo (newOrder );
278
278
}
279
279
280
+ @ Test
281
+ void testReplaceAllSpreadsheetConfigs () throws Exception {
282
+ // Create a first collection with initial configs
283
+ SpreadsheetConfigCollectionInfos initialCollection = new SpreadsheetConfigCollectionInfos (null , createSpreadsheetConfigs (), null );
284
+ UUID collectionUuid = postSpreadsheetConfigCollection (initialCollection );
285
+
286
+ // Get the initial config IDs
287
+ List <UUID > initialConfigIds = getSpreadsheetConfigCollection (collectionUuid )
288
+ .spreadsheetConfigs ()
289
+ .stream ()
290
+ .map (SpreadsheetConfigInfos ::id )
291
+ .toList ();
292
+
293
+ // Create a second collection with different configs
294
+ SpreadsheetConfigCollectionInfos sourceCollection = new SpreadsheetConfigCollectionInfos (null , createUpdatedSpreadsheetConfigs (), null );
295
+ UUID sourceCollectionUuid = postSpreadsheetConfigCollection (sourceCollection );
296
+
297
+ // Get the config IDs from the source collection
298
+ List <UUID > sourceConfigIds = getSpreadsheetConfigCollection (sourceCollectionUuid )
299
+ .spreadsheetConfigs ()
300
+ .stream ()
301
+ .map (SpreadsheetConfigInfos ::id )
302
+ .toList ();
303
+
304
+ // Call the replace-all endpoint
305
+ String configIdsJson = mapper .writeValueAsString (sourceConfigIds );
306
+ mockMvc .perform (put (URI_SPREADSHEET_CONFIG_COLLECTION_BASE + "/" + collectionUuid + "/spreadsheet-configs/replace-all" )
307
+ .content (configIdsJson )
308
+ .contentType (MediaType .APPLICATION_JSON ))
309
+ .andExpect (status ().isNoContent ());
310
+
311
+ // Verify the collection now has the new configs
312
+ SpreadsheetConfigCollectionInfos updatedCollection = getSpreadsheetConfigCollection (collectionUuid );
313
+ List <UUID > updatedConfigIds = updatedCollection .spreadsheetConfigs ()
314
+ .stream ()
315
+ .map (SpreadsheetConfigInfos ::id )
316
+ .toList ();
317
+
318
+ // Check that the initial and updated collections have different configs
319
+ assertThat (updatedConfigIds )
320
+ .isNotEqualTo (initialConfigIds )
321
+ .hasSize (sourceConfigIds .size ());
322
+ }
323
+
280
324
private List <SpreadsheetConfigInfos > createSpreadsheetConfigs () {
281
325
List <ColumnInfos > columnInfos = Arrays .asList (
282
326
new ColumnInfos (null , "cust_a" , ColumnType .NUMBER , 1 , "cust_b + cust_c" , "[\" cust_b\" , \" cust_c\" ]" , "idA" ),
0 commit comments