File tree Expand file tree Collapse file tree 3 files changed +73
-0
lines changed
jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/integration Expand file tree Collapse file tree 3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2025 Contributors to the Eclipse Foundation
3+ * All rights reserved. This program and the accompanying materials
4+ * are made available under the terms of the Eclipse Public License v1.0
5+ * and Apache License v2.0 which accompanies this distribution.
6+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+ * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+ *
9+ * You may elect to redistribute this code under either of these licenses.
10+ *
11+ * Contributors:
12+ *
13+ * Otavio Santana
14+ */
15+ package org .eclipse .jnosql .databases .mongodb .integration ;
16+
17+ import jakarta .nosql .Column ;
18+ import jakarta .nosql .Entity ;
19+ import jakarta .nosql .Id ;
20+
21+ import java .util .Map ;
22+
23+ @ Entity
24+ public record ComputerRecord (@ Id String name , @ Column Map <String , ProgramRecord > programs ){
25+
26+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2025 Contributors to the Eclipse Foundation
3+ * All rights reserved. This program and the accompanying materials
4+ * are made available under the terms of the Eclipse Public License v1.0
5+ * and Apache License v2.0 which accompanies this distribution.
6+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+ * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+ *
9+ * You may elect to redistribute this code under either of these licenses.
10+ *
11+ * Contributors:
12+ *
13+ * Otavio Santana
14+ */
15+ package org .eclipse .jnosql .databases .mongodb .integration ;
16+
17+ import jakarta .nosql .Column ;
18+ import jakarta .nosql .Embeddable ;
19+ import jakarta .nosql .Id ;
20+
21+ import java .util .Map ;
22+
23+ @ Embeddable
24+ public record ProgramRecord (@ Id String name , @ Column Map <String , String > socialMedia ) {
25+
26+ }
Original file line number Diff line number Diff line change @@ -181,4 +181,25 @@ void shouldInsertEntityWithMap() {
181181 soft .assertThat (result .getPrograms ().get ("Renamer" ).getSocialMedia ().get ("twitter" )).isEqualTo ("x" );
182182 });
183183 }
184+
185+ @ Test
186+ void shouldInsertEntityWithMapUsingRecord () {
187+ var program = new ProgramRecord (
188+ "Renamer" ,
189+ Map .of ("twitter" , "x" )
190+ );
191+ var computer = new ComputerRecord ("Computer" ,Map .of ("Renamer" , program ));
192+
193+ var result = this .template .insert (computer );
194+
195+ SoftAssertions .assertSoftly (soft ->{
196+ soft .assertThat (result ).isNotNull ();
197+ soft .assertThat (result .name ()).isEqualTo ("Computer" );
198+ soft .assertThat (result .programs ()).hasSize (1 );
199+ soft .assertThat (result .programs ().get ("Renamer" )).isNotNull ();
200+ soft .assertThat (result .programs ().get ("Renamer" ).name ()).isEqualTo ("Renamer" );
201+ soft .assertThat (result .programs ().get ("Renamer" ).socialMedia ()).hasSize (1 );
202+ soft .assertThat (result .programs ().get ("Renamer" ).socialMedia ().get ("twitter" )).isEqualTo ("x" );
203+ });
204+ }
184205}
You can’t perform that action at this time.
0 commit comments