Search in sources :

Example 1 with ZipCode

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

the class DefaultDocumentEntityConverterTest method shouldConvertSubEntity.

@Test
public void shouldConvertSubEntity() {
    ZipCode zipcode = new ZipCode();
    zipcode.setZip("12321");
    zipcode.setPlusFour("1234");
    Address address = new Address();
    address.setCity("Salvador");
    address.setState("Bahia");
    address.setStreet("Rua Engenheiro Jose Anasoh");
    address.setZipCode(zipcode);
    DocumentEntity documentEntity = converter.toDocument(address);
    List<Document> documents = documentEntity.getDocuments();
    assertEquals("Address", documentEntity.getName());
    assertEquals(4, documents.size());
    List<Document> zip = documentEntity.find("zipCode").map(d -> d.get(new TypeReference<List<Document>>() {
    })).orElse(Collections.emptyList());
    assertEquals("Rua Engenheiro Jose Anasoh", getValue(documentEntity.find("street")));
    assertEquals("Salvador", getValue(documentEntity.find("city")));
    assertEquals("Bahia", getValue(documentEntity.find("state")));
    assertEquals("12321", getValue(zip.stream().filter(d -> d.getName().equals("zip")).findFirst()));
    assertEquals("1234", getValue(zip.stream().filter(d -> d.getName().equals("plusFour")).findFirst()));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) AppointmentBook(jakarta.nosql.tck.entities.AppointmentBook) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Person(jakarta.nosql.tck.entities.Person) HashMap(java.util.HashMap) ContactType(jakarta.nosql.tck.entities.ContactType) ZipCode(jakarta.nosql.tck.entities.ZipCode) ArrayList(java.util.ArrayList) Address(jakarta.nosql.tck.entities.Address) Inject(javax.inject.Inject) Actor(jakarta.nosql.tck.entities.Actor) BigDecimal(java.math.BigDecimal) Vendor(jakarta.nosql.tck.entities.Vendor) TypeReference(jakarta.nosql.TypeReference) CDIExtension(jakarta.nosql.tck.test.CDIExtension) Citizen(org.eclipse.jnosql.mapping.document.entities.Citizen) Collections.singleton(java.util.Collections.singleton) Money(jakarta.nosql.tck.entities.Money) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Download(jakarta.nosql.tck.entities.Download) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Worker(jakarta.nosql.tck.entities.Worker) Director(jakarta.nosql.tck.entities.Director) Movie(jakarta.nosql.tck.entities.Movie) Contact(jakarta.nosql.tck.entities.Contact) Collection(java.util.Collection) Document(jakarta.nosql.document.Document) DocumentEntity(jakarta.nosql.document.DocumentEntity) DisplayName(org.junit.jupiter.api.DisplayName) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) Test(org.junit.jupiter.api.Test) Value(jakarta.nosql.Value) List(java.util.List) Stream(java.util.stream.Stream) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Assertions(org.junit.jupiter.api.Assertions) Job(jakarta.nosql.tck.entities.Job) Optional(java.util.Optional) Collections(java.util.Collections) DocumentEntity(jakarta.nosql.document.DocumentEntity) Address(jakarta.nosql.tck.entities.Address) ZipCode(jakarta.nosql.tck.entities.ZipCode) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Document(jakarta.nosql.document.Document) Test(org.junit.jupiter.api.Test)

Example 2 with ZipCode

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

the class InstanceProducerTest method shouldCreateNewInstance.

@Test
public void shouldCreateNewInstance() {
    ZipCode zipcode = instanceProducer.create(ZipCode.class);
    Assertions.assertNotNull(zipcode);
    Assertions.assertTrue(zipcode instanceof ZipCode);
}
Also used : ZipCode(jakarta.nosql.tck.entities.ZipCode) Test(org.junit.jupiter.api.Test)

Example 3 with ZipCode

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

the class DefaultColumnEntityConverterTest method shouldConvertSubEntity.

