From ea265f4856d14421bea28d1dccf2f155e5ca30c6 Mon Sep 17 00:00:00 2001 From: Scott Leberknight <174812+sleberknight@users.noreply.github.com> Date: Mon, 8 Jul 2024 12:25:22 -0400 Subject: [PATCH] Sonar: rename fields idiomatically (#387) * Rename non-final static fields in several tests from DATA_SOURCE to dataSource. The field cannot be final b/c they are set up in the BeforeAll method. --- .../jdbi3/H2Jdbi3ApplicationErrorDaoTest.java | 16 ++++++++-------- .../SqliteJdbi3ApplicationErrorDaoTest.java | 8 ++++---- .../dao/jdk/H2JdbcApplicationErrorDaoTest.java | 10 +++++----- .../jdk/MySqlJdbcApplicationErrorDaoTest.java | 6 +++--- .../jdk/SqliteJdbcApplicationErrorDaoTest.java | 8 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/H2Jdbi3ApplicationErrorDaoTest.java b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/H2Jdbi3ApplicationErrorDaoTest.java index 78f58a1..e0cc7f1 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/H2Jdbi3ApplicationErrorDaoTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/H2Jdbi3ApplicationErrorDaoTest.java @@ -16,29 +16,29 @@ @DisplayName("Jdbi3ApplicationErrorDao (H2)") class H2Jdbi3ApplicationErrorDaoTest extends AbstractJdbi3ApplicationErrorDaoTest { - private static JdbcDataSource DATA_SOURCE; + private static JdbcDataSource dataSource; @BeforeAll static void beforeAll() { var dataSourceFactory = ApplicationErrorJdbc.createInMemoryH2Database(); - DATA_SOURCE = new JdbcDataSource(); - DATA_SOURCE.setUrl(dataSourceFactory.getUrl()); - DATA_SOURCE.setUser(dataSourceFactory.getUser()); - DATA_SOURCE.setPassword(dataSourceFactory.getPassword()); + dataSource = new JdbcDataSource(); + dataSource.setUrl(dataSourceFactory.getUrl()); + dataSource.setUser(dataSourceFactory.getUser()); + dataSource.setPassword(dataSourceFactory.getPassword()); } @AfterAll static void afterAll() throws SQLException { - shutdownH2Database(DATA_SOURCE); + shutdownH2Database(dataSource); - DATA_SOURCE = null; + dataSource = null; } @RegisterExtension final Jdbi3DaoExtension jdbi3DaoExtension = Jdbi3DaoExtension.builder() .daoType(Jdbi3ApplicationErrorDao.class) - .dataSource(DATA_SOURCE) + .dataSource(dataSource) .plugin(new H2DatabasePlugin()) .build(); diff --git a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/SqliteJdbi3ApplicationErrorDaoTest.java b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/SqliteJdbi3ApplicationErrorDaoTest.java index d6afed4..85b6db4 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/SqliteJdbi3ApplicationErrorDaoTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/SqliteJdbi3ApplicationErrorDaoTest.java @@ -12,19 +12,19 @@ @DisplayName("Jdbi3ApplicationErrorDao (SQLite)") class SqliteJdbi3ApplicationErrorDaoTest extends AbstractJdbi3ApplicationErrorDaoTest { - private static SimpleSingleConnectionDataSource DATA_SOURCE; + private static SimpleSingleConnectionDataSource dataSource; @BeforeAll static void beforeAll() { - DATA_SOURCE = newInMemorySqliteDataSource(); - migrateDatabase(DATA_SOURCE, "dropwizard-app-errors-migrations-sqlite.xml"); + dataSource = newInMemorySqliteDataSource(); + migrateDatabase(dataSource, "dropwizard-app-errors-migrations-sqlite.xml"); } @RegisterExtension final Jdbi3DaoExtension jdbi3DaoExtension = Jdbi3DaoExtension.builder() .daoType(Jdbi3ApplicationErrorDao.class) - .dataSource(DATA_SOURCE) + .dataSource(dataSource) .build(); @Override diff --git a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/H2JdbcApplicationErrorDaoTest.java b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/H2JdbcApplicationErrorDaoTest.java index f2e5886..0b63e94 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/H2JdbcApplicationErrorDaoTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/H2JdbcApplicationErrorDaoTest.java @@ -13,13 +13,13 @@ @DisplayName("JdbcApplicationErrorDao (H2)") public class H2JdbcApplicationErrorDaoTest extends AbstractJdbcApplicationErrorDaoTest { - private static SimpleSingleConnectionDataSource DATA_SOURCE; + private static SimpleSingleConnectionDataSource dataSource; @BeforeAll static void beforeAll() { var dataSourceFactory = ApplicationErrorJdbc.createInMemoryH2Database(); - DATA_SOURCE = new SimpleSingleConnectionDataSource( + dataSource = new SimpleSingleConnectionDataSource( dataSourceFactory.getUrl(), dataSourceFactory.getUser(), dataSourceFactory.getPassword()); @@ -27,13 +27,13 @@ static void beforeAll() { @AfterAll static void afterAll() throws SQLException { - shutdownH2Database(DATA_SOURCE); + shutdownH2Database(dataSource); - DATA_SOURCE = null; + dataSource = null; } @Override protected SimpleSingleConnectionDataSource getDataSource() { - return DATA_SOURCE; + return dataSource; } } diff --git a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java index 0875a9c..e7fb852 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java @@ -14,7 +14,7 @@ @DisplayName("JdbcApplicationErrorDao (MySQL)") class MySqlJdbcApplicationErrorDaoTest extends AbstractJdbcApplicationErrorDaoTest { - private static SimpleSingleConnectionDataSource DATA_SOURCE; + private static SimpleSingleConnectionDataSource dataSource; @Container private static final MySQLContainer MYSQL = newLatestMySQLContainer(); @@ -23,12 +23,12 @@ class MySqlJdbcApplicationErrorDaoTest extends AbstractJdbcApplicationErrorDaoTe static void beforeAll() { migrateDatabase(MYSQL, "dropwizard-app-errors-migrations-mysql.xml"); - DATA_SOURCE = new SimpleSingleConnectionDataSource( + dataSource = new SimpleSingleConnectionDataSource( MYSQL.getJdbcUrl(), MYSQL.getUsername(), MYSQL.getPassword()); } @Override protected SimpleSingleConnectionDataSource getDataSource() { - return DATA_SOURCE; + return dataSource; } } diff --git a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/SqliteJdbcApplicationErrorDaoTest.java b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/SqliteJdbcApplicationErrorDaoTest.java index 7a29c63..fb2c11a 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/SqliteJdbcApplicationErrorDaoTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/SqliteJdbcApplicationErrorDaoTest.java @@ -10,16 +10,16 @@ @DisplayName("JdbcApplicationErrorDao (SQLite)") class SqliteJdbcApplicationErrorDaoTest extends AbstractJdbcApplicationErrorDaoTest { - private static SimpleSingleConnectionDataSource DATA_SOURCE; + private static SimpleSingleConnectionDataSource dataSource; @BeforeAll static void beforeAll() { - DATA_SOURCE = newInMemorySqliteDataSource(); - migrateDatabase(DATA_SOURCE, "dropwizard-app-errors-migrations-sqlite.xml"); + dataSource = newInMemorySqliteDataSource(); + migrateDatabase(dataSource, "dropwizard-app-errors-migrations-sqlite.xml"); } @Override protected SimpleSingleConnectionDataSource getDataSource() { - return DATA_SOURCE; + return dataSource; } }