use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapSimpleQuery.
// DATACASS-343
@Test
void shouldMapSimpleQuery() {
Query query = Query.query(Criteria.where("foo_name").is("bar"));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
assertThat(mappedCriteriaDefinition.getPredicate().getOperator()).isEqualTo(Operators.EQ);
assertThat(mappedCriteriaDefinition.getPredicate().getValue()).isEqualTo("bar");
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapUdtMapContainsKey.
// DATACASS-487
@Test
void shouldMapUdtMapContainsKey() {
Query query = Query.query(Criteria.where("relocations").containsKey(new Address("21 Jump-Street")));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
assertThat(mappedCriteriaDefinition.getPredicate().getOperator()).isEqualTo(Operators.CONTAINS_KEY);
assertThat(mappedCriteriaDefinition.getPredicate().getValue()).isInstanceOf(UdtValue.class);
assertThat(((UdtValue) mappedCriteriaDefinition.getPredicate().getValue()).getFormattedContents()).isEqualTo("{street:'21 Jump-Street'}");
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapApplyingCustomConversionInCollection.
// DATACASS-343
@Test
void shouldMapApplyingCustomConversionInCollection() {
Query query = Query.query(Criteria.where("foo_name").in(Currency.getInstance("EUR")));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
assertThat(mappedCriteriaDefinition.getPredicate().getOperator()).isEqualTo(Operators.IN);
assertThat(mappedCriteriaDefinition.getPredicate().getValue()).isEqualTo(Collections.singletonList("Euro"));
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapApplyingUdtValueConversion.
// DATACASS-343
@Test
void shouldMapApplyingUdtValueConversion() {
Query query = Query.query(Criteria.where("address").is(new Address("21 Jump-Street")));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
CriteriaDefinition.Predicate predicate = mappedCriteriaDefinition.getPredicate();
assertThat(predicate.getOperator()).isEqualTo(Operators.EQ);
assertThat(predicate.getValue()).isInstanceOf(UdtValue.class);
assertThat(predicate.as(UdtValue.class::cast).getFormattedContents()).isEqualTo("{street:'21 Jump-Street'}");
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapApplyingUdtValueCollectionConversion.
// DATACASS-343
@Test
void shouldMapApplyingUdtValueCollectionConversion() {
Query query = Query.query(Criteria.where("address").in(new Address("21 Jump-Street")));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
CriteriaDefinition.Predicate predicate = mappedCriteriaDefinition.getPredicate();
assertThat(predicate.getOperator()).isEqualTo(Operators.IN);
assertThat(predicate.getValue()).isInstanceOf(Collection.class);
assertThat((List<UdtValue>) predicate.getValue()).extracting(UdtValue::getFormattedContents).contains("{street:'21 Jump-Street'}");
}
Aggregations