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());
}
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);
}
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());
}
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()));
}
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());
}
Aggregations