@@ -123,6 +123,29 @@ void testUpdateCollection() throws Exception {
123
123
.isEqualTo (updatedCollection );
124
124
}
125
125
126
+ @ Test
127
+ void testAppendCollection () throws Exception {
128
+ List <String > existingAliases = List .of ("n1" , "n2" , "n3" );
129
+ SpreadsheetConfigCollectionInfos collectionToUpdate = new SpreadsheetConfigCollectionInfos (null , createSpreadsheetConfigs (), existingAliases );
130
+ UUID collectionUuid = saveAndReturnId (collectionToUpdate );
131
+
132
+ List <String > appendedAliases = List .of ("n1" , "n6" , "n3" );
133
+ SpreadsheetConfigCollectionInfos appendedCollection = new SpreadsheetConfigCollectionInfos (null , createUpdatedSpreadsheetConfigs (), appendedAliases );
134
+ UUID appendedCollectionUuid = saveAndReturnId (appendedCollection );
135
+
136
+ mockMvc .perform (put (URI_SPREADSHEET_CONFIG_COLLECTION_BASE + "/" + collectionUuid + "/append?sourceCollection=" + appendedCollectionUuid )
137
+ .contentType (MediaType .APPLICATION_JSON ))
138
+ .andExpect (status ().isNoContent ());
139
+
140
+ SpreadsheetConfigCollectionInfos mergedCollection = getSpreadsheetConfigCollection (collectionUuid );
141
+
142
+ // We have 3 new tabs coming from the appended collection, but 2 have been renamed to ensure name uniqueness.
143
+ assertThat (mergedCollection .spreadsheetConfigs ().stream ().map (SpreadsheetConfigInfos ::name ).toList ())
144
+ .isEqualTo (List .of ("TestSheet" , "TestSheet1" , "Generator" , "TestSheet (2)" , "TestSheet (1)" ));
145
+ // In the appended collection, we keep only the aliases from the appended collection
146
+ assertThat (mergedCollection .nodeAliases ()).isEqualTo (appendedAliases );
147
+ }
148
+
126
149
@ Test
127
150
void testDeleteCollection () throws Exception {
128
151
SpreadsheetConfigCollectionInfos collectionToDelete = new SpreadsheetConfigCollectionInfos (null , createSpreadsheetConfigs (), null );
@@ -185,8 +208,8 @@ void testAddSpreadsheetConfigToCollection() throws Exception {
185
208
SpreadsheetConfigCollectionInfos initialCollection = new SpreadsheetConfigCollectionInfos (null , createSpreadsheetConfigs (), null );
186
209
UUID collectionUuid = postSpreadsheetConfigCollection (initialCollection );
187
210
188
- List <ColumnInfos > columnInfos = Arrays . asList (
189
- new ColumnInfos (null , "new_col" , ColumnType .NUMBER , 1 , "formula" , "[\" dep\" ]" , "idNew" )
211
+ List <ColumnInfos > columnInfos = List . of (
212
+ new ColumnInfos (null , "new_col" , ColumnType .NUMBER , 1 , "formula" , "[\" dep\" ]" , "idNew" )
190
213
);
191
214
SpreadsheetConfigInfos newConfig = new SpreadsheetConfigInfos (null , "NewSheet" , SheetType .BATTERY , columnInfos );
192
215
@@ -212,7 +235,7 @@ void testRemoveSpreadsheetConfigFromCollection() throws Exception {
212
235
UUID collectionUuid = postSpreadsheetConfigCollection (initialCollection );
213
236
214
237
SpreadsheetConfigCollectionInfos createdCollection = getSpreadsheetConfigCollection (collectionUuid );
215
- UUID configIdToRemove = createdCollection .spreadsheetConfigs ().get ( 0 ).id ();
238
+ UUID configIdToRemove = createdCollection .spreadsheetConfigs ().getFirst ( ).id ();
216
239
217
240
mockMvc .perform (delete (URI_SPREADSHEET_CONFIG_COLLECTION_BASE + "/" + collectionUuid + "/spreadsheet-configs/" + configIdToRemove ))
218
241
.andExpect (status ().isNoContent ());
@@ -343,8 +366,8 @@ private List<SpreadsheetConfigInfos> createUpdatedSpreadsheetConfigs() {
343
366
344
367
return List .of (
345
368
new SpreadsheetConfigInfos (null , "Generator" , SheetType .GENERATOR , columnInfos ),
346
- new SpreadsheetConfigInfos (null , "Generator1 " , SheetType .GENERATOR , columnInfos ),
347
- new SpreadsheetConfigInfos (null , "Battery " , SheetType .BATTERY , columnInfos )
369
+ new SpreadsheetConfigInfos (null , "TestSheet " , SheetType .GENERATOR , columnInfos ),
370
+ new SpreadsheetConfigInfos (null , "TestSheet (1) " , SheetType .BATTERY , columnInfos )
348
371
);
349
372
}
350
373
0 commit comments