use of org.jnosql.diana.api.column.ColumnCondition in project jnosql-artemis by eclipse.
the class ColumnRepositoryAsyncProxyTest method shoudFindByName.
@Test
public void shoudFindByName() {
Consumer<List<Person>> callback = v -> {
};
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
personRepository.findByName("name", callback);
verify(template).select(captor.capture(), consumerCaptor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals(Column.of("name", "name"), condition.getColumn());
assertEquals(callback, consumerCaptor.getValue());
}
use of org.jnosql.diana.api.column.ColumnCondition in project jnosql-artemis by eclipse.
the class ColumnRepositoryProxyTest method shouldFindByNameAndAgeGreaterEqualThan.
@Test
public void shouldFindByNameAndAgeGreaterEqualThan() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(ColumnQuery.class))).thenReturn(singletonList(ada));
personRepository.findByNameAndAgeGreaterThanEqual("Ada", 33);
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
verify(template).select(captor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(AND, condition.getCondition());
List<ColumnCondition> conditions = condition.getColumn().get(new TypeReference<List<ColumnCondition>>() {
});
assertThat(conditions, containsInAnyOrder(eq(Column.of("name", "Ada")), gte(Column.of("age", 33))));
}
use of org.jnosql.diana.api.column.ColumnCondition in project jnosql-artemis by eclipse.
the class ColumnRepositoryProxyTest method shouldFindByNameLike.
@Test
public void shouldFindByNameLike() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(ColumnQuery.class))).thenReturn(singletonList(ada));
personRepository.findByNameLike("Ada");
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
verify(template).select(captor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(LIKE, condition.getCondition());
assertEquals(Column.of("name", "Ada"), condition.getColumn());
}
use of org.jnosql.diana.api.column.ColumnCondition in project jnosql-artemis by eclipse.
the class ColumnRepositoryProxyTest method shouldDeleteByName.
@Test
public void shouldDeleteByName() {
ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
personRepository.deleteByName("Ada");
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 org.jnosql.diana.api.column.ColumnCondition in project jnosql-artemis by eclipse.
the class ColumnRepositoryProxyTest method shouldFindByAgeLessEqual.
@Test
public void shouldFindByAgeLessEqual() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(ColumnQuery.class))).thenReturn(singletonList(ada));
personRepository.findByAgeLessThan(33);
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
verify(template).select(captor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(LESSER_THAN, condition.getCondition());
assertEquals(Column.of("age", 33), condition.getColumn());
}
Aggregations