Search in sources :

Example 16 with ColumnCondition

use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.

the class BaseQueryBuilder method lteImpl.

protected <T> void lteImpl(T value) {
    requireNonNull(value, "value is required");
    ColumnCondition newCondition = ColumnCondition.lte(Column.of(name, value));
    appendCondition(newCondition);
}
Also used : ColumnCondition(jakarta.nosql.column.ColumnCondition)

Example 17 with ColumnCondition

use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.

the class BaseQueryBuilder method eqImpl.

protected <T> void eqImpl(T value) {
    requireNonNull(value, "value is required");
    ColumnCondition newCondition = ColumnCondition.eq(Column.of(name, value));
    appendCondition(newCondition);
}
Also used : ColumnCondition(jakarta.nosql.column.ColumnCondition)

Example 18 with ColumnCondition

use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.

the class ColumnRepositoryProxyTest method shouldFindBySalary_Currency.

@Test
public void shouldFindBySalary_Currency() {
    Person ada = Person.builder().withAge(20).withName("Ada").build();
    when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(ada));
    personRepository.findBySalary_Currency("USD");
    ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
    verify(template).select(captor.capture());
    ColumnQuery query = captor.getValue();
    ColumnCondition condition = query.getCondition().get();
    final Column column = condition.getColumn();
    assertEquals("Person", query.getColumnFamily());
    assertEquals("salary.currency", column.getName());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Column(jakarta.nosql.column.Column) Person(jakarta.nosql.tck.entities.Person) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 19 with ColumnCondition

use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.

the class ColumnRepositoryProxyTest method shouldFindByIn.

@Test
public void shouldFindByIn() {
    Vendor vendor = new Vendor("vendor");
    vendor.setPrefixes(Collections.singleton("prefix"));
    when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(vendor));
    vendorRepository.findByPrefixesIn(singletonList("prefix"));
    ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
    verify(template).singleResult(captor.capture());
    ColumnQuery query = captor.getValue();
    ColumnCondition condition = query.getCondition().get();
    assertEquals("vendors", query.getColumnFamily());
    assertEquals(IN, condition.getCondition());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Vendor(jakarta.nosql.tck.entities.Vendor) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 20 with ColumnCondition

use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.

the class ColumnRepositoryProxyTest method shouldFindBySalary_CurrencyAndSalary_Value.

@Test
public void shouldFindBySalary_CurrencyAndSalary_Value() {
    Person ada = Person.builder().withAge(20).withName("Ada").build();
    when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(ada));
    personRepository.findBySalary_CurrencyAndSalary_Value("USD", BigDecimal.TEN);
    ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
    verify(template).select(captor.capture());
    ColumnQuery query = captor.getValue();
    ColumnCondition condition = query.getCondition().get();
    final Column column = condition.getColumn();
    final List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
    });
    final List<String> names = conditions.stream().map(ColumnCondition::getColumn).map(Column::getName).collect(Collectors.toList());
    assertEquals("Person", query.getColumnFamily());
    MatcherAssert.assertThat(names, Matchers.containsInAnyOrder("salary.currency", "salary.value"));
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Column(jakarta.nosql.column.Column) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Person(jakarta.nosql.tck.entities.Person) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnCondition (jakarta.nosql.column.ColumnCondition)130 Test (org.junit.jupiter.api.Test)68 ColumnQuery (jakarta.nosql.column.ColumnQuery)64 Column (jakarta.nosql.column.Column)57 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)37 ValueSource (org.junit.jupiter.params.provider.ValueSource)37 List (java.util.List)34 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)33 Person (jakarta.nosql.tck.entities.Person)17 Pagination (jakarta.nosql.mapping.Pagination)13 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)10 TypeReference (jakarta.nosql.TypeReference)7 Params (jakarta.nosql.Params)6 ColumnEntity (jakarta.nosql.column.ColumnEntity)6 Collections.singletonList (java.util.Collections.singletonList)5 QueryException (jakarta.nosql.QueryException)4 ServiceLoaderProvider (jakarta.nosql.ServiceLoaderProvider)4 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)4 ColumnObserverParser (jakarta.nosql.column.ColumnObserverParser)4 ColumnQueryParams (jakarta.nosql.column.ColumnQueryParams)4