Skip to content

Commit a193fc3

Browse files
committed
Replace String concatenation with text blocks where appropriate
1 parent 0f44e2b commit a193fc3

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JdbcBatchItemWriterBuilderTests.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 the original author or authors.
2+
* Copyright 2016-2023 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.
@@ -234,9 +234,8 @@ private Chunk<Map<String, Object>> buildMapItems() {
234234
private void verifyRow(int i, String i1, String nine) {
235235
JdbcOperations template = new JdbcTemplate(this.dataSource);
236236

237-
assertEquals(1,
238-
(int) template.queryForObject("select count(*) from foo where first = ? and second = ? and third = ?",
239-
Integer.class, i, i1, nine));
237+
String sql = "select count(*) from foo where first = ? and second = ? and third = ?";
238+
assertEquals(1, (int) template.queryForObject(sql, Integer.class, i, i1, nine));
240239
}
241240

242241
public static class Foo {
@@ -282,9 +281,12 @@ public void setThird(String third) {
282281
@Configuration
283282
public static class TestDataSourceConfiguration {
284283

285-
private static final String CREATE_SQL = "CREATE TABLE FOO (\n"
286-
+ "\tID BIGINT IDENTITY NOT NULL PRIMARY KEY ,\n" + "\tFIRST BIGINT ,\n"
287-
+ "\tSECOND VARCHAR(5) NOT NULL,\n" + "\tTHIRD VARCHAR(5) NOT NULL) ;";
284+
private static final String CREATE_SQL = """
285+
CREATE TABLE FOO (
286+
ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
287+
FIRST BIGINT ,
288+
SECOND VARCHAR(5) NOT NULL,
289+
THIRD VARCHAR(5) NOT NULL) ;""";
288290

289291
@Bean
290292
public DataSource dataSource() {

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilderTests.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 the original author or authors.
2+
* Copyright 2016-2023 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.
@@ -378,13 +378,17 @@ public void setThird(String third) {
378378
@Configuration
379379
public static class TestDataSourceConfiguration {
380380

381-
private static final String CREATE_SQL = "CREATE TABLE FOO (\n"
382-
+ "\tID BIGINT IDENTITY NOT NULL PRIMARY KEY ,\n" + "\tFIRST BIGINT ,\n"
383-
+ "\tSECOND VARCHAR(5) NOT NULL,\n" + "\tTHIRD VARCHAR(5) NOT NULL) ;";
384-
385-
private static final String INSERT_SQL = "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (1, '2', '3');"
386-
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (4, '5', '6');"
387-
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (7, '8', '9');";
381+
private static final String CREATE_SQL = """
382+
CREATE TABLE FOO (
383+
ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
384+
FIRST BIGINT ,
385+
SECOND VARCHAR(5) NOT NULL,
386+
THIRD VARCHAR(5) NOT NULL);""";
387+
388+
private static final String INSERT_SQL = """
389+
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (1, '2', '3');
390+
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (4, '5', '6');
391+
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (7, '8', '9');""";
388392

389393
@Bean
390394
public DataSource dataSource() {

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JdbcPagingItemReaderBuilderTests.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2022 the original author or authors.
2+
* Copyright 2017-2023 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.
@@ -46,6 +46,7 @@
4646
/**
4747
* @author Michael Minella
4848
* @author Drummond Dawson
49+
* @author Mahmoud Ben Hassine
4950
*/
5051
class JdbcPagingItemReaderBuilderTests {
5152

@@ -356,15 +357,19 @@ public void setThird(String third) {
356357
@Configuration
357358
public static class TestDataSourceConfiguration {
358359

359-
private static final String CREATE_SQL = "CREATE TABLE FOO (\n"
360-
+ "\tID BIGINT IDENTITY NOT NULL PRIMARY KEY ,\n" + "\tFIRST BIGINT ,\n"
361-
+ "\tSECOND VARCHAR(5) NOT NULL,\n" + "\tTHIRD VARCHAR(5) NOT NULL) ;";
362-
363-
private static final String INSERT_SQL = "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (1, '2', '3');"
364-
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (4, '5', '6');"
365-
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (7, '8', '9');"
366-
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (10, '11', '12');"
367-
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (13, '14', '15');";
360+
private static final String CREATE_SQL = """
361+
CREATE TABLE FOO (
362+
ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
363+
FIRST BIGINT ,
364+
SECOND VARCHAR(5) NOT NULL,
365+
THIRD VARCHAR(5) NOT NULL) ;""";
366+
367+
private static final String INSERT_SQL = """
368+
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (1, '2', '3');
369+
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (4, '5', '6');
370+
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (7, '8', '9');
371+
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (10, '11', '12');
372+
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (13, '14', '15');""";
368373

369374
@Bean
370375
public DataSource dataSource() {

0 commit comments

Comments
 (0)