Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6d63b5e

Browse files
committed
#492 - Polishing.
Use Java 8 syntax for Map creation. Add author tags. Use simpler table names. Original pull request: #493.
1 parent d80b8d5 commit 6d63b5e

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

‎src/main/java/org/springframework/data/r2dbc/dialect/PostgresDialect.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* An SQL dialect for Postgres.
3636
*
3737
* @author Mark Paluch
38+
* @author Jose Luis Leon
3839
*/
3940
public class PostgresDialect extends org.springframework.data.relational.core.dialect.PostgresDialect
4041
implements R2dbcDialect {
@@ -49,7 +50,8 @@ public class PostgresDialect extends org.springframework.data.relational.core.di
4950

5051
static {
5152

52-
Set<Class<?>> simpleTypes = new HashSet<>(Arrays.asList(UUID.class, URL.class, URI.class, InetAddress.class, Map.class));
53+
Set<Class<?>> simpleTypes = new HashSet<>(
54+
Arrays.asList(UUID.class, URL.class, URI.class, InetAddress.class, Map.class));
5355

5456
// conditional Postgres Geo support.
5557
Stream.of("io.r2dbc.postgresql.codec.Box", //

‎src/test/java/org/springframework/data/r2dbc/repository/PostgresR2dbcRepositoryIntegrationTests.java

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20-
import java.util.Map;
21-
2220
import io.r2dbc.postgresql.codec.Json;
2321
import io.r2dbc.spi.ConnectionFactory;
2422
import lombok.AllArgsConstructor;
2523
import reactor.core.publisher.Flux;
2624
import reactor.core.publisher.Mono;
2725
import reactor.test.StepVerifier;
2826

27+
import java.util.Collections;
28+
import java.util.Map;
29+
2930
import javax.sql.DataSource;
3031

3132
import org.junit.jupiter.api.Test;
@@ -55,21 +56,23 @@
5556
* Integration tests for {@link LegoSetRepository} using {@link R2dbcRepositoryFactory} against Postgres.
5657
*
5758
* @author Mark Paluch
59+
* @author Jose Luis Leon
5860
*/
5961
@ExtendWith(SpringExtension.class)
6062
@ContextConfiguration
6163
public class PostgresR2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIntegrationTests {
6264

6365
@RegisterExtension public static final ExternalDatabase database = PostgresTestSupport.database();
6466

65-
@Autowired JsonPersonRepositoryjsonPersonRepository;
67+
@Autowired WithJsonRepositorywithJsonRepository;
6668

67-
@Autowired HStorePersonRepositoryhstorePersonRepository;
69+
@Autowired WithHStoreRepositoryhstoreRepositoryWith;
6870

6971
@Configuration
7072
@EnableR2dbcRepositories(considerNestedRepositories = true,
71-
includeFilters = @Filter(classes = { PostgresLegoSetRepository.class, JsonPersonRepository.class,
72-
HStorePersonRepository.class }, type = FilterType.ASSIGNABLE_TYPE))
73+
includeFilters = @Filter(
74+
classes = { PostgresLegoSetRepository.class, WithJsonRepository.class, WithHStoreRepository.class },
75+
type = FilterType.ASSIGNABLE_TYPE))
7376
static class IntegrationTestConfiguration extends AbstractR2dbcConfiguration {
7477

7578
@Bean
@@ -136,66 +139,64 @@ void shouldSaveAndLoadJson() {
136139

137140
JdbcTemplate template = new JdbcTemplate(createDataSource());
138141

139-
template.execute("DROP TABLE IF EXISTS json_person");
140-
template.execute("CREATE TABLE json_person (\n" //
142+
template.execute("DROP TABLE IF EXISTS with_json");
143+
template.execute("CREATE TABLE with_json (\n" //
141144
+ " id SERIAL PRIMARY KEY,\n" //
142145
+ " json_value JSONB NOT NULL" //
143146
+ ");");
144147

145-
JsonPerson person = new JsonPerson(null, Json.of("{\"hello\": \"world\"}"));
146-
jsonPersonRepository.save(person).as(StepVerifier::create).expectNextCount(1).verifyComplete();
148+
WithJson person = new WithJson(null, Json.of("{\"hello\": \"world\"}"));
149+
withJsonRepository.save(person).as(StepVerifier::create).expectNextCount(1).verifyComplete();
147150

148-
jsonPersonRepository.findAll().as(StepVerifier::create).consumeNextWith(actual -> {
151+
withJsonRepository.findAll().as(StepVerifier::create).consumeNextWith(actual -> {
149152

150153
assertThat(actual.jsonValue).isNotNull();
151154
assertThat(actual.jsonValue.asString()).isEqualTo("{\"hello\": \"world\"}");
152155
}).verifyComplete();
153156
}
154157

155-
@Test
158+
@Test// gh-492
156159
void shouldSaveAndLoadHStore() {
157160

158161
JdbcTemplate template = new JdbcTemplate(createDataSource());
159162

160-
template.execute("DROP TABLE IF EXISTS hstore_person");
163+
template.execute("DROP TABLE IF EXISTS with_hstore");
161164
template.execute("CREATE EXTENSION IF NOT EXISTS hstore;");
162-
template.execute("CREATE TABLE hstore_person (\n" //
163-
+ " id SERIAL PRIMARY KEY,\n" //
164-
+ " hstore_value HSTORE NOT NULL" //
165-
+ ");");
165+
template.execute("CREATE TABLE with_hstore (" //
166+
+ " id SERIAL PRIMARY KEY," //
167+
+ " hstore_value HSTORE NOT NULL);");
166168

167-
HStorePerson person = new HStorePerson(null, Map.of("hello", "world"));
168-
hstorePersonRepository.save(person).as(StepVerifier::create).expectNextCount(1).verifyComplete();
169+
WithHStore person = new WithHStore(null, Collections.singletonMap("hello", "world"));
170+
hstoreRepositoryWith.save(person).as(StepVerifier::create).expectNextCount(1).verifyComplete();
169171

170-
hstorePersonRepository.findAll().as(StepVerifier::create).consumeNextWith(actual -> {
172+
hstoreRepositoryWith.findAll().as(StepVerifier::create).consumeNextWith(actual -> {
171173

172-
assertThat(actual.hstoreValue).isNotNull();
173-
assertThat(actual.hstoreValue).containsEntry("hello", "world");
174+
assertThat(actual.hstoreValue).isNotNull().containsEntry("hello", "world");
174175
}).verifyComplete();
175176
}
176177

177178
@AllArgsConstructor
178-
static class JsonPerson {
179+
static class WithJson {
179180

180181
@Id Long id;
181182

182183
Json jsonValue;
183184
}
184185

185-
interface JsonPersonRepository extends ReactiveCrudRepository<JsonPerson, Long> {
186+
interface WithJsonRepository extends ReactiveCrudRepository<WithJson, Long> {
186187

187188
}
188189

189190
@AllArgsConstructor
190-
@Table("hstore_person")
191-
static class HStorePerson {
191+
@Table("with_hstore")
192+
static class WithHStore {
192193

193194
@Id Long id;
194195

195196
Map<String, String> hstoreValue;
196197
}
197198

198-
interface HStorePersonRepository extends ReactiveCrudRepository<HStorePerson, Long> {
199+
interface WithHStoreRepository extends ReactiveCrudRepository<WithHStore, Long> {
199200

200201
}
201202
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /