use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapEmbeddedType.
// DATACASS-167
@Test
void shouldMapEmbeddedType() {
Filter filter = Filter.from(Criteria.where("nested.firstname").is("spring"));
Filter mappedObject = this.queryMapper.getMappedObject(filter, this.mappingContext.getRequiredPersistentEntity(WithNullableEmbeddedType.class));
assertThat(mappedObject.iterator().next().getColumnName()).isEqualTo(ColumnName.from("firstname"));
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapUdtMapContains.
// DATACASS-487
@Test
void shouldMapUdtMapContains() {
Query query = Query.query(Criteria.where("relocations").contains(new Address("21 Jump-Street")));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
assertThat(mappedCriteriaDefinition.getPredicate().getOperator()).isEqualTo(Operators.CONTAINS);
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 shouldMapApplyingCustomConversion.
// DATACASS-343
@Test
void shouldMapApplyingCustomConversion() {
Query query = Query.query(Criteria.where("foo_name").is(Currency.getInstance("EUR")));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
assertThat(mappedCriteriaDefinition.getPredicate().getOperator()).isEqualTo(Operators.EQ);
assertThat(mappedCriteriaDefinition.getPredicate().getValue()).isEqualTo("Euro");
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapQueryWithCompositePrimaryKeyClass.
// DATACASS-343
@Test
void shouldMapQueryWithCompositePrimaryKeyClass() {
Filter filter = Filter.from(Criteria.where("key.firstname").is("foo"));
Filter mappedObject = queryMapper.getMappedObject(filter, mappingContext.getRequiredPersistentEntity(TypeWithKeyClass.class));
assertThat(mappedObject).contains(Criteria.where("first_name").is("foo"));
}
use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapEnumToString.
// DATACASS-343
@Test
void shouldMapEnumToString() {
Query query = Query.query(Criteria.where("foo_name").is(State.Active));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
assertThat(mappedCriteriaDefinition.getPredicate().getValue()).isInstanceOf(String.class).isEqualTo("Active");
}
Aggregations