use of jakarta.nosql.tck.entities.Address in project jnosql-diana by eclipse.
the class DefaultColumnMapperSelectBuilderTest method shouldQueryBySubEntity.
@Test
public void shouldQueryBySubEntity() {
ColumnQuery query = mapperBuilder.selectFrom(Address.class).where("zipCode.zip").eq("01312321").build();
ColumnQuery queryExpected = select().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 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()));
}
use of jakarta.nosql.tck.entities.Address in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldQueryBySubEntity.
@Test
public void shouldQueryBySubEntity() {
DocumentQuery query = mapperBuilder.selectFrom(Address.class).where("zipCode.zip").eq("01312321").build();
DocumentQuery queryExpected = select().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 DefaultDocumentMapperDeleteBuilderTest method shouldQueryBySubEntity.
@Test
public void shouldQueryBySubEntity() {
DocumentDeleteQuery query = mapperBuilder.deleteFrom(Address.class).where("zipCode.zip").eq("01312321").build();
DocumentDeleteQuery 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 DefaultDocumentEntityConverterTest method shouldConvertDocumentInSubEntity.
@Test
public void shouldConvertDocumentInSubEntity() {
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("zipCode", Arrays.asList(Document.of("zip", "12321"), Document.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