use of org.jnosql.diana.api.column.ColumnEntity 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);
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateAsyncTest method shouldFindById.
@Test
public void shouldFindById() {
ArgumentCaptor<Consumer<List<ColumnEntity>>> dianaCallbackCaptor = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<ColumnQuery> queryCaptor = ArgumentCaptor.forClass(ColumnQuery.class);
AtomicBoolean condition = new AtomicBoolean(false);
AtomicReference<Person> atomicReference = new AtomicReference<>();
Consumer<Optional<Person>> callback = p -> {
condition.set(true);
p.ifPresent(atomicReference::set);
};
subject.find(Person.class, 10L, callback);
verify(managerMock).select(queryCaptor.capture(), dianaCallbackCaptor.capture());
Consumer<List<ColumnEntity>> dianaCallBack = dianaCallbackCaptor.getValue();
dianaCallBack.accept(singletonList(ColumnEntity.of("Person", asList(columns))));
ColumnQuery query = queryCaptor.getValue();
assertEquals("Person", query.getColumnFamily());
assertEquals(ColumnCondition.eq(Column.of("_id", 10L)), query.getCondition().get());
assertNotNull(atomicReference.get());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateAsyncTest method shouldInsert.
@Test
public void shouldInsert() {
ColumnEntity entity = ColumnEntity.of("Person");
entity.addAll(Stream.of(columns).collect(Collectors.toList()));
subject.insert(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 shouldUpdateEntities.
@Test
public void shouldUpdateEntities() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Mockito.when(managerMock.update(any(ColumnEntity.class))).thenReturn(columnEntity);
subject.update(Arrays.asList(person, person));
verify(managerMock, times(2)).update(any(ColumnEntity.class));
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateTest method shouldReturnSingleResult.
@Test
public void shouldReturnSingleResult() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Mockito.when(managerMock.select(any(ColumnQuery.class))).thenReturn(singletonList(columnEntity));
ColumnQuery query = select().from("person").build();
Optional<Person> result = subject.singleResult(query);
assertTrue(result.isPresent());
}
Aggregations