Search in sources :

Example 1 with Download

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

the class DefaultDocumentEntityConverterTest method shouldConvertDocumentToEntityWithArray.

@Test
public void shouldConvertDocumentToEntityWithArray() {
    byte[] contents = { 1, 2, 3, 4, 5, 6 };
    Download download = new Download();
    download.setId(1L);
    download.setContents(contents);
    DocumentEntity entity = converter.toDocument(download);
    Assertions.assertEquals(1L, entity.find("_id").get().get());
    final byte[] bytes = entity.find("contents").get().get(byte[].class);
    Assertions.assertArrayEquals(contents, bytes);
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) Download(jakarta.nosql.tck.entities.Download) Test(org.junit.jupiter.api.Test)

Example 2 with Download

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

the class DefaultDocumentEntityConverterTest method shouldConvertEntityToDocumentWithArray.

@Test
public void shouldConvertEntityToDocumentWithArray() {
    byte[] contents = { 1, 2, 3, 4, 5, 6 };
    DocumentEntity entity = DocumentEntity.of("download");
    entity.add("_id", 1L);
    entity.add("contents", contents);
    Download download = converter.toEntity(entity);
    Assertions.assertEquals(1L, download.getId());
    Assertions.assertArrayEquals(contents, download.getContents());
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) Download(jakarta.nosql.tck.entities.Download) Test(org.junit.jupiter.api.Test)

Example 3 with Download

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

the class DefaultColumnEntityConverterTest method shouldConvertEntityToDocumentWithArray.

@Test
public void shouldConvertEntityToDocumentWithArray() {
    byte[] contents = { 1, 2, 3, 4, 5, 6 };
    ColumnEntity entity = ColumnEntity.of("download");
    entity.add("_id", 1L);
    entity.add("contents", contents);
    Download download = converter.toEntity(entity);
    Assertions.assertEquals(1L, download.getId());
    Assertions.assertArrayEquals(contents, download.getContents());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Download(jakarta.nosql.tck.entities.Download) Test(org.junit.jupiter.api.Test)

Example 4 with Download

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

the class DefaultColumnEntityConverterTest method shouldConvertDocumentToEntityWithArray.

@Test
public void shouldConvertDocumentToEntityWithArray() {
    byte[] contents = { 1, 2, 3, 4, 5, 6 };
    Download download = new Download();
    download.setId(1L);
    download.setContents(contents);
    ColumnEntity entity = converter.toColumn(download);
    Assertions.assertEquals(1L, entity.find("_id").get().get());
    final byte[] bytes = entity.find("contents").map(v -> v.get(byte[].class)).orElse(new byte[0]);
    Assertions.assertArrayEquals(contents, bytes);
}
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) Download(jakarta.nosql.tck.entities.Download) Test(org.junit.jupiter.api.Test)

Aggregations

Download (jakarta.nosql.tck.entities.Download)4 Test (org.junit.jupiter.api.Test)4 ColumnEntity (jakarta.nosql.column.ColumnEntity)2 DocumentEntity (jakarta.nosql.document.DocumentEntity)2 TypeReference (jakarta.nosql.TypeReference)1 Value (jakarta.nosql.Value)1 Column (jakarta.nosql.column.Column)1 Actor (jakarta.nosql.tck.entities.Actor)1 Address (jakarta.nosql.tck.entities.Address)1 AppointmentBook (jakarta.nosql.tck.entities.AppointmentBook)1 Contact (jakarta.nosql.tck.entities.Contact)1 ContactType (jakarta.nosql.tck.entities.ContactType)1 Director (jakarta.nosql.tck.entities.Director)1 Job (jakarta.nosql.tck.entities.Job)1 Money (jakarta.nosql.tck.entities.Money)1 Movie (jakarta.nosql.tck.entities.Movie)1 Person (jakarta.nosql.tck.entities.Person)1 Vendor (jakarta.nosql.tck.entities.Vendor)1 Worker (jakarta.nosql.tck.entities.Worker)1 ZipCode (jakarta.nosql.tck.entities.ZipCode)1