Search in sources :

Example 1 with Contact

use of jakarta.nosql.tck.entities.Contact in project jnosql-diana by eclipse.

the class DefaultDocumentEntityConverterTest method shouldConvertFromListEmbeddable.

@Test
public void shouldConvertFromListEmbeddable() {
    DocumentEntity entity = DocumentEntity.of("AppointmentBook");
    entity.add(Document.of("_id", "ids"));
    List<List<Document>> documents = new ArrayList<>();
    documents.add(asList(Document.of("contact_name", "Ada"), Document.of("type", ContactType.EMAIL), Document.of("information", "ada@lovelace.com")));
    documents.add(asList(Document.of("contact_name", "Ada"), Document.of("type", ContactType.MOBILE), Document.of("information", "11 1231231 123")));
    documents.add(asList(Document.of("contact_name", "Ada"), Document.of("type", ContactType.PHONE), Document.of("information", "phone")));
    entity.add(Document.of("contacts", documents));
    AppointmentBook appointmentBook = converter.toEntity(entity);
    List<Contact> contacts = appointmentBook.getContacts();
    assertEquals("ids", appointmentBook.getId());
    assertEquals("Ada", contacts.stream().map(Contact::getName).distinct().findFirst().get());
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) AppointmentBook(jakarta.nosql.tck.entities.AppointmentBook) Contact(jakarta.nosql.tck.entities.Contact) Test(org.junit.jupiter.api.Test)

Example 2 with Contact

use of jakarta.nosql.tck.entities.Contact in project jnosql-diana by eclipse.

the class DefaultColumnEntityConverterTest method shouldConvertFromListEmbeddable.

@Test
public void shouldConvertFromListEmbeddable() {
    ColumnEntity entity = ColumnEntity.of("AppointmentBook");
    entity.add(Column.of("_id", "ids"));
    List<List<Column>> columns = new ArrayList<>();
    columns.add(asList(Column.of("contact_name", "Ada"), Column.of("type", ContactType.EMAIL), Column.of("information", "ada@lovelace.com")));
    columns.add(asList(Column.of("contact_name", "Ada"), Column.of("type", ContactType.MOBILE), Column.of("information", "11 1231231 123")));
    columns.add(asList(Column.of("contact_name", "Ada"), Column.of("type", ContactType.PHONE), Column.of("information", "phone")));
    entity.add(Column.of("contacts", columns));
    AppointmentBook appointmentBook = converter.toEntity(entity);
    List<Contact> contacts = appointmentBook.getContacts();
    assertEquals("ids", appointmentBook.getId());
    assertEquals("Ada", contacts.stream().map(Contact::getName).distinct().findFirst().get());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) AppointmentBook(jakarta.nosql.tck.entities.AppointmentBook) Contact(jakarta.nosql.tck.entities.Contact) Test(org.junit.jupiter.api.Test)

Aggregations

AppointmentBook (jakarta.nosql.tck.entities.AppointmentBook)2 Contact (jakarta.nosql.tck.entities.Contact)2 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 Test (org.junit.jupiter.api.Test)2 ColumnEntity (jakarta.nosql.column.ColumnEntity)1 DocumentEntity (jakarta.nosql.document.DocumentEntity)1