use of org.springframework.data.relational.core.mapping.RelationalPersistentProperty in project spring-data-jdbc by spring-projects.
the class MyBatisDataAccessStrategyUnitTests method findAllByPath.
@SuppressWarnings("unchecked")
// DATAJDBC-384
@Test
public void findAllByPath() {
RelationalPersistentProperty property = mock(RelationalPersistentProperty.class, RETURNS_DEEP_STUBS);
PersistentPropertyPath path = mock(PersistentPropertyPath.class, RETURNS_DEEP_STUBS);
when(path.getBaseProperty()).thenReturn(property);
when(property.getOwner().getType()).thenReturn((Class) String.class);
when(path.getRequiredLeafProperty()).thenReturn(property);
when(property.getType()).thenReturn((Class) Number.class);
when(path.toDotPath()).thenReturn("dot.path");
accessStrategy.findAllByPath(Identifier.empty(), path);
verify(session).selectList(eq("java.lang.StringMapper.findAllByPath-dot.path"), captor.capture());
//
assertThat(captor.getValue()).isNotNull().extracting(//
MyBatisContext::getInstance, //
MyBatisContext::getId, //
MyBatisContext::getIdentifier, //
MyBatisContext::getDomainType, //
c -> c.get("key")).containsExactly(//
null, //
null, //
Identifier.empty(), //
Number.class, //
null);
}
use of org.springframework.data.relational.core.mapping.RelationalPersistentProperty in project spring-data-jdbc by spring-projects.
the class BasicJdbcConverterUnitTests method checkConversionToTimestampAndBack.
private void checkConversionToTimestampAndBack(SoftAssertions softly, RelationalPersistentEntity<?> persistentEntity, String propertyName, Object value) {
RelationalPersistentProperty property = persistentEntity.getRequiredPersistentProperty(propertyName);
Object converted = converter.writeValue(value, ClassTypeInformation.from(converter.getColumnType(property)));
Object convertedBack = converter.readValue(converted, property.getTypeInformation());
softly.assertThat(convertedBack).describedAs(propertyName).isEqualTo(value);
}
use of org.springframework.data.relational.core.mapping.RelationalPersistentProperty in project spring-data-jdbc by spring-projects.
the class BasicRelationalConverterAggregateReferenceUnitTests method convertsToAggregateReference.
// DATAJDBC-221
@Test
public void convertsToAggregateReference() {
final RelationalPersistentProperty property = entity.getRequiredPersistentProperty("reference");
Object readValue = converter.readValue(23, property.getTypeInformation());
Assertions.assertThat(readValue).isInstanceOf(AggregateReference.class);
assertThat(((AggregateReference<DummyEntity, Long>) readValue).getId()).isEqualTo(23L);
}
use of org.springframework.data.relational.core.mapping.RelationalPersistentProperty in project spring-data-jdbc by spring-projects.
the class BasicJdbcPersistentPropertyUnitTests method detectsKeyColumnOverrideNameFromMappedCollectionAnnotation.
// DATAJDBC-331
@Test
public void detectsKeyColumnOverrideNameFromMappedCollectionAnnotation() {
RelationalPersistentProperty listProperty = //
context.getRequiredPersistentEntity(//
WithCollections.class).getRequiredPersistentProperty("overrideList");
PersistentPropertyPathExtension path = getPersistentPropertyPath(WithCollections.class, "overrideList");
assertThat(listProperty.getKeyColumn()).isEqualTo(quoted("override_key"));
assertThat(listProperty.getReverseColumnName(path)).isEqualTo(quoted("override_id"));
}
use of org.springframework.data.relational.core.mapping.RelationalPersistentProperty in project spring-data-jdbc by spring-projects.
the class BasicJdbcPersistentPropertyUnitTests method detectsAnnotatedColumnAndKeyName.
// DATAJDBC-218
@Test
public void detectsAnnotatedColumnAndKeyName() {
String propertyName = "someList";
RelationalPersistentProperty listProperty = entity.getRequiredPersistentProperty(propertyName);
PersistentPropertyPathExtension path = getPersistentPropertyPath(DummyEntity.class, propertyName);
assertThat(listProperty.getReverseColumnName(path)).isEqualTo(quoted("dummy_column_name"));
assertThat(listProperty.getKeyColumn()).isEqualTo(quoted("dummy_key_column_name"));
}
Aggregations