@@ -178,6 +178,28 @@ void shouldRetrieveListSubdocumentList() {
178
178
assertTrue (contacts .stream ().allMatch (d -> d .size () == 3 ));
179
179
}
180
180
181
+ @ Test
182
+ void shouldConvertFromListSubdocumentListNotUsingKey () {
183
+ CommunicationEntity entity = createDocumentListNotHavingId ();
184
+ entityManager .insert (entity );
185
+
186
+ }
187
+
188
+ @ Test
189
+ void shouldRetrieveListSubdocumentListNotUsingKey () {
190
+ CommunicationEntity entity = entityManager .insert (createDocumentListNotHavingId ());
191
+ Element key = entity .find (KEY_NAME ).get ();
192
+ SelectQuery query = select ().from ("AppointmentBook" ).where (key .name ()).eq (key .get ()).build ();
193
+
194
+ CommunicationEntity documentEntity = entityManager .singleResult (query ).get ();
195
+ assertNotNull (documentEntity );
196
+
197
+ List <List <Element >> contacts = (List <List <Element >>) documentEntity .find ("contacts" ).get ().get ();
198
+
199
+ assertEquals (3 , contacts .size ());
200
+ assertTrue (contacts .stream ().allMatch (d -> d .size () == 3 ));
201
+ }
202
+
181
203
@ Test
182
204
void shouldRunAQL () {
183
205
CommunicationEntity entity = getEntity ();
@@ -412,6 +434,25 @@ private CommunicationEntity createDocumentList() {
412
434
return entity ;
413
435
}
414
436
437
+ private CommunicationEntity createDocumentListNotHavingId () {
438
+ String id = UUID .randomUUID ().toString ();
439
+ CommunicationEntity entity = CommunicationEntity .of ("AppointmentBook" );
440
+ entity .add (Element .of ("_id" , "ids" ));
441
+ List <List <Element >> documents = new ArrayList <>();
442
+
443
+ documents .add (asList (Element .of ("name" , "Ada" ), Element .of ("type" , ContactType .EMAIL ),
444
+ Element .of ("information" , "ada@lovelace.com" )));
445
+
446
+ documents .add (asList (Element .of ("name" , "Ada" ), Element .of ("type" , ContactType .MOBILE ),
447
+ Element .of ("information" , "11 1231231 123" )));
448
+
449
+ documents .add (asList (Element .of ("name" , "Ada" ), Element .of ("type" , ContactType .PHONE ),
450
+ Element .of ("information" , "phone" )));
451
+
452
+ entity .add (Element .of ("contacts" , documents ));
453
+ return entity ;
454
+ }
455
+
415
456
private List <CommunicationEntity > getEntitiesWithValues () {
416
457
var lucas = CommunicationEntity .of (COLLECTION_NAME );
417
458
lucas .add (Element .of ("name" , "Lucas" ));
0 commit comments