Skip to content

Commit 210019c

Browse files
committed
Polish contribution
See gh-29379
1 parent 39f24f0 commit 210019c

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/MariaDBSequenceMaxValueIncrementer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,11 +19,11 @@
1919
import javax.sql.DataSource;
2020

2121
/**
22-
* {@link DataFieldMaxValueIncrementer} that retrieves the next value
23-
* of a given MariaDB sequence.
22+
* {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given
23+
* MariaDB sequence.
2424
*
2525
* @author Mahmoud Ben Hassine
26-
* @since 6.0.0
26+
* @since 6.0
2727
*/
2828
public class MariaDBSequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer {
2929

spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,58 +169,58 @@ void mySQLMaxValueIncrementer() throws SQLException {
169169
}
170170

171171
@Test
172-
void oracleSequenceMaxValueIncrementer() throws SQLException {
172+
void mariaDBSequenceMaxValueIncrementer() throws SQLException {
173173
given(dataSource.getConnection()).willReturn(connection);
174174
given(connection.createStatement()).willReturn(statement);
175-
given(statement.executeQuery("select myseq.nextval from dual")).willReturn(resultSet);
175+
given(statement.executeQuery("select next value for myseq")).willReturn(resultSet);
176176
given(resultSet.next()).willReturn(true);
177177
given(resultSet.getLong(1)).willReturn(10L, 12L);
178178

179-
OracleSequenceMaxValueIncrementer incrementer = new OracleSequenceMaxValueIncrementer();
179+
MariaDBSequenceMaxValueIncrementer incrementer = new MariaDBSequenceMaxValueIncrementer();
180180
incrementer.setDataSource(dataSource);
181181
incrementer.setIncrementerName("myseq");
182-
incrementer.setPaddingLength(2);
182+
incrementer.setPaddingLength(5);
183183
incrementer.afterPropertiesSet();
184184

185-
assertThat(incrementer.nextLongValue()).isEqualTo(10);
186-
assertThat(incrementer.nextStringValue()).isEqualTo("12");
185+
assertThat(incrementer.nextStringValue()).isEqualTo("00010");
186+
assertThat(incrementer.nextIntValue()).isEqualTo(12);
187187

188188
verify(resultSet, times(2)).close();
189189
verify(statement, times(2)).close();
190190
verify(connection, times(2)).close();
191191
}
192192

193193
@Test
194-
void postgresSequenceMaxValueIncrementer() throws SQLException {
194+
void oracleSequenceMaxValueIncrementer() throws SQLException {
195195
given(dataSource.getConnection()).willReturn(connection);
196196
given(connection.createStatement()).willReturn(statement);
197-
given(statement.executeQuery("select nextval('myseq')")).willReturn(resultSet);
197+
given(statement.executeQuery("select myseq.nextval from dual")).willReturn(resultSet);
198198
given(resultSet.next()).willReturn(true);
199199
given(resultSet.getLong(1)).willReturn(10L, 12L);
200200

201-
PostgresSequenceMaxValueIncrementer incrementer = new PostgresSequenceMaxValueIncrementer();
201+
OracleSequenceMaxValueIncrementer incrementer = new OracleSequenceMaxValueIncrementer();
202202
incrementer.setDataSource(dataSource);
203203
incrementer.setIncrementerName("myseq");
204-
incrementer.setPaddingLength(5);
204+
incrementer.setPaddingLength(2);
205205
incrementer.afterPropertiesSet();
206206

207-
assertThat(incrementer.nextStringValue()).isEqualTo("00010");
208-
assertThat(incrementer.nextIntValue()).isEqualTo(12);
207+
assertThat(incrementer.nextLongValue()).isEqualTo(10);
208+
assertThat(incrementer.nextStringValue()).isEqualTo("12");
209209

210210
verify(resultSet, times(2)).close();
211211
verify(statement, times(2)).close();
212212
verify(connection, times(2)).close();
213213
}
214214

215215
@Test
216-
void mariaDBSequenceMaxValueIncrementer() throws SQLException {
216+
void postgresSequenceMaxValueIncrementer() throws SQLException {
217217
given(dataSource.getConnection()).willReturn(connection);
218218
given(connection.createStatement()).willReturn(statement);
219-
given(statement.executeQuery("select next value for myseq")).willReturn(resultSet);
219+
given(statement.executeQuery("select nextval('myseq')")).willReturn(resultSet);
220220
given(resultSet.next()).willReturn(true);
221221
given(resultSet.getLong(1)).willReturn(10L, 12L);
222222

223-
MariaDBSequenceMaxValueIncrementer incrementer = new MariaDBSequenceMaxValueIncrementer();
223+
PostgresSequenceMaxValueIncrementer incrementer = new PostgresSequenceMaxValueIncrementer();
224224
incrementer.setDataSource(dataSource);
225225
incrementer.setIncrementerName("myseq");
226226
incrementer.setPaddingLength(5);

0 commit comments

Comments
 (0)