Search in sources :

Example 1 with QueryMappingConfiguration

use of org.springframework.data.jdbc.repository.QueryMappingConfiguration in project spring-data-jdbc by spring-projects.

the class EnableJdbcRepositoriesIntegrationTests method customRowMapperConfigurationGetsPickedUp.

// DATAJDBC-166
@Test
public void customRowMapperConfigurationGetsPickedUp() {
    QueryMappingConfiguration mapping = (QueryMappingConfiguration) ReflectionUtils.getField(MAPPER_MAP, factoryBean);
    assertThat(mapping.getRowMapper(String.class)).isEqualTo(STRING_ROW_MAPPER);
    assertThat(mapping.getRowMapper(DummyEntity.class)).isEqualTo(DUMMY_ENTITY_ROW_MAPPER);
}
Also used : QueryMappingConfiguration(org.springframework.data.jdbc.repository.QueryMappingConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with QueryMappingConfiguration

use of org.springframework.data.jdbc.repository.QueryMappingConfiguration in project spring-data-jdbc by spring-projects.

the class ConfigurableRowMapperMapUnitTests method returnsNullForClassNotConfigured.

// DATAJDBC-166
@Test
public void returnsNullForClassNotConfigured() {
    RowMapper rowMapper = mock(RowMapper.class);
    QueryMappingConfiguration map = new DefaultQueryMappingConfiguration().registerRowMapper(Number.class, rowMapper);
    assertThat(map.getRowMapper(Integer.class)).isNull();
    assertThat(map.getRowMapper(String.class)).isNull();
}
Also used : QueryMappingConfiguration(org.springframework.data.jdbc.repository.QueryMappingConfiguration) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.jupiter.api.Test)

Example 3 with QueryMappingConfiguration

use of org.springframework.data.jdbc.repository.QueryMappingConfiguration in project spring-data-jdbc by spring-projects.

the class ConfigurableRowMapperMapUnitTests method returnsInstanceRegisteredForSubClass.

// DATAJDBC-166
@Test
public void returnsInstanceRegisteredForSubClass() {
    RowMapper rowMapper = mock(RowMapper.class);
    QueryMappingConfiguration map = new DefaultQueryMappingConfiguration().registerRowMapper(String.class, rowMapper);
    assertThat(map.getRowMapper(Object.class)).isEqualTo(rowMapper);
}
Also used : QueryMappingConfiguration(org.springframework.data.jdbc.repository.QueryMappingConfiguration) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.jupiter.api.Test)

Example 4 with QueryMappingConfiguration

use of org.springframework.data.jdbc.repository.QueryMappingConfiguration in project spring-data-jdbc by spring-projects.

the class ConfigurableRowMapperMapUnitTests method freshInstanceReturnsNull.

// DATAJDBC-166
@Test
public void freshInstanceReturnsNull() {
    QueryMappingConfiguration map = new DefaultQueryMappingConfiguration();
    assertThat(map.getRowMapper(Object.class)).isNull();
}
Also used : QueryMappingConfiguration(org.springframework.data.jdbc.repository.QueryMappingConfiguration) Test(org.junit.jupiter.api.Test)

Example 5 with QueryMappingConfiguration

use of org.springframework.data.jdbc.repository.QueryMappingConfiguration in project spring-data-jdbc by spring-projects.

the class ConfigurableRowMapperMapUnitTests method prefersExactTypeMatchClass.

// DATAJDBC-166
@Test
public void prefersExactTypeMatchClass() {
    RowMapper rowMapper = mock(RowMapper.class);
    QueryMappingConfiguration map = // 
    new DefaultQueryMappingConfiguration().registerRowMapper(Object.class, // 
    mock(RowMapper.class)).registerRowMapper(Integer.class, // 
    rowMapper).registerRowMapper(Number.class, mock(RowMapper.class));
    assertThat(map.getRowMapper(Integer.class)).isEqualTo(rowMapper);
}
Also used : QueryMappingConfiguration(org.springframework.data.jdbc.repository.QueryMappingConfiguration) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)9 QueryMappingConfiguration (org.springframework.data.jdbc.repository.QueryMappingConfiguration)9 RowMapper (org.springframework.jdbc.core.RowMapper)7 DefaultQueryMappingConfiguration (org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration)2 RepositoryQuery (org.springframework.data.repository.query.RepositoryQuery)2 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)2