Search in sources :

Example 6 with Address

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

the class DefaultDocumentEntityConverterTest method shouldReturnNullWhenThereIsNotSubEntity.

@Test
public void shouldReturnNullWhenThereIsNotSubEntity() {
    DocumentEntity entity = DocumentEntity.of("Address");
    entity.add(Document.of("street", "Rua Engenheiro Jose Anasoh"));
    entity.add(Document.of("city", "Salvador"));
    entity.add(Document.of("state", "Bahia"));
    entity.add(Document.of("zip", "12321"));
    entity.add(Document.of("plusFour", "1234"));
    Address address = converter.toEntity(entity);
    assertEquals("Rua Engenheiro Jose Anasoh", address.getStreet());
    assertEquals("Salvador", address.getCity());
    assertEquals("Bahia", address.getState());
    assertNull(address.getZipCode());
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) Address(jakarta.nosql.tck.entities.Address) Test(org.junit.jupiter.api.Test)

Example 7 with Address

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

the class DefaultColumnMapperDeleteBuilderTest method shouldQueryBySubEntity.

@Test
public void shouldQueryBySubEntity() {
    ColumnDeleteQuery query = mapperBuilder.deleteFrom(Address.class).where("zipCode.zip").eq("01312321").build();
    ColumnDeleteQuery queryExpected = delete().from("Address").where("zipCode.zip").eq("01312321").build();
    assertEquals(queryExpected, query);
}
Also used : Address(jakarta.nosql.tck.entities.Address) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 8 with Address

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

the class DefaultColumnEntityConverterTest method shouldReturnNullWhenThereIsNotSubEntity.

@Test
public void shouldReturnNullWhenThereIsNotSubEntity() {
    ColumnEntity entity = ColumnEntity.of("Address");
    entity.add(Column.of("street", "Rua Engenheiro Jose Anasoh"));
    entity.add(Column.of("city", "Salvador"));
    entity.add(Column.of("state", "Bahia"));
    entity.add(Column.of("zip", "12321"));
    entity.add(Column.of("plusFour", "1234"));
    Address address = converter.toEntity(entity);
    assertEquals("Rua Engenheiro Jose Anasoh", address.getStreet());
    assertEquals("Salvador", address.getCity());
    assertEquals("Bahia", address.getState());
    assertNull(address.getZipCode());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Address(jakarta.nosql.tck.entities.Address) Test(org.junit.jupiter.api.Test)

Example 9 with Address

use of jakarta.nosql.tck.entities.Address 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)

Example 10 with Address

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

the class DefaultColumnEntityConverterTest method shouldConvertColumnInSubEntity.

@Test
public void shouldConvertColumnInSubEntity() {
    ColumnEntity entity = ColumnEntity.of("Address");
    entity.add(Column.of("street", "Rua Engenheiro Jose Anasoh"));
    entity.add(Column.of("city", "Salvador"));
    entity.add(Column.of("state", "Bahia"));
    entity.add(Column.of("zipCode", Arrays.asList(Column.of("zip", "12321"), Column.of("plusFour", "1234"))));
    Address address = converter.toEntity(entity);
    assertEquals("Rua Engenheiro Jose Anasoh", address.getStreet());
    assertEquals("Salvador", address.getCity());
    assertEquals("Bahia", address.getState());
    assertEquals("12321", address.getZipCode().getZip());
    assertEquals("1234", address.getZipCode().getPlusFour());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Address(jakarta.nosql.tck.entities.Address) Test(org.junit.jupiter.api.Test)

Aggregations

Address (jakarta.nosql.tck.entities.Address)10 Test (org.junit.jupiter.api.Test)10 ColumnEntity (jakarta.nosql.column.ColumnEntity)3 DocumentEntity (jakarta.nosql.document.DocumentEntity)3 TypeReference (jakarta.nosql.TypeReference)2 Value (jakarta.nosql.Value)2 Actor (jakarta.nosql.tck.entities.Actor)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 ZipCode (jakarta.nosql.tck.entities.ZipCode)2 CDIExtension (jakarta.nosql.tck.test.CDIExtension)2