Search in sources :

Example 81 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.

the class DefaultColumnEntityConverterTest method shouldConvertEntityFromColumnEntity.

@Test
public void shouldConvertEntityFromColumnEntity() {
    Person person = Person.builder().withAge().withId(12).withName("Otavio").withPhones(asList("234", "2342")).build();
    ColumnEntity entity = converter.toColumn(person);
    assertEquals("Person", entity.getName());
    assertEquals(4, entity.size());
    assertThat(entity.getColumns(), containsInAnyOrder(Column.of("_id", 12L), Column.of("age", 10), Column.of("name", "Otavio"), Column.of("phones", Arrays.asList("234", "2342"))));
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Person(org.jnosql.artemis.model.Person) Test(org.junit.jupiter.api.Test)

Example 82 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.

the class DefaultColumnEntityConverterTest method shouldConvertColumnEntityToExistEntity.

@Test
public void shouldConvertColumnEntityToExistEntity() {
    ColumnEntity entity = ColumnEntity.of("Actor");
    Stream.of(columns).forEach(entity::add);
    Actor actor = Actor.actorBuilder().build();
    Actor result = converter.toEntity(actor, entity);
    assertTrue(actor == result);
    assertEquals(10, actor.getAge());
    assertEquals(12L, actor.getId());
    assertEquals(asList("234", "2342"), actor.getPhones());
    assertEquals(Collections.singletonMap("JavaZone", "Jedi"), actor.getMovieCharacter());
    assertEquals(Collections.singletonMap("JavaZone", 10), actor.getMovieRating());
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Actor(org.jnosql.artemis.model.Actor) Test(org.junit.jupiter.api.Test)

Example 83 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.

the class DefaultColumnEntityConverterTest method shouldConvertColumnEntityToEntity.

@Test
public void shouldConvertColumnEntityToEntity() {
    ColumnEntity entity = ColumnEntity.of("Actor");
    Stream.of(columns).forEach(entity::add);
    Actor actor = converter.toEntity(Actor.class, entity);
    assertNotNull(actor);
    assertEquals(10, actor.getAge());
    assertEquals(12L, actor.getId());
    assertEquals(asList("234", "2342"), actor.getPhones());
    assertEquals(Collections.singletonMap("JavaZone", "Jedi"), actor.getMovieCharacter());
    assertEquals(Collections.singletonMap("JavaZone", 10), actor.getMovieRating());
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Actor(org.jnosql.artemis.model.Actor) Test(org.junit.jupiter.api.Test)

Example 84 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.

the class DefaultColumnEntityConverterTest method shouldConvertColumnEntityFromEntity.

@Test
public void shouldConvertColumnEntityFromEntity() {
    ColumnEntity entity = converter.toColumn(actor);
    assertEquals("Actor", entity.getName());
    assertEquals(6, entity.size());
    assertThat(entity.getColumns(), containsInAnyOrder(columns));
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 85 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.

the class DefaultColumnEventPersistManagerTest method shouldFirePreColumn.

@Test
public void shouldFirePreColumn() {
    ColumnEntity entity = ColumnEntity.of("columnFamily");
    subject.firePreColumn(entity);
    ArgumentCaptor<ColumnEntityPrePersist> captor = ArgumentCaptor.forClass(ColumnEntityPrePersist.class);
    verify(columnEntityPrePersistEvent).fire(captor.capture());
    ColumnEntityPrePersist captorValue = captor.getValue();
    assertEquals(entity, captorValue.getEntity());
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnEntity (org.jnosql.diana.api.column.ColumnEntity)88 Test (org.junit.jupiter.api.Test)76 ColumnQuery (org.jnosql.diana.api.column.ColumnQuery)26 Column (org.jnosql.diana.api.column.Column)22 Arrays.asList (java.util.Arrays.asList)17 List (java.util.List)17 Consumer (java.util.function.Consumer)14 Collections.singletonList (java.util.Collections.singletonList)13 ColumnDeleteQuery (org.jnosql.diana.api.column.ColumnDeleteQuery)13 Person (org.jnosql.artemis.model.Person)12 Duration (java.time.Duration)11 Collections.emptyList (java.util.Collections.emptyList)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)10 ColumnQueryBuilder.delete (org.jnosql.diana.api.column.query.ColumnQueryBuilder.delete)9 ColumnQueryBuilder.select (org.jnosql.diana.api.column.query.ColumnQueryBuilder.select)9 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 ArrayList (java.util.ArrayList)8 Arrays (java.util.Arrays)8