use of org.springframework.data.cassandra.core.convert.CassandraCustomConversions in project spring-data-cassandra by spring-projects.
the class CassandraMappingContextUnitTests method shouldCreatePersistentEntityIfNoConversionRegistered.
// DATACASS-296
@Test
void shouldCreatePersistentEntityIfNoConversionRegistered() {
mappingContext.setCustomConversions(new CassandraCustomConversions(Collections.emptyList()));
assertThat(mappingContext.shouldCreatePersistentEntityFor(ClassTypeInformation.from(Human.class))).isTrue();
}
use of org.springframework.data.cassandra.core.convert.CassandraCustomConversions in project spring-data-cassandra by spring-projects.
the class CassandraMappingContextUnitTests method shouldNotCreateEntitiesForCustomConvertedTypes.
// DATACASS-296
@Test
void shouldNotCreateEntitiesForCustomConvertedTypes() {
mappingContext.setCustomConversions(new CassandraCustomConversions(Collections.singletonList(HumanToStringConverter.INSTANCE)));
assertThat(mappingContext.shouldCreatePersistentEntityFor(ClassTypeInformation.from(Human.class))).isFalse();
}
use of org.springframework.data.cassandra.core.convert.CassandraCustomConversions in project spring-data-cassandra by spring-projects.
the class RepositoryQueryMethodParameterTypesIntegrationTests method shouldFindByAnnotatedDateParameter.
// DATACASS-296
@Test
void shouldFindByAnnotatedDateParameter() {
CustomConversions customConversions = new CassandraCustomConversions(Collections.singletonList(new DateToLocalDateConverter()));
mappingContext.setCustomConversions(customConversions);
converter.setCustomConversions(customConversions);
converter.afterPropertiesSet();
session.execute("CREATE INDEX IF NOT EXISTS allpossibletypes_date ON allpossibletypes ( date )");
AllPossibleTypes allPossibleTypes = new AllPossibleTypes();
LocalDate localDate = LocalDate.now();
Instant instant = localDate.atStartOfDay().toInstant(ZoneOffset.UTC);
allPossibleTypes.setId("id");
allPossibleTypes.setDate(LocalDate.of(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth()));
allPossibleTypesRepository.save(allPossibleTypes);
List<AllPossibleTypes> result = allPossibleTypesRepository.findWithAnnotatedDateParameter(Date.from(instant));
assertThat(result).hasSize(1).contains(allPossibleTypes);
}
Aggregations