Search in sources :

Example 76 with ColumnEntity

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

the class DefaultColumnTemplateTest method shouldReturnErrorWhenThereMoreThanASingleResult.

@Test
public void shouldReturnErrorWhenThereMoreThanASingleResult() {
    Assertions.assertThrows(NonUniqueResultException.class, () -> {
        ColumnEntity columnEntity = ColumnEntity.of("Person");
        columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
        Mockito.when(managerMock.select(any(ColumnQuery.class))).thenReturn(Arrays.asList(columnEntity, columnEntity));
        ColumnQuery query = select().from("person").build();
        subject.singleResult(query);
    });
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 77 with ColumnEntity

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

the class DefaultColumnTemplateTest method shouldUpdate.

@Test
public void shouldUpdate() {
    ColumnEntity columnEntity = ColumnEntity.of("Person");
    columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
    Mockito.when(managerMock.update(any(ColumnEntity.class))).thenReturn(columnEntity);
    subject.update(this.person);
    verify(managerMock).update(captor.capture());
    verify(columnEventPersistManager).firePostEntity(any(Person.class));
    verify(columnEventPersistManager).firePreEntity(any(Person.class));
    verify(columnEventPersistManager).firePreColumn(any(ColumnEntity.class));
    verify(columnEventPersistManager).firePostColumn(any(ColumnEntity.class));
    ColumnEntity value = captor.getValue();
    assertEquals("Person", value.getName());
    assertEquals(4, value.getColumns().size());
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Person(org.jnosql.artemis.model.Person) Test(org.junit.jupiter.api.Test)

Example 78 with ColumnEntity

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

the class DefaultColumnTemplateTest method shouldInsertEntities.

@Test
public void shouldInsertEntities() {
    ColumnEntity columnEntity = ColumnEntity.of("Person");
    columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
    Mockito.when(managerMock.insert(any(ColumnEntity.class))).thenReturn(columnEntity);
    subject.insert(Arrays.asList(person, person));
    verify(managerMock, times(2)).insert(any(ColumnEntity.class));
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 79 with ColumnEntity

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

the class ColumnEntityPostPersistTest method shouldReturnInstance.

@Test
public void shouldReturnInstance() {
    ColumnEntity entity = ColumnEntity.of("columnFamily");
    ColumnEntityPostPersist postPersist = ColumnEntityPostPersist.of(entity);
    assertEquals(entity, postPersist.getEntity());
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 80 with ColumnEntity

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

the class ColumnEntityPrePersistTest method shouldReturnInstance.

@Test
public void shouldReturnInstance() {
    ColumnEntity entity = ColumnEntity.of("columnFamily");
    ColumnEntityPrePersist prePersist = ColumnEntityPrePersist.of(entity);
    assertEquals(entity, prePersist.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