Search in sources :

Example 1 with Address

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);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Address(jakarta.nosql.tck.entities.Address) Test(org.junit.jupiter.api.Test)

Example 2 with Address

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()));
}
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 3 with Address

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);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Address(jakarta.nosql.tck.entities.Address) Test(org.junit.jupiter.api.Test)

Example 4 with Address

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);
}
Also used : Address(jakarta.nosql.tck.entities.Address) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 5 with Address

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());
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) 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