use of org.jnosql.diana.api.column.query.ColumnQueryBuilder.select in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateAsyncTest method shouldReturnEmptySingleResult.
@Test
public void shouldReturnEmptySingleResult() {
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(emptyList());
verify(managerMock).select(Mockito.eq(query), Mockito.any());
await().untilTrue(condition);
assertNull(atomicReference.get());
}
use of org.jnosql.diana.api.column.query.ColumnQueryBuilder.select 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.query.ColumnQueryBuilder.select 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.query.ColumnQueryBuilder.select in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateAsyncTest method shouldSelect.
@Test
public void shouldSelect() {
ArgumentCaptor<Consumer<List<ColumnEntity>>> dianaCallbackCaptor = ArgumentCaptor.forClass(Consumer.class);
ColumnQuery query = ColumnQueryBuilder.select().from("Person").build();
AtomicBoolean condition = new AtomicBoolean(false);
Consumer<List<Person>> callback = l -> {
condition.set(true);
};
subject.select(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);
}
Aggregations