Skip to content

Commit 2fb75f5

Browse files
committed
tests: Use final and add constructor where needed
1 parent 5d995de commit 2fb75f5

File tree

21 files changed

+42
-39
lines changed

21 files changed

+42
-39
lines changed

src/test/java/org/apache/ibatis/builder/XmlConfigBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ void propertiesSpecifyResourceAndUrlAtSameTime() {
333333
"The properties element cannot specify both a URL and a resource based property file reference. Please specify one or the other.");
334334
}
335335

336-
static class MySqlProvider {
336+
static final class MySqlProvider {
337337
@SuppressWarnings("unused")
338338
public static String provideSql() {
339339
return "SELECT 1";

src/test/java/org/apache/ibatis/databases/blog/StoredProcedures.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -21,7 +21,7 @@
2121
import java.sql.ResultSet;
2222
import java.sql.SQLException;
2323

24-
public class StoredProcedures {
24+
public final class StoredProcedures {
2525
public static void selectTwoSetsOfTwoAuthors(int p1, int p2, ResultSet[] rs1, ResultSet[] rs2) throws SQLException {
2626
try (Connection conn = DriverManager.getConnection("jdbc:default:connection")) {
2727
PreparedStatement ps1 = conn.prepareStatement("select * from author where id in (?,?)");

src/test/java/org/apache/ibatis/executor/ExecutorTestHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import org.apache.ibatis.type.JdbcType;
5454
import org.apache.ibatis.type.TypeHandlerRegistry;
5555

56-
class ExecutorTestHelper {
56+
final class ExecutorTestHelper {
5757

5858
static final Cache authorCache;
5959

src/test/java/org/apache/ibatis/plugin/PluginTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void shouldPluginSwitchSchema() {
6060
}
6161
}
6262

63-
static class SchemaHolder {
63+
static final class SchemaHolder {
6464
private static ThreadLocal<String> value = ThreadLocal.withInitial(() -> "PUBLIC");
6565

6666
public static void set(String tenantName) {
@@ -70,6 +70,9 @@ public static void set(String tenantName) {
7070
public static String get() {
7171
return value.get();
7272
}
73+
74+
private SchemaHolder() {
75+
}
7376
}
7477

7578
@Intercepts(@Signature(type = StatementHandler.class, method = "prepare", args = { Connection.class, Integer.class }))

src/test/java/org/apache/ibatis/submitted/constructor_automapping/Author.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -15,7 +15,7 @@
1515
*/
1616
package org.apache.ibatis.submitted.constructor_automapping;
1717

18-
public class Author {
18+
public final class Author {
1919

2020
private final Integer id;
2121
private String name;

src/test/java/org/apache/ibatis/submitted/dirty_select/Mapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -44,7 +44,7 @@ public interface Mapper {
4444
@Insert("insert into users (name) values (#{name}) returning id, name")
4545
int insert(User user);
4646

47-
static class MyProvider {
47+
static final class MyProvider {
4848
public static String getSql() {
4949
return "insert into users (name) values (#{name}) returning id, name";
5050
}

src/test/java/org/apache/ibatis/submitted/discriminator/Contract.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
package org.apache.ibatis.submitted.discriminator;
1717

1818
public class Contract {
19-
private Integer id;
20-
private Owner owner;
19+
private final Integer id;
20+
private final Owner owner;
2121

2222
public Contract(Integer id, Owner owner) {
2323
this.id = id;

src/test/java/org/apache/ibatis/submitted/dynsql/CustomUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -15,7 +15,7 @@
1515
*/
1616
package org.apache.ibatis.submitted.dynsql;
1717

18-
public class CustomUtil {
18+
public final class CustomUtil {
1919
public static String esc(final String s) {
2020
return s.replace("'", "''");
2121
}

src/test/java/org/apache/ibatis/submitted/enum_with_method/Mood.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public String getMessage() {
2929
}
3030
};
3131

32-
private int value;
32+
private final int value;
3333

3434
Mood(int value) {
3535
this.value = value;

src/test/java/org/apache/ibatis/submitted/global_variables_defaults/SupportClasses.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -54,7 +54,7 @@ public void setName(String name) {
5454
}
5555
}
5656

57-
static class Utils {
57+
static final class Utils {
5858
static SupportClasses.CustomCache unwrap(Cache cache) {
5959
Field field;
6060
try {

src/test/java/org/apache/ibatis/submitted/ognlstatic/StaticClass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -15,7 +15,7 @@
1515
*/
1616
package org.apache.ibatis.submitted.ognlstatic;
1717

18-
public class StaticClass {
18+
public final class StaticClass {
1919

2020
public static String value = "User1";
2121

src/test/java/org/apache/ibatis/submitted/primitive_result_type/IbatisConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.apache.ibatis.session.SqlSessionFactory;
2323
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
2424

25-
public class IbatisConfig {
25+
public final class IbatisConfig {
2626

2727
private static SqlSessionFactory sqlSessionFactory;
2828

src/test/java/org/apache/ibatis/submitted/primitive_result_type/ProductDAO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -20,7 +20,7 @@
2020

2121
import org.apache.ibatis.session.SqlSession;
2222

23-
public class ProductDAO {
23+
public final class ProductDAO {
2424

2525
public static List<Integer> selectProductCodes() {
2626
try (SqlSession session = IbatisConfig.getSession()) {

src/test/java/org/apache/ibatis/submitted/repeatable/BothSelectAndSelectProviderMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -24,7 +24,7 @@ public interface BothSelectAndSelectProviderMapper {
2424
@SelectProvider(type = SqlProvider.class, method = "getUser")
2525
User getUser(Integer id);
2626

27-
class SqlProvider {
27+
final class SqlProvider {
2828
public static String getUser() {
2929
return "SELECT * FROM users WHERE id = #{id}";
3030
}

src/test/java/org/apache/ibatis/submitted/repeatable/BothSelectContainerAndSelectProviderContainerMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -26,7 +26,7 @@ public interface BothSelectContainerAndSelectProviderContainerMapper {
2626
@SelectProvider(type = SqlProvider.class, method = "getUser")
2727
User getUser(Integer id);
2828

29-
class SqlProvider {
29+
final class SqlProvider {
3030
public static String getUser() {
3131
return "SELECT * FROM users WHERE id = #{id}";
3232
}

src/test/java/org/apache/ibatis/submitted/repeatable/Mapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -94,7 +94,7 @@ public interface Mapper {
9494
@Select("SELECT COUNT(*) FROM users WHERE name LIKE '%' || #{dataabse} || '%'")
9595
int countByCurrentDatabase(String database);
9696

97-
class HsqlSqlProvider {
97+
final class HsqlSqlProvider {
9898
public static String getUserUsingProvider() {
9999
return "SELECT id, name, 'HSQL' as databaseName FROM users WHERE id = #{id}";
100100
}
@@ -115,7 +115,7 @@ private HsqlSqlProvider() {
115115
}
116116
}
117117

118-
class DerbySqlProvider {
118+
final class DerbySqlProvider {
119119
public static String getUserUsingProvider() {
120120
return "SELECT id, name, 'DERBY' as databaseName FROM users WHERE id = #{id}";
121121
}
@@ -136,7 +136,7 @@ private DerbySqlProvider() {
136136
}
137137
}
138138

139-
class DefaultSqlProvider {
139+
final class DefaultSqlProvider {
140140
public static String getUserUsingProvider() {
141141
return "SELECT id, name, 'DEFAULT' as databaseName FROM users WHERE id = #{id}";
142142
}

src/test/java/org/apache/ibatis/submitted/serializecircular/UtilityTester.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -21,7 +21,7 @@
2121
import java.io.ObjectInputStream;
2222
import java.io.ObjectOutputStream;
2323

24-
public class UtilityTester {
24+
public final class UtilityTester {
2525

2626
public static void serializeAndDeserializeObject(Object myObject) {
2727

src/test/java/org/apache/ibatis/submitted/sqlprovider/ProviderMethodResolutionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static String provideSelect2Sql() {
164164
}
165165
}
166166

167-
class ReservedMethodNameBasedSqlProvider {
167+
final class ReservedMethodNameBasedSqlProvider {
168168
public static String provideSql() {
169169
return "DELETE FROM memos WHERE id = 1";
170170
}
@@ -246,7 +246,7 @@ interface ReservedNameMethodIsNoneMapper {
246246
@UpdateProvider(type = SqlProvider.class)
247247
int update();
248248

249-
class SqlProvider {
249+
final class SqlProvider {
250250
public static String select() {
251251
return "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS";
252252
}

src/test/java/org/apache/ibatis/submitted/sqlprovider/SqlProviderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ public interface DefaultSqlProviderMapper {
707707
@DeleteProvider
708708
void delete(int id);
709709

710-
class SqlProvider {
710+
final class SqlProvider {
711711

712712
public static String provideSql(ProviderContext c) {
713713
return switch (c.getMapperMethod().getName()) {
@@ -840,7 +840,7 @@ public interface StaticMethodSqlProviderMapper {
840840
String multipleMap(@Param("map1") Map<String, Object> map1, @Param("map2") Map<String, Object> map2);
841841

842842
@SuppressWarnings("unused")
843-
class SqlProvider {
843+
final class SqlProvider {
844844

845845
public static String noArgument() {
846846
return "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS";
@@ -989,7 +989,7 @@ interface DatabaseIdMapper {
989989
String selectDatabaseId();
990990

991991
@SuppressWarnings("unused")
992-
class SqlProvider {
992+
final class SqlProvider {
993993
public static String provideSql(ProviderContext context) {
994994
if ("hsql".equals(context.getDatabaseId())) {
995995
return "SELECT '" + context.getDatabaseId() + "' FROM INFORMATION_SCHEMA.SYSTEM_USERS";

src/test/java/org/apache/ibatis/testcontainers/MysqlContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.testcontainers.junit.jupiter.Testcontainers;
2525

2626
@Testcontainers
27-
public class MysqlContainer {
27+
public final class MysqlContainer {
2828

2929
private static final String DB_NAME = "mybatis_test";
3030
private static final String USERNAME = "u";

src/test/java/org/apache/ibatis/testcontainers/PgContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2024 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.
@@ -20,7 +20,7 @@
2020
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
2121
import org.testcontainers.containers.PostgreSQLContainer;
2222

23-
public class PgContainer {
23+
public final class PgContainer {
2424

2525
private static final String DB_NAME = "mybatis_test";
2626
private static final String USERNAME = "u";

0 commit comments

Comments
 (0)