use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapEnumToNumber.
// DATACASS-343
@Test
void shouldMapEnumToNumber() {
Query query = Query.query(Criteria.where("number").is(State.Inactive));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
assertThat(mappedCriteriaDefinition.getPredicate().getValue()).isInstanceOf(Integer.class).isEqualTo(1);
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapTime.
// DATACASS-302
@Test
void shouldMapTime() {
Filter filter = Filter.from(Criteria.where("localTime").gt(LocalTime.fromMillisOfDay(1000)));
Filter mappedObject = this.queryMapper.getMappedObject(filter, this.mappingContext.getRequiredPersistentEntity(Person.class));
assertThat(mappedObject).contains(Criteria.where("localtime").gt(java.time.LocalTime.ofNanoOfDay(TimeUnit.MILLISECONDS.toNanos(1000))));
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapPrefixedEmbeddedType.
// DATACASS-167
@Test
void shouldMapPrefixedEmbeddedType() {
Filter filter = Filter.from(Criteria.where("nested.firstname").is("spring"));
Filter mappedObject = this.queryMapper.getMappedObject(filter, this.mappingContext.getRequiredPersistentEntity(WithPrefixedNullableEmbeddedType.class));
assertThat(mappedObject.iterator().next().getColumnName()).isEqualTo(ColumnName.from("prefixfirstname"));
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapTuple.
// DATACASS-523
@Test
void shouldMapTuple() {
MappedTuple tuple = new MappedTuple("foo");
Filter filter = Filter.from(Criteria.where("tuple").is(tuple));
Filter mappedObject = this.queryMapper.getMappedObject(filter, this.mappingContext.getRequiredPersistentEntity(Person.class));
TupleValue tupleValue = DataTypes.tupleOf(DataTypes.TEXT).newValue();
tupleValue.setString(0, "foo");
assertThat(mappedObject).contains(Criteria.where("tuple").is(tupleValue));
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapCollectionApplyingUdtValueCollectionConversion.
// DATACASS-343
@Test
void shouldMapCollectionApplyingUdtValueCollectionConversion() {
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