use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultColumnMapperDeleteBuilderTest method shouldUseAttributeConverter.
@Test
public void shouldUseAttributeConverter() {
ColumnDeleteQuery query = mapperBuilder.deleteFrom(Worker.class).where("salary").eq(new Money("USD", BigDecimal.TEN)).build();
ColumnDeleteQuery queryExpected = delete().from("Worker").where("money").eq("USD 10").build();
assertEquals(queryExpected, query);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultColumnMapperDeleteBuilderTest method shouldReturnDeleteFrom.
@Test
public void shouldReturnDeleteFrom() {
ColumnQueryMapper.ColumnMapperDeleteFrom columnFrom = mapperBuilder.deleteFrom(Person.class);
ColumnDeleteQuery query = columnFrom.build();
ColumnDeleteQuery queryExpected = delete().from("Person").build();
assertEquals(queryExpected, query);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultColumnMapperDeleteBuilderTest method shouldSelectWhereNameLike.
@Test
public void shouldSelectWhereNameLike() {
ColumnDeleteQuery query = mapperBuilder.deleteFrom(Person.class).where("name").like("Ada").build();
ColumnDeleteQuery queryExpected = delete().from("Person").where("name").like("Ada").build();
assertEquals(queryExpected, query);
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class ColumnReactiveRepositoryProxyTest method shouldDeleteByName.
@Test
public void shouldDeleteByName() {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
final Publisher<Void> publisher = personRepository.deleteByName("Ada");
final CompletionSubscriber<Void, Optional<Void>> subscriber = ReactiveStreams.<Void>builder().findFirst().build();
publisher.subscribe(subscriber);
final CompletionStage<Optional<Void>> completion = subscriber.getCompletion();
AtomicBoolean atomicBoolean = new AtomicBoolean();
completion.thenAccept(v -> atomicBoolean.set(true));
verify(template).delete(captor.capture());
ColumnDeleteQuery deleteQuery = captor.getValue();
ColumnCondition condition = deleteQuery.getCondition().get();
assertEquals("Person", deleteQuery.getColumnFamily());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals(Column.of("name", "Ada"), condition.getColumn());
}
use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultReactiveColumnTemplateTest method shouldDeleteClass.
@Test
public void shouldDeleteClass() {
Class<?> entity = Person.class;
AtomicLong atomicLong = new AtomicLong();
Mockito.when(template.count(entity)).thenReturn(1L);
ColumnDeleteQuery query = Mockito.mock(ColumnDeleteQuery.class);
final Observable<Void> observable = manager.delete(Person.class, 1L);
Mockito.verify(template, Mockito.never()).delete(Person.class, 1L);
CompletionStage<Optional<Void>> completion = observable.getFirst();
completion.thenAccept(o -> atomicLong.incrementAndGet());
Mockito.verify(template).delete(Person.class, 1L);
assertEquals(1L, atomicLong.get());
}
Aggregations