Search in sources :

Example 1 with BasicJdbcConverter

use of org.springframework.data.jdbc.core.convert.BasicJdbcConverter in project spring-data-jdbc by spring-projects.

the class JdbcAggregateTemplateUnitTests method setUp.

@BeforeEach
public void setUp() {
    RelationalMappingContext mappingContext = new RelationalMappingContext(NamingStrategy.INSTANCE);
    JdbcConverter converter = new BasicJdbcConverter(mappingContext, relationResolver);
    template = new JdbcAggregateTemplate(eventPublisher, mappingContext, converter, dataAccessStrategy);
    ((JdbcAggregateTemplate) template).setEntityCallbacks(callbacks);
}
Also used : BasicJdbcConverter(org.springframework.data.jdbc.core.convert.BasicJdbcConverter) BasicJdbcConverter(org.springframework.data.jdbc.core.convert.BasicJdbcConverter) JdbcConverter(org.springframework.data.jdbc.core.convert.JdbcConverter) RelationalMappingContext(org.springframework.data.relational.core.mapping.RelationalMappingContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with BasicJdbcConverter

use of org.springframework.data.jdbc.core.convert.BasicJdbcConverter in project spring-data-jdbc by spring-projects.

the class JdbcRepositoryFactoryBeanUnitTests method setsUpBasicInstanceCorrectly.

// DATAJDBC-151
@Test
public void setsUpBasicInstanceCorrectly() {
    factoryBean.setDataAccessStrategy(dataAccessStrategy);
    factoryBean.setMappingContext(mappingContext);
    factoryBean.setConverter(new BasicJdbcConverter(mappingContext, dataAccessStrategy));
    factoryBean.setApplicationEventPublisher(publisher);
    factoryBean.setBeanFactory(beanFactory);
    factoryBean.setDialect(dialect);
    factoryBean.afterPropertiesSet();
    assertThat(factoryBean.getObject()).isNotNull();
}
Also used : BasicJdbcConverter(org.springframework.data.jdbc.core.convert.BasicJdbcConverter) Test(org.junit.jupiter.api.Test)

Example 3 with BasicJdbcConverter

use of org.springframework.data.jdbc.core.convert.BasicJdbcConverter in project spring-data-jdbc by spring-projects.

the class StringBasedJdbcQueryUnitTests method setup.

@BeforeEach
void setup() throws NoSuchMethodException {
    this.defaultRowMapper = mock(RowMapper.class);
    this.operations = mock(NamedParameterJdbcOperations.class);
    this.context = mock(RelationalMappingContext.class, RETURNS_DEEP_STUBS);
    this.converter = new BasicJdbcConverter(context, mock(RelationResolver.class));
}
Also used : BasicJdbcConverter(org.springframework.data.jdbc.core.convert.BasicJdbcConverter) RelationalMappingContext(org.springframework.data.relational.core.mapping.RelationalMappingContext) RowMapper(org.springframework.jdbc.core.RowMapper) NamedParameterJdbcOperations(org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with BasicJdbcConverter

use of org.springframework.data.jdbc.core.convert.BasicJdbcConverter in project spring-data-jdbc by spring-projects.

the class JdbcRepositoryFactoryBeanUnitTests method afterPropertiesSetDefaultsNullablePropertiesCorrectly.

// DATAJDBC-155
@Test
public void afterPropertiesSetDefaultsNullablePropertiesCorrectly() {
    factoryBean.setMappingContext(mappingContext);
    factoryBean.setConverter(new BasicJdbcConverter(mappingContext, dataAccessStrategy));
    factoryBean.setApplicationEventPublisher(publisher);
    factoryBean.setBeanFactory(beanFactory);
    factoryBean.setDialect(dialect);
    factoryBean.afterPropertiesSet();
    assertThat(factoryBean.getObject()).isNotNull();
    assertThat(ReflectionTestUtils.getField(factoryBean, "dataAccessStrategy")).isInstanceOf(DefaultDataAccessStrategy.class);
    assertThat(ReflectionTestUtils.getField(factoryBean, "queryMappingConfiguration")).isEqualTo(QueryMappingConfiguration.EMPTY);
}
Also used : BasicJdbcConverter(org.springframework.data.jdbc.core.convert.BasicJdbcConverter) Test(org.junit.jupiter.api.Test)

Example 5 with BasicJdbcConverter

use of org.springframework.data.jdbc.core.convert.BasicJdbcConverter in project spring-data-jdbc by spring-projects.

the class SimpleJdbcRepositoryEventsUnitTests method before.

@BeforeEach
public void before() {
    RelationalMappingContext context = new JdbcMappingContext();
    NamedParameterJdbcOperations operations = createIdGeneratingOperations();
    DelegatingDataAccessStrategy delegatingDataAccessStrategy = new DelegatingDataAccessStrategy();
    Dialect dialect = HsqlDbDialect.INSTANCE;
    JdbcConverter converter = new BasicJdbcConverter(context, delegatingDataAccessStrategy, new JdbcCustomConversions(), new DefaultJdbcTypeFactory(operations.getJdbcOperations()), dialect.getIdentifierProcessing());
    SqlGeneratorSource generatorSource = new SqlGeneratorSource(context, converter, dialect);
    this.dataAccessStrategy = spy(new DefaultDataAccessStrategy(generatorSource, context, converter, operations));
    delegatingDataAccessStrategy.setDelegate(dataAccessStrategy);
    doReturn(true).when(dataAccessStrategy).update(any(), any());
    JdbcRepositoryFactory factory = new JdbcRepositoryFactory(dataAccessStrategy, context, converter, H2Dialect.INSTANCE, publisher, operations);
    this.repository = factory.getRepository(DummyEntityRepository.class);
}
Also used : BasicJdbcConverter(org.springframework.data.jdbc.core.convert.BasicJdbcConverter) RelationalMappingContext(org.springframework.data.relational.core.mapping.RelationalMappingContext) DefaultDataAccessStrategy(org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy) JdbcRepositoryFactory(org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory) NamedParameterJdbcOperations(org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations) JdbcCustomConversions(org.springframework.data.jdbc.core.convert.JdbcCustomConversions) JdbcMappingContext(org.springframework.data.jdbc.core.mapping.JdbcMappingContext) BasicJdbcConverter(org.springframework.data.jdbc.core.convert.BasicJdbcConverter) JdbcConverter(org.springframework.data.jdbc.core.convert.JdbcConverter) Dialect(org.springframework.data.relational.core.dialect.Dialect) H2Dialect(org.springframework.data.relational.core.dialect.H2Dialect) HsqlDbDialect(org.springframework.data.relational.core.dialect.HsqlDbDialect) DefaultJdbcTypeFactory(org.springframework.data.jdbc.core.convert.DefaultJdbcTypeFactory) SqlGeneratorSource(org.springframework.data.jdbc.core.convert.SqlGeneratorSource) DelegatingDataAccessStrategy(org.springframework.data.jdbc.core.convert.DelegatingDataAccessStrategy) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BasicJdbcConverter (org.springframework.data.jdbc.core.convert.BasicJdbcConverter)6 BeforeEach (org.junit.jupiter.api.BeforeEach)3 RelationalMappingContext (org.springframework.data.relational.core.mapping.RelationalMappingContext)3 Test (org.junit.jupiter.api.Test)2 DefaultJdbcTypeFactory (org.springframework.data.jdbc.core.convert.DefaultJdbcTypeFactory)2 JdbcConverter (org.springframework.data.jdbc.core.convert.JdbcConverter)2 NamedParameterJdbcOperations (org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations)2 Bean (org.springframework.context.annotation.Bean)1 DefaultDataAccessStrategy (org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy)1 DelegatingDataAccessStrategy (org.springframework.data.jdbc.core.convert.DelegatingDataAccessStrategy)1 JdbcCustomConversions (org.springframework.data.jdbc.core.convert.JdbcCustomConversions)1 SqlGeneratorSource (org.springframework.data.jdbc.core.convert.SqlGeneratorSource)1 JdbcArrayColumns (org.springframework.data.jdbc.core.dialect.JdbcArrayColumns)1 JdbcDialect (org.springframework.data.jdbc.core.dialect.JdbcDialect)1 JdbcMappingContext (org.springframework.data.jdbc.core.mapping.JdbcMappingContext)1 JdbcRepositoryFactory (org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory)1 Dialect (org.springframework.data.relational.core.dialect.Dialect)1 H2Dialect (org.springframework.data.relational.core.dialect.H2Dialect)1 HsqlDbDialect (org.springframework.data.relational.core.dialect.HsqlDbDialect)1 RowMapper (org.springframework.jdbc.core.RowMapper)1