use of org.springframework.data.cassandra.core.query.CriteriaDefinition in project spring-data-cassandra by spring-projects.
the class QueryMapperUnitTests method shouldMapPropertyToColumnName.
// DATACASS-343
@Test
void shouldMapPropertyToColumnName() {
Query query = Query.query(Criteria.where("firstName").is("bar"));
Filter mappedObject = queryMapper.getMappedObject(query, persistentEntity);
CriteriaDefinition mappedCriteriaDefinition = mappedObject.iterator().next();
assertThat(mappedCriteriaDefinition.getColumnName()).isEqualTo(ColumnName.from(CqlIdentifier.fromCql("first_name")));
assertThat(mappedCriteriaDefinition.getColumnName().toString()).isEqualTo("first_name");
}
use of org.springframework.data.cassandra.core.query.CriteriaDefinition 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.CriteriaDefinition 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.CriteriaDefinition 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");
}
use of org.springframework.data.cassandra.core.query.CriteriaDefinition 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");
}
Aggregations