use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateAsyncTest method shouldReturnErrorWhenThereIsMoreThanOneResultInSingleResult.
@Test
public void shouldReturnErrorWhenThereIsMoreThanOneResultInSingleResult() {
assertThrows(NonUniqueResultException.class, () -> {
ArgumentCaptor<Consumer<List<ColumnEntity>>> dianaCallbackCaptor = ArgumentCaptor.forClass(Consumer.class);
ColumnQuery query = ColumnQueryBuilder.select().from("Person").build();
Consumer<Optional<Person>> callback = l -> {
};
subject.singleResult(query, callback);
verify(managerMock).select(Mockito.any(ColumnQuery.class), dianaCallbackCaptor.capture());
Consumer<List<ColumnEntity>> dianaCallBack = dianaCallbackCaptor.getValue();
dianaCallBack.accept(asList(ColumnEntity.of("Person", asList(columns)), ColumnEntity.of("Person", asList(columns))));
});
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateAsyncTest method shouldReturnSingleResult.
@Test
public void shouldReturnSingleResult() {
ArgumentCaptor<Consumer<List<ColumnEntity>>> dianaCallbackCaptor = ArgumentCaptor.forClass(Consumer.class);
ColumnQuery query = ColumnQueryBuilder.select().from("Person").build();
AtomicBoolean condition = new AtomicBoolean(false);
AtomicReference<Person> atomicReference = new AtomicReference<>();
Consumer<Optional<Person>> callback = p -> {
condition.set(true);
p.ifPresent(atomicReference::set);
};
subject.singleResult(query, callback);
verify(managerMock).select(Mockito.any(ColumnQuery.class), dianaCallbackCaptor.capture());
Consumer<List<ColumnEntity>> dianaCallBack = dianaCallbackCaptor.getValue();
dianaCallBack.accept(singletonList(ColumnEntity.of("Person", asList(columns))));
verify(managerMock).select(Mockito.eq(query), Mockito.any());
await().untilTrue(condition);
assertNotNull(atomicReference.get());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateAsyncTest method shouldInsertIterable.
@Test
public void shouldInsertIterable() {
ColumnEntity entity = ColumnEntity.of("Person");
entity.addAll(Stream.of(columns).collect(Collectors.toList()));
subject.insert(singletonList(this.person));
verify(managerMock).insert(captor.capture(), Mockito.any(Consumer.class));
ColumnEntity value = captor.getValue();
assertEquals(entity.getName(), value.getName());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateTest method shouldInsert.
@Test
public void shouldInsert() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Mockito.when(managerMock.insert(any(ColumnEntity.class))).thenReturn(columnEntity);
subject.insert(this.person);
verify(managerMock).insert(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());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateTest method shouldInsertTTL.
@Test
public void shouldInsertTTL() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Mockito.when(managerMock.insert(any(ColumnEntity.class), any(Duration.class))).thenReturn(columnEntity);
subject.insert(this.person, Duration.ofHours(2));
verify(managerMock).insert(captor.capture(), Mockito.eq(Duration.ofHours(2)));
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());
}
Aggregations