Search in sources :

Example 1 with Address

use of org.jnosql.artemis.model.Address in project jnosql-artemis 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(5, columns.size());
    assertEquals("Rua Engenheiro Jose Anasoh", getValue(columnEntity.find("street")));
    assertEquals("Salvador", getValue(columnEntity.find("city")));
    assertEquals("Bahia", getValue(columnEntity.find("state")));
    assertEquals("12321", getValue(columnEntity.find("zip")));
    assertEquals("1234", getValue(columnEntity.find("plusFour")));
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Address(org.jnosql.artemis.model.Address) Column(org.jnosql.diana.api.column.Column) Zipcode(org.jnosql.artemis.model.Zipcode) Test(org.junit.jupiter.api.Test)

Example 2 with Address

use of org.jnosql.artemis.model.Address in project jnosql-artemis 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("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());
    assertEquals("12321", address.getZipcode().getZip());
    assertEquals("1234", address.getZipcode().getPlusFour());
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Address(org.jnosql.artemis.model.Address) Test(org.junit.jupiter.api.Test)

Example 3 with Address

use of org.jnosql.artemis.model.Address in project jnosql-artemis 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("zip").eq("01312321").build();
    assertEquals(queryExpected, query);
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Address(org.jnosql.artemis.model.Address) Test(org.junit.jupiter.api.Test)

Example 4 with Address

use of org.jnosql.artemis.model.Address in project jnosql-artemis 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(5, documents.size());
    assertEquals("Rua Engenheiro Jose Anasoh", getValue(documentEntity.find("street")));
    assertEquals("Salvador", getValue(documentEntity.find("city")));
    assertEquals("Bahia", getValue(documentEntity.find("state")));
    assertEquals("12321", getValue(documentEntity.find("zip")));
    assertEquals("1234", getValue(documentEntity.find("plusFour")));
}
Also used : DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) Address(org.jnosql.artemis.model.Address) Zipcode(org.jnosql.artemis.model.Zipcode) Document(org.jnosql.diana.api.document.Document) Test(org.junit.jupiter.api.Test)

Example 5 with Address

use of org.jnosql.artemis.model.Address in project jnosql-artemis 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("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());
    assertEquals("12321", address.getZipcode().getZip());
    assertEquals("1234", address.getZipcode().getPlusFour());
}
Also used : DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) Address(org.jnosql.artemis.model.Address) Test(org.junit.jupiter.api.Test)

Aggregations

Address (org.jnosql.artemis.model.Address)8 Test (org.junit.jupiter.api.Test)8 Zipcode (org.jnosql.artemis.model.Zipcode)2 ColumnEntity (org.jnosql.diana.api.column.ColumnEntity)2 DocumentEntity (org.jnosql.diana.api.document.DocumentEntity)2 Column (org.jnosql.diana.api.column.Column)1 ColumnDeleteQuery (org.jnosql.diana.api.column.ColumnDeleteQuery)1 ColumnQuery (org.jnosql.diana.api.column.ColumnQuery)1 Document (org.jnosql.diana.api.document.Document)1 DocumentDeleteQuery (org.jnosql.diana.api.document.DocumentDeleteQuery)1 DocumentQuery (org.jnosql.diana.api.document.DocumentQuery)1