Search in sources :

Example 11 with ColumnDeleteQuery

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);
}
Also used : Money(jakarta.nosql.tck.entities.Money) Worker(jakarta.nosql.tck.entities.Worker) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 12 with ColumnDeleteQuery

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);
}
Also used : ColumnQueryMapper(jakarta.nosql.mapping.column.ColumnQueryMapper) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 13 with ColumnDeleteQuery

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);
}
Also used : Person(jakarta.nosql.tck.entities.Person) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 14 with ColumnDeleteQuery

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());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Optional(java.util.Optional) ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 15 with ColumnDeleteQuery

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());
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) Optional(java.util.Optional) Person(jakarta.nosql.tck.entities.Person) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)70 Test (org.junit.jupiter.api.Test)41 ColumnCondition (jakarta.nosql.column.ColumnCondition)33 Column (jakarta.nosql.column.Column)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 ValueSource (org.junit.jupiter.params.provider.ValueSource)20 Person (jakarta.nosql.tck.entities.Person)12 List (java.util.List)12 ColumnEntity (jakarta.nosql.column.ColumnEntity)6 Params (jakarta.nosql.Params)5 ColumnDeleteQueryParams (jakarta.nosql.column.ColumnDeleteQueryParams)5 ColumnQuery (jakarta.nosql.column.ColumnQuery)5 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)4 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)3 DeleteQuery (jakarta.nosql.query.DeleteQuery)3 Optional (java.util.Optional)3 QueryException (jakarta.nosql.QueryException)2 ServiceLoaderProvider (jakarta.nosql.ServiceLoaderProvider)2 ColumnObserverParser (jakarta.nosql.column.ColumnObserverParser)2 DeleteQueryConverter (jakarta.nosql.column.DeleteQueryConverter)2