Replace String concatenation with text blocks where appropriate

This commit is contained in:
Mahmoud Ben Hassine
2023-06-12 15:55:32 +02:00
parent 0f44e2bad1
commit a193fc3688
3 changed files with 34 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 the original author or authors.
* Copyright 2016-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -234,9 +234,8 @@ class JdbcBatchItemWriterBuilderTests {
private void verifyRow(int i, String i1, String nine) {
JdbcOperations template = new JdbcTemplate(this.dataSource);
assertEquals(1,
(int) template.queryForObject("select count(*) from foo where first = ? and second = ? and third = ?",
Integer.class, i, i1, nine));
String sql = "select count(*) from foo where first = ? and second = ? and third = ?";
assertEquals(1, (int) template.queryForObject(sql, Integer.class, i, i1, nine));
}
public static class Foo {
@@ -282,9 +281,12 @@ class JdbcBatchItemWriterBuilderTests {
@Configuration
public static class TestDataSourceConfiguration {
private static final String CREATE_SQL = "CREATE TABLE FOO (\n"
+ "\tID BIGINT IDENTITY NOT NULL PRIMARY KEY ,\n" + "\tFIRST BIGINT ,\n"
+ "\tSECOND VARCHAR(5) NOT NULL,\n" + "\tTHIRD VARCHAR(5) NOT NULL) ;";
private static final String CREATE_SQL = """
CREATE TABLE FOO (
ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
FIRST BIGINT ,
SECOND VARCHAR(5) NOT NULL,
THIRD VARCHAR(5) NOT NULL) ;""";
@Bean
public DataSource dataSource() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 the original author or authors.
* Copyright 2016-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -378,13 +378,17 @@ class JdbcCursorItemReaderBuilderTests {
@Configuration
public static class TestDataSourceConfiguration {
private static final String CREATE_SQL = "CREATE TABLE FOO (\n"
+ "\tID BIGINT IDENTITY NOT NULL PRIMARY KEY ,\n" + "\tFIRST BIGINT ,\n"
+ "\tSECOND VARCHAR(5) NOT NULL,\n" + "\tTHIRD VARCHAR(5) NOT NULL) ;";
private static final String CREATE_SQL = """
CREATE TABLE FOO (
ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
FIRST BIGINT ,
SECOND VARCHAR(5) NOT NULL,
THIRD VARCHAR(5) NOT NULL);""";
private static final String INSERT_SQL = "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (1, '2', '3');"
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (4, '5', '6');"
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (7, '8', '9');";
private static final String INSERT_SQL = """
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (1, '2', '3');
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (4, '5', '6');
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (7, '8', '9');""";
@Bean
public DataSource dataSource() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 the original author or authors.
* Copyright 2017-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Michael Minella
* @author Drummond Dawson
* @author Mahmoud Ben Hassine
*/
class JdbcPagingItemReaderBuilderTests {
@@ -356,15 +357,19 @@ class JdbcPagingItemReaderBuilderTests {
@Configuration
public static class TestDataSourceConfiguration {
private static final String CREATE_SQL = "CREATE TABLE FOO (\n"
+ "\tID BIGINT IDENTITY NOT NULL PRIMARY KEY ,\n" + "\tFIRST BIGINT ,\n"
+ "\tSECOND VARCHAR(5) NOT NULL,\n" + "\tTHIRD VARCHAR(5) NOT NULL) ;";
private static final String CREATE_SQL = """
CREATE TABLE FOO (
ID BIGINT IDENTITY NOT NULL PRIMARY KEY ,
FIRST BIGINT ,
SECOND VARCHAR(5) NOT NULL,
THIRD VARCHAR(5) NOT NULL) ;""";
private static final String INSERT_SQL = "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (1, '2', '3');"
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (4, '5', '6');"
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (7, '8', '9');"
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (10, '11', '12');"
+ "INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (13, '14', '15');";
private static final String INSERT_SQL = """
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (1, '2', '3');
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (4, '5', '6');
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (7, '8', '9');
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (10, '11', '12');
INSERT INTO FOO (FIRST, SECOND, THIRD) VALUES (13, '14', '15');""";
@Bean
public DataSource dataSource() {