@Test
public void shouldConvertSubEntity() {
    ZipCode zipcode = new ZipCode();
    zipcode.setZip("12321");
    zipcode.setPlusFour("1234");
    Address address = new Address();
    address.setCity("Salvador");
    address.setState("Bahia");
    address.setStreet("Rua Engenheiro Jose Anasoh");
    address.setZipCode(zipcode);
    ColumnEntity columnEntity = converter.toColumn(address);
    List<Column> columns = columnEntity.getColumns();
    assertEquals("Address", columnEntity.getName());
    assertEquals(4, columns.size());
    List<Column> zip = columnEntity.find("zipCode").map(d -> d.get(new TypeReference<List<Column>>() {
    })).orElse(Collections.emptyList());
    assertEquals("Rua Engenheiro Jose Anasoh", getValue(columnEntity.find("street")));
    assertEquals("Salvador", getValue(columnEntity.find("city")));
    assertEquals("Bahia", getValue(columnEntity.find("state")));
    assertEquals("12321", getValue(zip.stream().filter(d -> d.getName().equals("zip")).findFirst()));
    assertEquals("1234", getValue(zip.stream().filter(d -> d.getName().equals("plusFour")).findFirst()));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) AppointmentBook(jakarta.nosql.tck.entities.AppointmentBook) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) Citizen(org.eclipse.jnosql.mapping.column.entities.Citizen) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Person(jakarta.nosql.tck.entities.Person) HashMap(java.util.HashMap) ContactType(jakarta.nosql.tck.entities.ContactType) ZipCode(jakarta.nosql.tck.entities.ZipCode) ArrayList(java.util.ArrayList) Address(jakarta.nosql.tck.entities.Address) Inject(javax.inject.Inject) Actor(jakarta.nosql.tck.entities.Actor) BigDecimal(java.math.BigDecimal) Vendor(jakarta.nosql.tck.entities.Vendor) TypeReference(jakarta.nosql.TypeReference) CDIExtension(jakarta.nosql.tck.test.CDIExtension) Collections.singleton(java.util.Collections.singleton) Money(jakarta.nosql.tck.entities.Money) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Download(jakarta.nosql.tck.entities.Download) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ColumnEntity(jakarta.nosql.column.ColumnEntity) Worker(jakarta.nosql.tck.entities.Worker) Director(jakarta.nosql.tck.entities.Director) Movie(jakarta.nosql.tck.entities.Movie) Contact(jakarta.nosql.tck.entities.Contact) Collection(java.util.Collection) Assertions.assertSame(org.junit.jupiter.api.Assertions.assertSame) Test(org.junit.jupiter.api.Test) Value(jakarta.nosql.Value) List(java.util.List) Column(jakarta.nosql.column.Column) Stream(java.util.stream.Stream) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Assertions(org.junit.jupiter.api.Assertions) Job(jakarta.nosql.tck.entities.Job) Optional(java.util.Optional) Collections(java.util.Collections) ColumnEntity(jakarta.nosql.column.ColumnEntity) Address(jakarta.nosql.tck.entities.Address) Column(jakarta.nosql.column.Column) ZipCode(jakarta.nosql.tck.entities.ZipCode) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

ZipCode (jakarta.nosql.tck.entities.ZipCode)3 TypeReference (jakarta.nosql.TypeReference)2 Value (jakarta.nosql.Value)2 Actor (jakarta.nosql.tck.entities.Actor)2 Address (jakarta.nosql.tck.entities.Address)2 AppointmentBook (jakarta.nosql.tck.entities.AppointmentBook)2 Contact (jakarta.nosql.tck.entities.Contact)2 ContactType (jakarta.nosql.tck.entities.ContactType)2 Director (jakarta.nosql.tck.entities.Director)2 Download (jakarta.nosql.tck.entities.Download)2 Job (jakarta.nosql.tck.entities.Job)2 Money (jakarta.nosql.tck.entities.Money)2 Movie (jakarta.nosql.tck.entities.Movie)2 Person (jakarta.nosql.tck.entities.Person)2 Vendor (jakarta.nosql.tck.entities.Vendor)2 Worker (jakarta.nosql.tck.entities.Worker)2 CDIExtension (jakarta.nosql.tck.test.CDIExtension)2 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2