From 630f0175f45df35a603c2a18b3212b9badb20ec8 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 20 Feb 2023 13:09:21 -0500 Subject: [PATCH] [ci] Apply open rewrite partially on java cleanup --- .../ibatis/cache/decorators/LoggingCache.java | 6 +- .../ibatis/datasource/pooled/PoolState.java | 16 ++-- .../scripting/xmltags/DynamicContext.java | 2 +- .../apache/ibatis/session/Configuration.java | 2 +- .../ibatis/binding/BoundAuthorMapper.java | 12 +-- .../ibatis/binding/BoundBlogMapper.java | 48 +++++------ .../ibatis/builder/XmlMapperBuilderTest.java | 16 ---- .../ibatis/cache/SerializedCacheTest.java | 12 ++- .../org/apache/ibatis/domain/blog/Author.java | 25 ++++-- .../ibatis/domain/blog/ImmutableAuthor.java | 25 ++++-- .../java/org/apache/ibatis/jdbc/SQLTest.java | 86 +++++++++---------- .../apache/ibatis/jdbc/SelectBuilderTest.java | 50 +++++------ .../apache/ibatis/jdbc/SqlBuilderTest.java | 50 +++++------ .../ibatis/parsing/XPathParserTest.java | 56 ++++++------ .../apache/ibatis/session/SqlSessionTest.java | 7 +- .../UserDao.java | 18 ++-- .../UserDao.java | 16 ++-- .../blocking_cache/BlockingCacheTest.java | 1 + .../submitted/cglib_lazy_error/Person.java | 9 +- .../complex_column/PersonMapper.java | 14 +-- .../constructor_columnprefix/EntityKey.java | 17 ++-- .../CustomCollection.java | 3 +- .../ibatis/submitted/empty_row/Mapper.java | 4 +- .../HasValueEnumTypeHandler.java | 6 +- .../submitted/extendresultmap/TestModel.java | 23 +++-- .../foreach_map/IntBoolMapEntry.java | 14 +-- .../foreach_map/NestedBeanMapEntry.java | 18 ++-- .../foreach_map/StringStringMapEntry.java | 14 +-- .../submitted/language/VelocitySqlSource.java | 4 +- .../ibatis/submitted/manyanno/PostMapper.java | 12 +-- .../member_access/MemberAccessTest.java | 16 ++-- .../submitted/nestedresulthandler/Person.java | 3 +- .../NestedResultHandlerAssociationTest.java | 3 +- .../primitive_result_type/IbatisConfig.java | 5 +- .../record_type/RecordTypeMapper.java | 2 +- 35 files changed, 329 insertions(+), 286 deletions(-) diff --git a/src/main/java/org/apache/ibatis/cache/decorators/LoggingCache.java b/src/main/java/org/apache/ibatis/cache/decorators/LoggingCache.java index e2e099e2f1b..6ff00cb2e06 100644 --- a/src/main/java/org/apache/ibatis/cache/decorators/LoggingCache.java +++ b/src/main/java/org/apache/ibatis/cache/decorators/LoggingCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-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. @@ -26,8 +26,8 @@ public class LoggingCache implements Cache { private final Log log; private final Cache delegate; - protected int requests = 0; - protected int hits = 0; + protected int requests; + protected int hits; public LoggingCache(Cache delegate) { this.delegate = delegate; diff --git a/src/main/java/org/apache/ibatis/datasource/pooled/PoolState.java b/src/main/java/org/apache/ibatis/datasource/pooled/PoolState.java index 6471f375c90..f17dcfe8387 100644 --- a/src/main/java/org/apache/ibatis/datasource/pooled/PoolState.java +++ b/src/main/java/org/apache/ibatis/datasource/pooled/PoolState.java @@ -27,14 +27,14 @@ public class PoolState { protected final List idleConnections = new ArrayList<>(); protected final List activeConnections = new ArrayList<>(); - protected long requestCount = 0; - protected long accumulatedRequestTime = 0; - protected long accumulatedCheckoutTime = 0; - protected long claimedOverdueConnectionCount = 0; - protected long accumulatedCheckoutTimeOfOverdueConnections = 0; - protected long accumulatedWaitTime = 0; - protected long hadToWaitCount = 0; - protected long badConnectionCount = 0; + protected long requestCount; + protected long accumulatedRequestTime; + protected long accumulatedCheckoutTime; + protected long claimedOverdueConnectionCount; + protected long accumulatedCheckoutTimeOfOverdueConnections; + protected long accumulatedWaitTime; + protected long hadToWaitCount; + protected long badConnectionCount; public PoolState(PooledDataSource dataSource) { this.dataSource = dataSource; diff --git a/src/main/java/org/apache/ibatis/scripting/xmltags/DynamicContext.java b/src/main/java/org/apache/ibatis/scripting/xmltags/DynamicContext.java index 435d45908a8..33e85af11a5 100644 --- a/src/main/java/org/apache/ibatis/scripting/xmltags/DynamicContext.java +++ b/src/main/java/org/apache/ibatis/scripting/xmltags/DynamicContext.java @@ -40,7 +40,7 @@ public class DynamicContext { private final ContextMap bindings; private final StringJoiner sqlBuilder = new StringJoiner(" "); - private int uniqueNumber = 0; + private int uniqueNumber; public DynamicContext(Configuration configuration, Object parameterObject) { if (parameterObject != null && !(parameterObject instanceof Map)) { diff --git a/src/main/java/org/apache/ibatis/session/Configuration.java b/src/main/java/org/apache/ibatis/session/Configuration.java index 9dc875f0320..b84c2b4dd74 100644 --- a/src/main/java/org/apache/ibatis/session/Configuration.java +++ b/src/main/java/org/apache/ibatis/session/Configuration.java @@ -138,7 +138,7 @@ public class Configuration { protected ObjectFactory objectFactory = new DefaultObjectFactory(); protected ObjectWrapperFactory objectWrapperFactory = new DefaultObjectWrapperFactory(); - protected boolean lazyLoadingEnabled = false; + protected boolean lazyLoadingEnabled; protected ProxyFactory proxyFactory = new JavassistProxyFactory(); // #224 Using internal Javassist instead of OGNL protected String databaseId; diff --git a/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java b/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java index 1429d61db9a..a24ee8632ae 100644 --- a/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java +++ b/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java @@ -104,8 +104,8 @@ public interface BoundAuthorMapper { " USERNAME as AUTHOR_USERNAME,", " PASSWORD as AUTHOR_PASSWORD,", " EMAIL as AUTHOR_EMAIL,", - " BIO as AUTHOR_BIO," + - " FAVOURITE_SECTION as AUTHOR_SECTION", + " BIO as AUTHOR_BIO," + + " FAVOURITE_SECTION as AUTHOR_SECTION", "FROM AUTHOR WHERE ID = #{id}"}) // @formatter:on Author selectAuthorConstructor(int id); @@ -125,8 +125,8 @@ public interface BoundAuthorMapper { " USERNAME as AUTHOR_USERNAME,", " PASSWORD as AUTHOR_PASSWORD,", " EMAIL as AUTHOR_EMAIL,", - " BIO as AUTHOR_BIO," + - " FAVOURITE_SECTION as AUTHOR_SECTION", + " BIO as AUTHOR_BIO," + + " FAVOURITE_SECTION as AUTHOR_SECTION", "FROM AUTHOR WHERE ID = #{id}"}) // @formatter:on Author selectAuthorMapToConstructorUsingRepeatable(int id); @@ -164,8 +164,8 @@ public interface BoundAuthorMapper { " USERNAME as AUTHOR_USERNAME,", " PASSWORD as AUTHOR_PASSWORD,", " EMAIL as AUTHOR_EMAIL,", - " BIO as AUTHOR_BIO," + - " FAVOURITE_SECTION as AUTHOR_SECTION", + " BIO as AUTHOR_BIO," + + " FAVOURITE_SECTION as AUTHOR_SECTION", "FROM AUTHOR WHERE ID = #{id}"}) // @formatter:on Author selectAuthorUsingBothArgAndConstructorArgs(int id); diff --git a/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java b/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java index c2d68f35103..2b702fcfdcd 100644 --- a/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java +++ b/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java @@ -128,16 +128,16 @@ public interface BoundBlogMapper { // ====================================================== // @formatter:off - @Select("SELECT * FROM " + - "blog WHERE id = #{id}") + @Select("SELECT * FROM " + + "blog WHERE id = #{id}") // @formatter:on Blog selectBlog(int id); // ====================================================== // @formatter:off - @Select("SELECT * FROM " + - "blog WHERE id = #{id}") + @Select("SELECT * FROM " + + "blog WHERE id = #{id}") @ConstructorArgs({ @Arg(column = "id", javaType = int.class, id = true), @Arg(column = "title", javaType = String.class), @@ -158,24 +158,24 @@ public interface BoundBlogMapper { // ====================================================== // @formatter:off - @Select("SELECT * FROM " + - "blog WHERE id = #{id}") + @Select("SELECT * FROM " + + "blog WHERE id = #{id}") // @formatter:on Map selectBlogAsMap(Map params); // ====================================================== // @formatter:off - @Select("SELECT * FROM " + - "post WHERE subject like #{query}") + @Select("SELECT * FROM " + + "post WHERE subject like #{query}") // @formatter:on List selectPostsLike(RowBounds bounds, String query); // ====================================================== // @formatter:off - @Select("SELECT * FROM " + - "post WHERE subject like #{subjectQuery} and body like #{bodyQuery}") + @Select("SELECT * FROM " + + "post WHERE subject like #{subjectQuery} and body like #{bodyQuery}") // @formatter:on List selectPostsLikeSubjectAndBody(RowBounds bounds, @Param("subjectQuery") String subjectQuery, @Param("bodyQuery") String bodyQuery); @@ -183,22 +183,22 @@ List selectPostsLikeSubjectAndBody(RowBounds bounds, @Param("subjectQuery" // ====================================================== // @formatter:off - @Select("SELECT * FROM " + - "post WHERE id = #{id}") + @Select("SELECT * FROM " + + "post WHERE id = #{id}") // @formatter:on List selectPostsById(int id); // ====================================================== // @formatter:off - @Select("SELECT * FROM blog " + - "WHERE id = #{id} AND title = #{nonExistentParam,jdbcType=VARCHAR}") + @Select("SELECT * FROM blog " + + "WHERE id = #{id} AND title = #{nonExistentParam,jdbcType=VARCHAR}") // @formatter:on Blog selectBlogByNonExistentParam(@Param("id") int id); // @formatter:off - @Select("SELECT * FROM blog " + - "WHERE id = #{id} AND title = #{params.nonExistentParam,jdbcType=VARCHAR}") + @Select("SELECT * FROM blog " + + "WHERE id = #{id} AND title = #{params.nonExistentParam,jdbcType=VARCHAR}") // @formatter:on Blog selectBlogByNonExistentNestedParam(@Param("id") int id, @Param("params") Map params); @@ -208,22 +208,22 @@ List selectPostsLikeSubjectAndBody(RowBounds bounds, @Param("subjectQuery" // ====================================================== // @formatter:off - @Select("SELECT * FROM blog " + - "WHERE id = #{0} AND title = #{1}") + @Select("SELECT * FROM blog " + + "WHERE id = #{0} AND title = #{1}") // @formatter:on Blog selectBlogByDefault30ParamNames(int id, String title); // @formatter:off - @Select("SELECT * FROM blog " + - "WHERE id = #{param1} AND title = #{param2}") + @Select("SELECT * FROM blog " + + "WHERE id = #{param1} AND title = #{param2}") // @formatter:on Blog selectBlogByDefault31ParamNames(int id, String title); // ====================================================== // @formatter:off - @Select("SELECT * FROM blog " + - "WHERE ${column} = #{id} AND title = #{value}") + @Select("SELECT * FROM blog " + + "WHERE ${column} = #{id} AND title = #{value}") // @formatter:on Blog selectBlogWithAParamNamedValue(@Param("column") String column, @Param("id") int id, @Param("value") String title); @@ -248,8 +248,8 @@ Blog selectBlogWithAParamNamedValue(@Param("column") String column, @Param("id") "FROM blog" }) @Results({ - @Result(property = "author", column = "author_id", one = @One(select = "org.apache.ibatis.binding.BoundAuthorMapper.selectAuthor", fetchType=FetchType.EAGER)), - @Result(property = "posts", column = "id", many = @Many(select = "selectPostsById", fetchType=FetchType.EAGER)) + @Result(property = "author", column = "author_id", one = @One(select = "org.apache.ibatis.binding.BoundAuthorMapper.selectAuthor", fetchType = FetchType.EAGER)), + @Result(property = "posts", column = "id", many = @Many(select = "selectPostsById", fetchType = FetchType.EAGER)) }) // @formatter:on List selectBlogsWithAutorAndPostsEagerly(); diff --git a/src/test/java/org/apache/ibatis/builder/XmlMapperBuilderTest.java b/src/test/java/org/apache/ibatis/builder/XmlMapperBuilderTest.java index 823dfd3b17f..4321fa40c4e 100644 --- a/src/test/java/org/apache/ibatis/builder/XmlMapperBuilderTest.java +++ b/src/test/java/org/apache/ibatis/builder/XmlMapperBuilderTest.java @@ -82,8 +82,6 @@ void mappedStatementWithoutOptionsWhenSpecifyDefaultValue() throws Exception { @Test void parseExpression() { BaseBuilder builder = new BaseBuilder(new Configuration()) { - { - } }; { Pattern pattern = builder.parseExpression("[0-9]", "[a-z]"); @@ -100,8 +98,6 @@ void parseExpression() { @Test void resolveJdbcTypeWithUndefinedValue() { BaseBuilder builder = new BaseBuilder(new Configuration()) { - { - } }; when(() -> builder.resolveJdbcType("aaa")); then(caughtException()).isInstanceOf(BuilderException.class) @@ -112,8 +108,6 @@ void resolveJdbcTypeWithUndefinedValue() { @Test void resolveResultSetTypeWithUndefinedValue() { BaseBuilder builder = new BaseBuilder(new Configuration()) { - { - } }; when(() -> builder.resolveResultSetType("bbb")); then(caughtException()).isInstanceOf(BuilderException.class) @@ -124,8 +118,6 @@ void resolveResultSetTypeWithUndefinedValue() { @Test void resolveParameterModeWithUndefinedValue() { BaseBuilder builder = new BaseBuilder(new Configuration()) { - { - } }; when(() -> builder.resolveParameterMode("ccc")); then(caughtException()).isInstanceOf(BuilderException.class) @@ -136,8 +128,6 @@ void resolveParameterModeWithUndefinedValue() { @Test void createInstanceWithAbstractClass() { BaseBuilder builder = new BaseBuilder(new Configuration()) { - { - } }; when(() -> builder.createInstance("org.apache.ibatis.builder.BaseBuilder")); then(caughtException()).isInstanceOf(BuilderException.class).hasMessage( @@ -147,8 +137,6 @@ void createInstanceWithAbstractClass() { @Test void resolveClassWithNotFound() { BaseBuilder builder = new BaseBuilder(new Configuration()) { - { - } }; when(() -> builder.resolveClass("ddd")); then(caughtException()).isInstanceOf(BuilderException.class).hasMessage( @@ -158,8 +146,6 @@ void resolveClassWithNotFound() { @Test void resolveTypeHandlerTypeHandlerAliasIsNull() { BaseBuilder builder = new BaseBuilder(new Configuration()) { - { - } }; TypeHandler typeHandler = builder.resolveTypeHandler(String.class, (String) null); assertThat(typeHandler).isNull(); @@ -168,8 +154,6 @@ void resolveTypeHandlerTypeHandlerAliasIsNull() { @Test void resolveTypeHandlerNoAssignable() { BaseBuilder builder = new BaseBuilder(new Configuration()) { - { - } }; when(() -> builder.resolveTypeHandler(String.class, "integer")); then(caughtException()).isInstanceOf(BuilderException.class).hasMessage( diff --git a/src/test/java/org/apache/ibatis/cache/SerializedCacheTest.java b/src/test/java/org/apache/ibatis/cache/SerializedCacheTest.java index 1bcb59c17c5..368e520e31b 100644 --- a/src/test/java/org/apache/ibatis/cache/SerializedCacheTest.java +++ b/src/test/java/org/apache/ibatis/cache/SerializedCacheTest.java @@ -64,10 +64,12 @@ public CachingObject(int x) { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; + } CachingObject obj = (CachingObject) o; return x == obj.x; } @@ -87,10 +89,12 @@ public CachingObjectWithoutSerializable(int x) { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; + } CachingObjectWithoutSerializable obj = (CachingObjectWithoutSerializable) o; return x == obj.x; } diff --git a/src/test/java/org/apache/ibatis/domain/blog/Author.java b/src/test/java/org/apache/ibatis/domain/blog/Author.java index 332115700c4..8c4574d5304 100644 --- a/src/test/java/org/apache/ibatis/domain/blog/Author.java +++ b/src/test/java/org/apache/ibatis/domain/blog/Author.java @@ -93,25 +93,34 @@ public Section getFavouriteSection() { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof Author)) + } + if (!(o instanceof Author)) { return false; + } Author author = (Author) o; - if (id != author.id) + if (id != author.id) { return false; - if (bio != null ? !bio.equals(author.bio) : author.bio != null) + } + if (bio != null ? !bio.equals(author.bio) : author.bio != null) { return false; - if (email != null ? !email.equals(author.email) : author.email != null) + } + if (email != null ? !email.equals(author.email) : author.email != null) { return false; - if (password != null ? !password.equals(author.password) : author.password != null) + } + if (password != null ? !password.equals(author.password) : author.password != null) { return false; - if (username != null ? !username.equals(author.username) : author.username != null) + } + if (username != null ? !username.equals(author.username) : author.username != null) { return false; - if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection) : author.favouriteSection != null) + } + if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection) + : author.favouriteSection != null) { return false; + } return true; } diff --git a/src/test/java/org/apache/ibatis/domain/blog/ImmutableAuthor.java b/src/test/java/org/apache/ibatis/domain/blog/ImmutableAuthor.java index fbfc91c2228..a404ba12621 100644 --- a/src/test/java/org/apache/ibatis/domain/blog/ImmutableAuthor.java +++ b/src/test/java/org/apache/ibatis/domain/blog/ImmutableAuthor.java @@ -60,25 +60,34 @@ public Section getFavouriteSection() { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof Author)) + } + if (!(o instanceof Author)) { return false; + } Author author = (Author) o; - if (id != author.id) + if (id != author.id) { return false; - if (bio != null ? !bio.equals(author.bio) : author.bio != null) + } + if (bio != null ? !bio.equals(author.bio) : author.bio != null) { return false; - if (email != null ? !email.equals(author.email) : author.email != null) + } + if (email != null ? !email.equals(author.email) : author.email != null) { return false; - if (password != null ? !password.equals(author.password) : author.password != null) + } + if (password != null ? !password.equals(author.password) : author.password != null) { return false; - if (username != null ? !username.equals(author.username) : author.username != null) + } + if (username != null ? !username.equals(author.username) : author.username != null) { return false; - if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection) : author.favouriteSection != null) + } + if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection) + : author.favouriteSection != null) { return false; + } return true; } diff --git a/src/test/java/org/apache/ibatis/jdbc/SQLTest.java b/src/test/java/org/apache/ibatis/jdbc/SQLTest.java index df640fc8973..7d0efd3ea36 100644 --- a/src/test/java/org/apache/ibatis/jdbc/SQLTest.java +++ b/src/test/java/org/apache/ibatis/jdbc/SQLTest.java @@ -30,16 +30,16 @@ void shouldDemonstrateProvidedStringBuilder() { final String sql = example1().usingAppender(sb).toString(); // @formatter:off - assertEquals("SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON\n" + - "FROM PERSON P, ACCOUNT A\n" + - "INNER JOIN DEPARTMENT D on D.ID = P.DEPARTMENT_ID\n" + - "INNER JOIN COMPANY C on D.COMPANY_ID = C.ID\n" + - "WHERE (P.ID = A.ID AND P.FIRST_NAME like ?) \n" + - "OR (P.LAST_NAME like ?)\n" + - "GROUP BY P.ID\n" + - "HAVING (P.LAST_NAME like ?) \n" + - "OR (P.FIRST_NAME like ?)\n" + - "ORDER BY P.ID, P.FULL_NAME", sql); + assertEquals("SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON\n" + + "FROM PERSON P, ACCOUNT A\n" + + "INNER JOIN DEPARTMENT D on D.ID = P.DEPARTMENT_ID\n" + + "INNER JOIN COMPANY C on D.COMPANY_ID = C.ID\n" + + "WHERE (P.ID = A.ID AND P.FIRST_NAME like ?) \n" + + "OR (P.LAST_NAME like ?)\n" + + "GROUP BY P.ID\n" + + "HAVING (P.LAST_NAME like ?) \n" + + "OR (P.FIRST_NAME like ?)\n" + + "ORDER BY P.ID, P.FULL_NAME", sql); // @formatter:on } @@ -55,10 +55,10 @@ void shouldDemonstrateMixedStyle() { }.toString(); // @formatter:off - assertEquals("" + - "SELECT id, name\n" + - "FROM PERSON A\n" + - "WHERE (name like ? AND id = ?)", sql); + assertEquals("" + + "SELECT id, name\n" + + "FROM PERSON A\n" + + "WHERE (name like ? AND id = ?)", sql); // @formatter:on } @@ -68,10 +68,10 @@ void shouldDemonstrateFluentStyle() { final String sql = new SQL().SELECT("id, name").FROM("PERSON A").WHERE("name like ?").WHERE("id = ?").toString(); // @formatter:off - assertEquals("" + - "SELECT id, name\n" + - "FROM PERSON A\n" + - "WHERE (name like ? AND id = ?)", sql); + assertEquals("" + + "SELECT id, name\n" + + "FROM PERSON A\n" + + "WHERE (name like ? AND id = ?)", sql); // @formatter:on } @@ -79,10 +79,10 @@ void shouldDemonstrateFluentStyle() { void shouldProduceExpectedSimpleSelectStatement() { // @formatter:off final String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.ID like #id# AND P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.ID like #id# AND P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2("a", "b", "c")); } @@ -91,10 +91,10 @@ void shouldProduceExpectedSimpleSelectStatement() { void shouldProduceExpectedSimpleSelectStatementMissingFirstParam() { // @formatter:off final String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, "b", "c")); } @@ -103,10 +103,10 @@ void shouldProduceExpectedSimpleSelectStatementMissingFirstParam() { void shouldProduceExpectedSimpleSelectStatementMissingFirstTwoParams() { // @formatter:off final String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, null, "c")); } @@ -115,9 +115,9 @@ void shouldProduceExpectedSimpleSelectStatementMissingFirstTwoParams() { void shouldProduceExpectedSimpleSelectStatementMissingAllParams() { // @formatter:off final String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, null, null)); } @@ -126,16 +126,16 @@ void shouldProduceExpectedSimpleSelectStatementMissingAllParams() { void shouldProduceExpectedComplexSelectStatement() { // @formatter:off final String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON\n" + - "FROM PERSON P, ACCOUNT A\n" + - "INNER JOIN DEPARTMENT D on D.ID = P.DEPARTMENT_ID\n" + - "INNER JOIN COMPANY C on D.COMPANY_ID = C.ID\n" + - "WHERE (P.ID = A.ID AND P.FIRST_NAME like ?) \n" + - "OR (P.LAST_NAME like ?)\n" + - "GROUP BY P.ID\n" + - "HAVING (P.LAST_NAME like ?) \n" + - "OR (P.FIRST_NAME like ?)\n" + - "ORDER BY P.ID, P.FULL_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON\n" + + "FROM PERSON P, ACCOUNT A\n" + + "INNER JOIN DEPARTMENT D on D.ID = P.DEPARTMENT_ID\n" + + "INNER JOIN COMPANY C on D.COMPANY_ID = C.ID\n" + + "WHERE (P.ID = A.ID AND P.FIRST_NAME like ?) \n" + + "OR (P.LAST_NAME like ?)\n" + + "GROUP BY P.ID\n" + + "HAVING (P.LAST_NAME like ?) \n" + + "OR (P.FIRST_NAME like ?)\n" + + "ORDER BY P.ID, P.FULL_NAME"; // @formatter:on assertEquals(expected, example1().toString()); } diff --git a/src/test/java/org/apache/ibatis/jdbc/SelectBuilderTest.java b/src/test/java/org/apache/ibatis/jdbc/SelectBuilderTest.java index cc8c39f1011..8b73fb10405 100644 --- a/src/test/java/org/apache/ibatis/jdbc/SelectBuilderTest.java +++ b/src/test/java/org/apache/ibatis/jdbc/SelectBuilderTest.java @@ -26,10 +26,10 @@ class SelectBuilderTest { void shouldProduceExpectedSimpleSelectStatement() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.ID like #id# AND P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.ID like #id# AND P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2("a", "b", "c")); } @@ -38,10 +38,10 @@ void shouldProduceExpectedSimpleSelectStatement() { void shouldProduceExpectedSimpleSelectStatementMissingFirstParam() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, "b", "c")); } @@ -50,10 +50,10 @@ void shouldProduceExpectedSimpleSelectStatementMissingFirstParam() { void shouldProduceExpectedSimpleSelectStatementMissingFirstTwoParams() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, null, "c")); } @@ -62,9 +62,9 @@ void shouldProduceExpectedSimpleSelectStatementMissingFirstTwoParams() { void shouldProduceExpectedSimpleSelectStatementMissingAllParams() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, null, null)); } @@ -73,16 +73,16 @@ void shouldProduceExpectedSimpleSelectStatementMissingAllParams() { void shouldProduceExpectedComplexSelectStatement() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON\n" + - "FROM PERSON P, ACCOUNT A\n" + - "INNER JOIN DEPARTMENT D on D.ID = P.DEPARTMENT_ID\n" + - "INNER JOIN COMPANY C on D.COMPANY_ID = C.ID\n" + - "WHERE (P.ID = A.ID AND P.FIRST_NAME like ?) \n" + - "OR (P.LAST_NAME like ?)\n" + - "GROUP BY P.ID\n" + - "HAVING (P.LAST_NAME like ?) \n" + - "OR (P.FIRST_NAME like ?)\n" + - "ORDER BY P.ID, P.FULL_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON\n" + + "FROM PERSON P, ACCOUNT A\n" + + "INNER JOIN DEPARTMENT D on D.ID = P.DEPARTMENT_ID\n" + + "INNER JOIN COMPANY C on D.COMPANY_ID = C.ID\n" + + "WHERE (P.ID = A.ID AND P.FIRST_NAME like ?) \n" + + "OR (P.LAST_NAME like ?)\n" + + "GROUP BY P.ID\n" + + "HAVING (P.LAST_NAME like ?) \n" + + "OR (P.FIRST_NAME like ?)\n" + + "ORDER BY P.ID, P.FULL_NAME"; // @formatter:on assertEquals(expected, example1()); } diff --git a/src/test/java/org/apache/ibatis/jdbc/SqlBuilderTest.java b/src/test/java/org/apache/ibatis/jdbc/SqlBuilderTest.java index f77e75ce76f..d0e1a64e55e 100644 --- a/src/test/java/org/apache/ibatis/jdbc/SqlBuilderTest.java +++ b/src/test/java/org/apache/ibatis/jdbc/SqlBuilderTest.java @@ -26,10 +26,10 @@ class SqlBuilderTest { void shouldProduceExpectedSimpleSelectStatement() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.ID like #id# AND P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.ID like #id# AND P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2("a", "b", "c")); } @@ -38,10 +38,10 @@ void shouldProduceExpectedSimpleSelectStatement() { void shouldProduceExpectedSimpleSelectStatementMissingFirstParam() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.FIRST_NAME like #firstName# AND P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, "b", "c")); } @@ -50,10 +50,10 @@ void shouldProduceExpectedSimpleSelectStatementMissingFirstParam() { void shouldProduceExpectedSimpleSelectStatementMissingFirstTwoParams() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "WHERE (P.LAST_NAME like #lastName#)\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "WHERE (P.LAST_NAME like #lastName#)\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, null, "c")); } @@ -62,9 +62,9 @@ void shouldProduceExpectedSimpleSelectStatementMissingFirstTwoParams() { void shouldProduceExpectedSimpleSelectStatementMissingAllParams() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + - "FROM PERSON P\n" + - "ORDER BY P.LAST_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\n" + + "FROM PERSON P\n" + + "ORDER BY P.LAST_NAME"; // @formatter:on assertEquals(expected, example2(null, null, null)); } @@ -73,16 +73,16 @@ void shouldProduceExpectedSimpleSelectStatementMissingAllParams() { void shouldProduceExpectedComplexSelectStatement() { // @formatter:off String expected = - "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON\n" + - "FROM PERSON P, ACCOUNT A\n" + - "INNER JOIN DEPARTMENT D on D.ID = P.DEPARTMENT_ID\n" + - "INNER JOIN COMPANY C on D.COMPANY_ID = C.ID\n" + - "WHERE (P.ID = A.ID AND P.FIRST_NAME like ?) \n" + - "OR (P.LAST_NAME like ?)\n" + - "GROUP BY P.ID\n" + - "HAVING (P.LAST_NAME like ?) \n" + - "OR (P.FIRST_NAME like ?)\n" + - "ORDER BY P.ID, P.FULL_NAME"; + "SELECT P.ID, P.USERNAME, P.PASSWORD, P.FULL_NAME, P.LAST_NAME, P.CREATED_ON, P.UPDATED_ON\n" + + "FROM PERSON P, ACCOUNT A\n" + + "INNER JOIN DEPARTMENT D on D.ID = P.DEPARTMENT_ID\n" + + "INNER JOIN COMPANY C on D.COMPANY_ID = C.ID\n" + + "WHERE (P.ID = A.ID AND P.FIRST_NAME like ?) \n" + + "OR (P.LAST_NAME like ?)\n" + + "GROUP BY P.ID\n" + + "HAVING (P.LAST_NAME like ?) \n" + + "OR (P.FIRST_NAME like ?)\n" + + "ORDER BY P.ID, P.FULL_NAME"; // @formatter:on assertEquals(expected, example1()); } diff --git a/src/test/java/org/apache/ibatis/parsing/XPathParserTest.java b/src/test/java/org/apache/ibatis/parsing/XPathParserTest.java index 496cb5b0dd4..aee70307a2e 100644 --- a/src/test/java/org/apache/ibatis/parsing/XPathParserTest.java +++ b/src/test/java/org/apache/ibatis/parsing/XPathParserTest.java @@ -32,7 +32,7 @@ import org.xml.sax.InputSource; class XPathParserTest { - private String resource = "nodelet_test.xml"; + private final String resource = "nodelet_test.xml"; // InputStream Source @Test @@ -221,41 +221,41 @@ void formatXNodeToString() { // @formatter:off String usersNodeToStringExpect = - "\n" + - " \n" + - " 100\n" + - " Tom\n" + - " 30\n" + - " \n" + - " BMW\n" + - " Audi\n" + - " Benz\n" + - " \n" + - " \n" + - "\n"; + "\n" + + " \n" + + " 100\n" + + " Tom\n" + + " 30\n" + + " \n" + + " BMW\n" + + " Audi\n" + + " Benz\n" + + " \n" + + " \n" + + "\n"; // @formatter:on // @formatter:off String userNodeToStringExpect = - "\n" + - " 100\n" + - " Tom\n" + - " 30\n" + - " \n" + - " BMW\n" + - " Audi\n" + - " Benz\n" + - " \n" + - "\n"; + "\n" + + " 100\n" + + " Tom\n" + + " 30\n" + + " \n" + + " BMW\n" + + " Audi\n" + + " Benz\n" + + " \n" + + "\n"; // @formatter:on // @formatter:off String carsNodeToStringExpect = - "\n" + - " BMW\n" + - " Audi\n" + - " Benz\n" + - "\n"; + "\n" + + " BMW\n" + + " Audi\n" + + " Benz\n" + + "\n"; // @formatter:on assertEquals(usersNodeToStringExpect, usersNodeToString); diff --git a/src/test/java/org/apache/ibatis/session/SqlSessionTest.java b/src/test/java/org/apache/ibatis/session/SqlSessionTest.java index 115cdf2faa9..d5f77b33e33 100644 --- a/src/test/java/org/apache/ibatis/session/SqlSessionTest.java +++ b/src/test/java/org/apache/ibatis/session/SqlSessionTest.java @@ -672,7 +672,7 @@ void shouldLimitResultsUsingMapperClass() { } private static class TestResultHandler implements ResultHandler { - int count = 0; + int count; @Override public void handleResult(ResultContext context) { @@ -690,13 +690,14 @@ void shouldHandleZeroParameters() { } private static class TestResultStopHandler implements ResultHandler { - int count = 0; + int count; @Override public void handleResult(ResultContext context) { count++; - if (count == 2) + if (count == 2) { context.stop(); + } } } diff --git a/src/test/java/org/apache/ibatis/submitted/annotion_many_one_add_columnprefix/UserDao.java b/src/test/java/org/apache/ibatis/submitted/annotion_many_one_add_columnprefix/UserDao.java index 3b8545d78f8..92dccee721d 100644 --- a/src/test/java/org/apache/ibatis/submitted/annotion_many_one_add_columnprefix/UserDao.java +++ b/src/test/java/org/apache/ibatis/submitted/annotion_many_one_add_columnprefix/UserDao.java @@ -28,11 +28,11 @@ */ public interface UserDao { // @formatter:off - @Select({ "select", + @Select({"select", " u.id, u.username, r.id role_id, r.name role_name", " from user u", " left join user_role ur on u.id = ur.user_id", - " left join role r on ur.role_id = r.id" }) + " left join role r on ur.role_id = r.id"}) @Results({ @Result(id = true, column = "id", property = "id"), @Result(column = "username", property = "username"), @@ -42,11 +42,11 @@ public interface UserDao { List findAll(); // @formatter:off - @Select({ "select", + @Select({"select", " u.id, u.username, r.id role_id, r.name role_name", " from user u", " left join user_role ur on u.id = ur.user_id", - " left join role r on ur.role_id = r.id" }) + " left join role r on ur.role_id = r.id"}) @Results({ @Result(id = true, column = "id", property = "id"), @Result(column = "username", property = "username"), @@ -56,11 +56,11 @@ public interface UserDao { List findAll2(); // @formatter:off - @Select({ "select", + @Select({"select", " u.id, u.username, r.id role_id, r.name role_name", " from user u", " left join user_role ur on u.id = ur.user_id", - " left join role r on ur.role_id = r.id where u.id in (2, 3)" }) + " left join role r on ur.role_id = r.id where u.id in (2, 3)"}) @Results({ @Result(id = true, column = "id", property = "id"), @Result(column = "username", property = "username"), @@ -79,15 +79,15 @@ public interface UserDao { List justUseResult(); // @formatter:off - @Select({ "select", + @Select({"select", " u.id, u.username, r.id role_id, r.name role_name,", " f.id friend_id, f.username, fr.id friend_role_id, fr.name friend_role_name", " from user u", " left join user_role ur on u.id = ur.user_id", - " left join role r on ur.role_id = r.id" , + " left join role r on ur.role_id = r.id", " left join user f on u.friend_id = f.id", " left join user_role fur on f.id = fur.user_id", - " left join role fr on fur.role_id = fr.id" , + " left join role fr on fur.role_id = fr.id", " where u.id = #{userId} order by r.id, fr.id" }) @Results(id = "userWithFriendMap", value = { diff --git a/src/test/java/org/apache/ibatis/submitted/annotion_many_one_add_resultmapid/UserDao.java b/src/test/java/org/apache/ibatis/submitted/annotion_many_one_add_resultmapid/UserDao.java index 00ad5f4feb7..2edbbbc603e 100644 --- a/src/test/java/org/apache/ibatis/submitted/annotion_many_one_add_resultmapid/UserDao.java +++ b/src/test/java/org/apache/ibatis/submitted/annotion_many_one_add_resultmapid/UserDao.java @@ -24,11 +24,11 @@ */ public interface UserDao { // @formatter:off - @Select({ "select", + @Select({"select", " u.id, u.username, r.id role_id, r.role_name", " from user u", " left join user_role ur on u.id = ur.user_id", - " left join role r on ur.role_id = r.id" }) + " left join role r on ur.role_id = r.id"}) @Results({ @Result(id = true, column = "id", property = "id"), @Result(column = "username", property = "username"), @@ -38,11 +38,11 @@ public interface UserDao { public List findAll(); // @formatter:off - @Select({ "select", + @Select({"select", " u.id, u.username, r.id role_id, r.role_name", " from user u", " left join user_role ur on u.id = ur.user_id", - " left join role r on ur.role_id = r.id" }) + " left join role r on ur.role_id = r.id"}) @Results({ @Result(id = true, column = "id", property = "id"), @Result(column = "username", property = "username"), @@ -52,11 +52,11 @@ public interface UserDao { public List findAll2(); // @formatter:off - @Select({ "select", + @Select({"select", " u.id, u.username, r.id role_id, r.role_name", " from user u", " left join user_role ur on u.id = ur.user_id", - " left join role r on ur.role_id = r.id where u.id in (2, 3)" }) + " left join role r on ur.role_id = r.id where u.id in (2, 3)"}) @Results({ @Result(id = true, column = "id", property = "id"), @Result(column = "username", property = "username"), @@ -75,13 +75,13 @@ public interface UserDao { public List justUseResult(); // @formatter:off - @Select({ "select", + @Select({"select", "u.id, u.username, r.id role_id, r.role_name, ut.id teacher_id, ut.username teacher_name", "from user u", "left join user_role ur on u.id = ur.user_id", "left join role r on ur.role_id = r.id", "left join user ut on ut.id != u.id", - "where role_id = 3" }) + "where role_id = 3"}) @Results({ @Result(id = true, column = "id", property = "id"), @Result(column = "username", property = "username"), diff --git a/src/test/java/org/apache/ibatis/submitted/blocking_cache/BlockingCacheTest.java b/src/test/java/org/apache/ibatis/submitted/blocking_cache/BlockingCacheTest.java index 5233cf237e1..7a938a30f08 100644 --- a/src/test/java/org/apache/ibatis/submitted/blocking_cache/BlockingCacheTest.java +++ b/src/test/java/org/apache/ibatis/submitted/blocking_cache/BlockingCacheTest.java @@ -59,6 +59,7 @@ void testBlockingCache() { defaultThreadPool.shutdown(); while (!defaultThreadPool.isTerminated()) { + continue; } long totalTime = System.currentTimeMillis() - init; diff --git a/src/test/java/org/apache/ibatis/submitted/cglib_lazy_error/Person.java b/src/test/java/org/apache/ibatis/submitted/cglib_lazy_error/Person.java index b06fc7715f5..88cf4f992eb 100644 --- a/src/test/java/org/apache/ibatis/submitted/cglib_lazy_error/Person.java +++ b/src/test/java/org/apache/ibatis/submitted/cglib_lazy_error/Person.java @@ -32,15 +32,18 @@ public Person getAncestor() { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof Person)) + } + if (!(o instanceof Person)) { return false; + } Person person = (Person) o; - if (id != null ? !id.equals(person.id) : person.id != null) + if (id != null ? !id.equals(person.id) : person.id != null) { return false; + } return true; } diff --git a/src/test/java/org/apache/ibatis/submitted/complex_column/PersonMapper.java b/src/test/java/org/apache/ibatis/submitted/complex_column/PersonMapper.java index 30db22d58fd..27a9b753059 100644 --- a/src/test/java/org/apache/ibatis/submitted/complex_column/PersonMapper.java +++ b/src/test/java/org/apache/ibatis/submitted/complex_column/PersonMapper.java @@ -52,18 +52,18 @@ public interface PersonMapper { "WHERE id = #{id,jdbcType=INTEGER}" }) @Results({ - @Result(id=true, column = "id", property = "id"), - @Result(property = "parent", column="{firstName=parent_firstName,lastName=parent_lastName}", one=@One(select="getParentWithParamAttributes")) + @Result(id = true, column = "id", property = "id"), + @Result(property = "parent", column = "{firstName=parent_firstName,lastName=parent_lastName}", one = @One(select = "getParentWithParamAttributes")) }) // @formatter:on Person getComplexWithParamAttributes(Long id); // @formatter:off - @Select("SELECT id, firstName, lastName, parent_id, parent_firstName, parent_lastName" + - " FROM Person" + - " WHERE firstName = #{firstName,jdbcType=VARCHAR}" + - " AND lastName = #{lastName,jdbcType=VARCHAR}" + - " LIMIT 1") + @Select("SELECT id, firstName, lastName, parent_id, parent_firstName, parent_lastName" + + " FROM Person" + + " WHERE firstName = #{firstName,jdbcType=VARCHAR}" + + " AND lastName = #{lastName,jdbcType=VARCHAR}" + + " LIMIT 1") // @formatter:on Person getParentWithParamAttributes(@Param("firstName") String firstName, @Param("lastName") String lastname); diff --git a/src/test/java/org/apache/ibatis/submitted/constructor_columnprefix/EntityKey.java b/src/test/java/org/apache/ibatis/submitted/constructor_columnprefix/EntityKey.java index d82c19c494e..bc4b70c4f0a 100644 --- a/src/test/java/org/apache/ibatis/submitted/constructor_columnprefix/EntityKey.java +++ b/src/test/java/org/apache/ibatis/submitted/constructor_columnprefix/EntityKey.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-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. @@ -36,18 +36,23 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } EntityKey other = (EntityKey) obj; if (id == null) { - if (other.id != null) + if (other.id != null) { return false; - } else if (!id.equals(other.id)) + } + } else if (!id.equals(other.id)) { return false; + } return true; } } diff --git a/src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomCollection.java b/src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomCollection.java index bbc76b04193..9b701f3e555 100644 --- a/src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomCollection.java +++ b/src/test/java/org/apache/ibatis/submitted/custom_collection_handling/CustomCollection.java @@ -92,8 +92,9 @@ public T get(int index) { @Override public boolean equals(Object o) { - if (!(o instanceof CustomCollection)) + if (!(o instanceof CustomCollection)) { return false; + } return data.equals(((CustomCollection) o).data); } diff --git a/src/test/java/org/apache/ibatis/submitted/empty_row/Mapper.java b/src/test/java/org/apache/ibatis/submitted/empty_row/Mapper.java index be0e04362fe..6af0feecfef 100644 --- a/src/test/java/org/apache/ibatis/submitted/empty_row/Mapper.java +++ b/src/test/java/org/apache/ibatis/submitted/empty_row/Mapper.java @@ -53,9 +53,9 @@ public interface Mapper { @ResultMap("twoCollectionsRM") // @formatter:off - @Select({ "select p.id, c.name child_name, e.name pet_name from parent p", + @Select({"select p.id, c.name child_name, e.name pet_name from parent p", "left join child c on c.parent_id = p.id", - "left join pet e on e.parent_id = p.id", "where p.id = #{id}" }) + "left join pet e on e.parent_id = p.id", "where p.id = #{id}"}) // @formatter:on Parent getTwoCollections(Integer id); diff --git a/src/test/java/org/apache/ibatis/submitted/enum_interface_type_handler/HasValueEnumTypeHandler.java b/src/test/java/org/apache/ibatis/submitted/enum_interface_type_handler/HasValueEnumTypeHandler.java index c5d36aed8fd..a13ae9b8c69 100644 --- a/src/test/java/org/apache/ibatis/submitted/enum_interface_type_handler/HasValueEnumTypeHandler.java +++ b/src/test/java/org/apache/ibatis/submitted/enum_interface_type_handler/HasValueEnumTypeHandler.java @@ -30,12 +30,14 @@ public class HasValueEnumTypeHandler & HasValue> extends BaseT private final E[] enums; public HasValueEnumTypeHandler(Class type) { - if (type == null) + if (type == null) { throw new IllegalArgumentException("Type argument cannot be null"); + } this.type = type; this.enums = type.getEnumConstants(); - if (!type.isInterface() && this.enums == null) + if (!type.isInterface() && this.enums == null) { throw new IllegalArgumentException(type.getSimpleName() + " does not represent an enum type."); + } } @Override diff --git a/src/test/java/org/apache/ibatis/submitted/extendresultmap/TestModel.java b/src/test/java/org/apache/ibatis/submitted/extendresultmap/TestModel.java index de338337747..ebe79dec539 100644 --- a/src/test/java/org/apache/ibatis/submitted/extendresultmap/TestModel.java +++ b/src/test/java/org/apache/ibatis/submitted/extendresultmap/TestModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-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. @@ -56,23 +56,30 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } TestModel other = (TestModel) obj; if (a == null) { - if (other.a != null) + if (other.a != null) { return false; - } else if (!a.equals(other.a)) + } + } else if (!a.equals(other.a)) { return false; + } if (b == null) { - if (other.b != null) + if (other.b != null) { return false; - } else if (!b.equals(other.b)) + } + } else if (!b.equals(other.b)) { return false; + } return true; } diff --git a/src/test/java/org/apache/ibatis/submitted/foreach_map/IntBoolMapEntry.java b/src/test/java/org/apache/ibatis/submitted/foreach_map/IntBoolMapEntry.java index e6af3f92873..d579aeac77f 100644 --- a/src/test/java/org/apache/ibatis/submitted/foreach_map/IntBoolMapEntry.java +++ b/src/test/java/org/apache/ibatis/submitted/foreach_map/IntBoolMapEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-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. @@ -42,17 +42,21 @@ public void setValue(Boolean value) { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; + } IntBoolMapEntry mapEntry = (IntBoolMapEntry) o; - if (key != null ? !key.equals(mapEntry.key) : mapEntry.key != null) + if (key != null ? !key.equals(mapEntry.key) : mapEntry.key != null) { return false; - if (value != null ? !value.equals(mapEntry.value) : mapEntry.value != null) + } + if (value != null ? !value.equals(mapEntry.value) : mapEntry.value != null) { return false; + } return true; } diff --git a/src/test/java/org/apache/ibatis/submitted/foreach_map/NestedBeanMapEntry.java b/src/test/java/org/apache/ibatis/submitted/foreach_map/NestedBeanMapEntry.java index 0593381f915..2158a11d902 100644 --- a/src/test/java/org/apache/ibatis/submitted/foreach_map/NestedBeanMapEntry.java +++ b/src/test/java/org/apache/ibatis/submitted/foreach_map/NestedBeanMapEntry.java @@ -62,21 +62,27 @@ public void setValueb(Boolean valueb) { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; + } NestedBeanMapEntry map3Entry = (NestedBeanMapEntry) o; - if (!Objects.equals(keya, map3Entry.keya)) + if (!Objects.equals(keya, map3Entry.keya)) { return false; - if (!Objects.equals(keyb, map3Entry.keyb)) + } + if (!Objects.equals(keyb, map3Entry.keyb)) { return false; - if (!Objects.equals(valuea, map3Entry.valuea)) + } + if (!Objects.equals(valuea, map3Entry.valuea)) { return false; - if (!Objects.equals(valueb, map3Entry.valueb)) + } + if (!Objects.equals(valueb, map3Entry.valueb)) { return false; + } return true; } diff --git a/src/test/java/org/apache/ibatis/submitted/foreach_map/StringStringMapEntry.java b/src/test/java/org/apache/ibatis/submitted/foreach_map/StringStringMapEntry.java index aeaaa05d90c..6ec4711a4e0 100644 --- a/src/test/java/org/apache/ibatis/submitted/foreach_map/StringStringMapEntry.java +++ b/src/test/java/org/apache/ibatis/submitted/foreach_map/StringStringMapEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-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. @@ -42,17 +42,21 @@ public void setValue(String value) { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; + } StringStringMapEntry mapEntry = (StringStringMapEntry) o; - if (key != null ? !key.equals(mapEntry.key) : mapEntry.key != null) + if (key != null ? !key.equals(mapEntry.key) : mapEntry.key != null) { return false; - if (value != null ? !value.equals(mapEntry.value) : mapEntry.value != null) + } + if (value != null ? !value.equals(mapEntry.value) : mapEntry.value != null) { return false; + } return true; } diff --git a/src/test/java/org/apache/ibatis/submitted/language/VelocitySqlSource.java b/src/test/java/org/apache/ibatis/submitted/language/VelocitySqlSource.java index d51f971b830..499b9bed2af 100644 --- a/src/test/java/org/apache/ibatis/submitted/language/VelocitySqlSource.java +++ b/src/test/java/org/apache/ibatis/submitted/language/VelocitySqlSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-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. @@ -92,7 +92,7 @@ public static Map createBindings(Object parameterObject, Configu public static class IteratorParameter { private static final String PREFIX = "__frch_"; - private int count = 0; + private int count; private final Map bindings; public IteratorParameter(Map bindings) { diff --git a/src/test/java/org/apache/ibatis/submitted/manyanno/PostMapper.java b/src/test/java/org/apache/ibatis/submitted/manyanno/PostMapper.java index ae4d53d31b2..7e361e4a1fe 100644 --- a/src/test/java/org/apache/ibatis/submitted/manyanno/PostMapper.java +++ b/src/test/java/org/apache/ibatis/submitted/manyanno/PostMapper.java @@ -24,10 +24,10 @@ public interface PostMapper { @Select("select * from post where author_id = #{id} order by id") // @formatter:off @Results(value = { - @Result(property="id", column="id"), - @Result(property="subject", column="subject"), - @Result(property="body", column="body"), - @Result(property="tags", javaType=List.class, column="id", many=@Many(select="getTagsForPost")) + @Result(property = "id", column = "id"), + @Result(property = "subject", column = "subject"), + @Result(property = "body", column = "body"), + @Result(property = "tags", javaType = List.class, column = "id", many = @Many(select = "getTagsForPost")) }) // @formatter:on List getPosts(int authorId); @@ -35,8 +35,8 @@ public interface PostMapper { @Select("select t.id, t.name from tag t inner join post_tag pt on pt.tag_id = t.id where pt.post_id = #{postId} order by id") // @formatter:off @ConstructorArgs(value = { - @Arg(column="id",javaType=int.class), - @Arg(column="name",javaType=String.class) + @Arg(column = "id", javaType = int.class), + @Arg(column = "name", javaType = String.class) }) // @formatter:on List getTagsForPost(int postId); diff --git a/src/test/java/org/apache/ibatis/submitted/member_access/MemberAccessTest.java b/src/test/java/org/apache/ibatis/submitted/member_access/MemberAccessTest.java index 3d32f1355ab..4f009a9b1d0 100644 --- a/src/test/java/org/apache/ibatis/submitted/member_access/MemberAccessTest.java +++ b/src/test/java/org/apache/ibatis/submitted/member_access/MemberAccessTest.java @@ -225,7 +225,7 @@ interface Mapper { , "FROM INFORMATION_SCHEMA.SYSTEM_USERS" - ,""} + , ""} ) // @formatter:on Bean resultAutoMappingUsingOgnl(Params params); @@ -233,13 +233,13 @@ interface Mapper { // @formatter:off @Results({ @Result(property = "privateField", column = "private_field") - ,@Result(property = "packagePrivateField", column = "package_private_field") - ,@Result(property = "protectedField", column = "protected_field") - ,@Result(property = "publicField", column = "public_field") - ,@Result(property = "privateProperty", column = "private_property") - ,@Result(property = "packagePrivateProperty", column = "package_private_property") - ,@Result(property = "protectedProperty", column = "protected_property") - ,@Result(property = "publicProperty", column = "public_property") + , @Result(property = "packagePrivateField", column = "package_private_field") + , @Result(property = "protectedField", column = "protected_field") + , @Result(property = "publicField", column = "public_field") + , @Result(property = "privateProperty", column = "private_property") + , @Result(property = "packagePrivateProperty", column = "package_private_property") + , @Result(property = "protectedProperty", column = "protected_property") + , @Result(property = "publicProperty", column = "public_property") }) @Select({ "SELECT" diff --git a/src/test/java/org/apache/ibatis/submitted/nestedresulthandler/Person.java b/src/test/java/org/apache/ibatis/submitted/nestedresulthandler/Person.java index a90e5609758..5c30331fa6e 100644 --- a/src/test/java/org/apache/ibatis/submitted/nestedresulthandler/Person.java +++ b/src/test/java/org/apache/ibatis/submitted/nestedresulthandler/Person.java @@ -51,8 +51,9 @@ public Collection getItems() { public boolean owns(String name) { for (Item item : getItems()) { - if (item.getName().equals(name)) + if (item.getName().equals(name)) { return true; + } } return false; } diff --git a/src/test/java/org/apache/ibatis/submitted/nestedresulthandler_association/NestedResultHandlerAssociationTest.java b/src/test/java/org/apache/ibatis/submitted/nestedresulthandler_association/NestedResultHandlerAssociationTest.java index d2fddb38932..38ad6a184fb 100644 --- a/src/test/java/org/apache/ibatis/submitted/nestedresulthandler_association/NestedResultHandlerAssociationTest.java +++ b/src/test/java/org/apache/ibatis/submitted/nestedresulthandler_association/NestedResultHandlerAssociationTest.java @@ -74,8 +74,9 @@ void shouldHandleStop() throws Exception { sqlSession.select("collectPageByBirthMonth", targetMonth, context -> { Account account = (Account) context.getResultObject(); accounts.add(account); - if (accounts.size() > 1) + if (accounts.size() > 1) { context.stop(); + } }); } assertEquals(2, accounts.size()); diff --git a/src/test/java/org/apache/ibatis/submitted/primitive_result_type/IbatisConfig.java b/src/test/java/org/apache/ibatis/submitted/primitive_result_type/IbatisConfig.java index 16792addadd..5c92502ae19 100644 --- a/src/test/java/org/apache/ibatis/submitted/primitive_result_type/IbatisConfig.java +++ b/src/test/java/org/apache/ibatis/submitted/primitive_result_type/IbatisConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-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. @@ -30,7 +30,7 @@ private IbatisConfig() { } private static synchronized void init() { - if (sqlSessionFactory == null) + if (sqlSessionFactory == null) { try { final String resource = "org/apache/ibatis/submitted/primitive_result_type/ibatis.xml"; Reader reader = Resources.getResourceAsReader(resource); @@ -38,6 +38,7 @@ private static synchronized void init() { } catch (Exception e) { throw new RuntimeException(e); } + } } public static SqlSession getSession() { diff --git a/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeMapper.java b/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeMapper.java index df4f14f316a..6101fa35206 100644 --- a/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeMapper.java +++ b/src/test/java/org/apache/ibatis/submitted/record_type/RecordTypeMapper.java @@ -47,7 +47,7 @@ public interface RecordTypeMapper { @Select({ "select i.id, p.id p_id, p.val p_val, p.url p_url", "from item i left join prop p on p.id = i.prop_id", - "where i.id = #{id}" }) + "where i.id = #{id}"}) // @formatter:on Item selectItem(Integer id);