This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new fa8a7f0  Use assertThat to instead of assertEquals (#11526)
fa8a7f0 is described below

commit fa8a7f05d64e3336135033ea235a2baffb5c9cd7
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jul 27 12:58:07 2021 +0800

    Use assertThat to instead of assertEquals (#11526)
---
 .../advice/CommandExecutorTaskAdviceTest.java      |  9 ++--
 ...elemetryTracingPluginDefinitionServiceTest.java | 12 ++---
 .../advice/CommandExecutorTaskAdviceTest.java      |  6 +--
 .../dialect/OraclePrivilegeHandlerTest.java        | 23 ++++-----
 .../dialect/PostgreSQLPrivilegeHandlerTest.java    | 15 +++---
 .../schema/builder/util/IndexMetaDataUtilTest.java | 19 +++----
 .../SelectStatementSqlNodeConverterTest.java       | 58 +++++++++++-----------
 .../proxy/backend/context/ProxyContextTest.java    |  5 +-
 .../sql/common/extractor/TableExtractorTest.java   | 37 ++++++--------
 .../transaction/core/ResourceDataSourceTest.java   |  7 +--
 10 files changed, 87 insertions(+), 104 deletions(-)

diff --git 
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
 
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
index 58eacda..c8b1af7 100644
--- 
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
+++ 
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
@@ -17,14 +17,13 @@
 
 package org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice;
 
-import com.google.common.collect.Maps;
 import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockSpan.LogEntry;
 import io.opentracing.tag.Tags;
 import org.apache.shardingsphere.agent.api.result.MethodInvocationResult;
 import 
org.apache.shardingsphere.agent.plugin.tracing.advice.AbstractCommandExecutorTaskAdviceTest;
 import 
org.apache.shardingsphere.agent.plugin.tracing.jaeger.collector.JaegerCollector;
 import 
org.apache.shardingsphere.agent.plugin.tracing.jaeger.constant.JaegerConstants;
-import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -70,17 +69,17 @@ public final class CommandExecutorTaskAdviceTest extends 
AbstractCommandExecutor
         ADVICE.onThrowing(getTargetObject(), null, new Object[]{}, new 
IOException());
         ADVICE.afterMethod(getTargetObject(), null, new Object[]{}, new 
MethodInvocationResult());
         List<MockSpan> spans = COLLECTOR.finishedSpans();
-        Assert.assertEquals(1, spans.size());
+        assertThat(spans.size(), is(1));
         MockSpan span = spans.get(0);
         assertThat(span.tags().get("error"), is(true));
-        List<MockSpan.LogEntry> entries = span.logEntries();
+        List<LogEntry> entries = span.logEntries();
         assertThat(entries.size(), is(1));
         Map<String, ?> fields = entries.get(0).fields();
         assertThat(fields.get("event"), is("error"));
         assertNull(fields.get("message"));
         assertThat(fields.get("error.kind"), is("java.io.IOException"));
         assertThat(span.operationName(), is("/ShardingSphere/rootInvoke/"));
-        Map<Object, Object> map = Maps.newHashMap(EXPECTED);
+        Map<Object, Object> map = new HashMap<>(EXPECTED);
         map.put(JaegerConstants.ErrorLogTagKeys.EVENT_ERROR_TYPE, true);
         assertThat(spans.get(0).tags(), is(map));
     }
diff --git 
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentelemetry/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/definition/OpenTelemetryTracingPluginDefinitionServiceTest.java
 
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentelemetry/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/defini
 [...]
index e67eb63..85ad959 100644
--- 
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentelemetry/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/definition/OpenTelemetryTracingPluginDefinitionServiceTest.java
+++ 
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentelemetry/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/definition/OpenTelemetryTracingPluginDefinitionServiceTest.java
@@ -17,26 +17,26 @@
 
 package 
org.apache.shardingsphere.agent.plugin.tracing.opentelemetry.definition;
 
-import java.util.Collection;
 import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
 import org.junit.Test;
 
+import java.util.Collection;
+
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 
 public final class OpenTelemetryTracingPluginDefinitionServiceTest {
-
+    
     private final OpenTelemetryTracingPluginDefinitionService 
definitionService = new OpenTelemetryTracingPluginDefinitionService();
-
+    
     @Test
     public void assertDefine() {
         Collection<PluginInterceptorPoint> interceptorPointList = 
definitionService.install();
         assertThat(interceptorPointList.size(), is(3));
     }
-
+    
     @Test
     public void assertType() {
-        assertEquals("OpenTelemetry", definitionService.getType());
+        assertThat(definitionService.getType(), is("OpenTelemetry"));
     }
 }
diff --git 
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
 
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
index 4d6aa8d..ff3c3e6 100644
--- 
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
+++ 
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice;
 
 import io.netty.channel.ChannelHandlerContext;
 import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockSpan.LogEntry;
 import io.opentracing.mock.MockTracer;
 import io.opentracing.util.GlobalTracer;
 import lombok.SneakyThrows;
@@ -26,7 +27,6 @@ import 
org.apache.shardingsphere.agent.api.result.MethodInvocationResult;
 import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -83,10 +83,10 @@ public final class CommandExecutorTaskAdviceTest {
         ADVICE.onThrowing(targetObject, executeCommandMethod, new Object[]{}, 
new IOException());
         ADVICE.afterMethod(targetObject, executeCommandMethod, new Object[]{}, 
new MethodInvocationResult());
         List<MockSpan> spans = tracer.finishedSpans();
-        Assert.assertEquals(1, spans.size());
+        assertThat(spans.size(), is(1));
         MockSpan span = spans.get(0);
         assertThat(span.tags().get("error"), is(true));
-        List<MockSpan.LogEntry> entries = span.logEntries();
+        List<LogEntry> entries = span.logEntries();
         assertThat(entries.size(), is(1));
         Map<String, ?> fields = entries.get(0).fields();
         assertThat(fields.get("event"), is("error"));
diff --git 
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
 
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
index db4c8a8..9b57735 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
@@ -41,7 +41,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.stream.Collectors;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
@@ -86,18 +85,18 @@ public final class OraclePrivilegeHandlerTest {
         DataSource dataSource = mockDataSource(users);
         
assertPrivileges(TypedSPIRegistry.getRegisteredService(StoragePrivilegeHandler.class,
 "Oracle", new Properties()).load(users, dataSource));
     }
-
+    
     private void assertCreateUsers(final Collection<ShardingSphereUser> users, 
final Statement statement) throws SQLException {
         for (ShardingSphereUser each : users) {
             verify(statement).execute(String.format("CREATE USER %s IDENTIFIED 
BY %s", each.getGrantee().getUsername(), each.getPassword()));
         }
     }
-
+    
     private void assertDiffUsers(final Collection<ShardingSphereUser> users) {
         assertThat(users.size(), is(1));
         assertThat(users.iterator().next().getGrantee().getUsername(), 
is("user"));
     }
-
+    
     private void assertGrantUsersAll(final Collection<ShardingSphereUser> 
users, final Statement statement) throws SQLException {
         for (ShardingSphereUser each : users) {
             verify(statement).execute(String.format("GRANT ALL PRIVILEGES TO 
%s", each.getGrantee().getUsername()));
@@ -109,20 +108,20 @@ public final class OraclePrivilegeHandlerTest {
         ShardingSphereUser user = new ShardingSphereUser("admin", "", "");
         
assertThat(actual.get(user).getDatabasePrivileges().getGlobalPrivileges().size(),
 is(0));
         
assertThat(actual.get(user).getDatabasePrivileges().getSpecificPrivileges().size(),
 is(1));
-        Collection<PrivilegeType> expectedSpecificPrivilege = new 
CopyOnWriteArraySet(Arrays.asList(PrivilegeType.INSERT, PrivilegeType.SELECT, 
PrivilegeType.UPDATE));
+        Collection<PrivilegeType> expectedSpecificPrivilege = new 
CopyOnWriteArraySet<>(Arrays.asList(PrivilegeType.INSERT, PrivilegeType.SELECT, 
PrivilegeType.UPDATE));
         SchemaPrivileges schemaPrivileges = 
actual.get(user).getDatabasePrivileges().getSpecificPrivileges().get("sys");
         
assertThat(schemaPrivileges.getSpecificPrivileges().get("t_order").hasPrivileges(expectedSpecificPrivilege),
 is(true));
         
assertThat(actual.get(user).getAdministrativePrivileges().getPrivileges().size(),
 is(3));
-        Collection<PrivilegeType> expectedAdminPrivileges = new 
CopyOnWriteArraySet(Arrays.asList(PrivilegeType.SUPER, 
PrivilegeType.CREATE_ROLE, PrivilegeType.CREATE_TABLESPACE));
-        
assertEquals(actual.get(user).getAdministrativePrivileges().getPrivileges(), 
expectedAdminPrivileges);
+        Collection<PrivilegeType> expectedAdminPrivileges = new 
CopyOnWriteArraySet<>(Arrays.asList(PrivilegeType.SUPER, 
PrivilegeType.CREATE_ROLE, PrivilegeType.CREATE_TABLESPACE));
+        
assertThat(actual.get(user).getAdministrativePrivileges().getPrivileges(), 
is(expectedAdminPrivileges));
     }
-
+    
     private Collection<ShardingSphereUser> createUsers() {
         LinkedList<ShardingSphereUser> result = new LinkedList<>();
         result.add(new ShardingSphereUser("admin", "", ""));
         return result;
     }
-
+    
     private DataSource mockDataSource(final Collection<ShardingSphereUser> 
users) throws SQLException {
         ResultSet sysPrivilegeResultSet = mockSysPrivilegeResultSet();
         DataSource result = mock(DataSource.class, RETURNS_DEEP_STUBS);
@@ -134,7 +133,7 @@ public final class OraclePrivilegeHandlerTest {
         
when(result.getConnection().createStatement().executeQuery(String.format(tabPrivilegeSql,
 userList))).thenReturn(tabPrivilegeResultSet);
         return result;
     }
-
+    
     private DataSource mockDataSourceForUsers(final 
Collection<ShardingSphereUser> users) throws SQLException {
         ResultSet usersResultSet = mockUsersResultSet();
         DataSource result = mock(DataSource.class, RETURNS_DEEP_STUBS);
@@ -155,7 +154,7 @@ public final class OraclePrivilegeHandlerTest {
         when(result.getString("PRIVILEGE")).thenReturn("SYSDBA", "CREATE 
ROLE", "CREATE TABLESPACE");
         return result;
     }
-
+    
     private ResultSet mockTabPrivilegeResultSet() throws SQLException {
         ResultSet result = mock(ResultSet.class, RETURNS_DEEP_STUBS);
         when(result.next()).thenReturn(true, true, true, true, false);
@@ -166,7 +165,7 @@ public final class OraclePrivilegeHandlerTest {
         when(result.getString("GRANTEE")).thenReturn("admin");
         return result;
     }
-
+    
     private ResultSet mockUsersResultSet() throws SQLException {
         ResultSet result = mock(ResultSet.class);
         when(result.next()).thenReturn(true, false);
diff --git 
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandlerTest.java
 
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandlerTest.java
index faf8282..de93da2 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandlerTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandlerTest.java
@@ -41,12 +41,12 @@ import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.stream.Collectors;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public final class PostgreSQLPrivilegeHandlerTest {
     
@@ -89,16 +89,15 @@ public final class PostgreSQLPrivilegeHandlerTest {
     private void assertPrivileges(final Map<ShardingSphereUser, 
NativePrivileges> actual) {
         assertThat(actual.size(), is(1));
         ShardingSphereUser user = new ShardingSphereUser("postgres", "", "");
-        
assertThat(actual.get(user).getDatabasePrivileges().getGlobalPrivileges().size(),
 is(0));
+        
assertTrue(actual.get(user).getDatabasePrivileges().getGlobalPrivileges().isEmpty());
         
assertThat(actual.get(user).getDatabasePrivileges().getSpecificPrivileges().size(),
 is(1));
-        Collection<PrivilegeType> expectedSpecificPrivilege = new 
CopyOnWriteArraySet(Arrays.asList(PrivilegeType.INSERT, PrivilegeType.SELECT, 
PrivilegeType.UPDATE,
-                PrivilegeType.DELETE));
+        Collection<PrivilegeType> expectedSpecificPrivilege = new 
CopyOnWriteArraySet<>(Arrays.asList(PrivilegeType.INSERT, PrivilegeType.SELECT, 
PrivilegeType.UPDATE, PrivilegeType.DELETE));
         SchemaPrivileges schemaPrivileges = 
actual.get(user).getDatabasePrivileges().getSpecificPrivileges().get("db0");
         
assertThat(schemaPrivileges.getSpecificPrivileges().get("t_order").hasPrivileges(expectedSpecificPrivilege),
 is(true));
         
assertThat(actual.get(user).getAdministrativePrivileges().getPrivileges().size(),
 is(4));
-        Collection<PrivilegeType> expectedAdminPrivileges = new 
CopyOnWriteArraySet(
+        Collection<PrivilegeType> expectedAdminPrivileges = new 
CopyOnWriteArraySet<>(
                 Arrays.asList(PrivilegeType.SUPER, PrivilegeType.CREATE_ROLE, 
PrivilegeType.CREATE_DATABASE, PrivilegeType.CAN_LOGIN));
-        
assertEquals(actual.get(user).getAdministrativePrivileges().getPrivileges(), 
expectedAdminPrivileges);
+        
assertThat(actual.get(user).getAdministrativePrivileges().getPrivileges(), 
is(expectedAdminPrivileges));
     }
     
     private void assertDiffUsers(final Collection<ShardingSphereUser> users) {
@@ -119,7 +118,7 @@ public final class PostgreSQLPrivilegeHandlerTest {
     }
     
     private Collection<ShardingSphereUser> createUsers() {
-        LinkedList<ShardingSphereUser> result = new LinkedList<>();
+        Collection<ShardingSphereUser> result = new LinkedList<>();
         result.add(new ShardingSphereUser("postgres", "", ""));
         return result;
     }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/IndexMetaDataUtilTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/IndexMetaDataUtilTest.java
index 13e48a1..0c61cf7 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/IndexMetaDataUtilTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/IndexMetaDataUtilTest.java
@@ -17,38 +17,35 @@
 
 package org.apache.shardingsphere.infra.metadata.schema.builder.util;
 
-import org.junit.Assert;
 import org.junit.Test;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
 public class IndexMetaDataUtilTest {
     
     @Test
     public void assertGetLogicIndexNameWithIndexNameSuffix() {
-        String logicIndexName = 
IndexMetaDataUtil.getLogicIndexName("order_index_t_order", "t_order");
-        Assert.assertEquals(logicIndexName, "order_index");
+        assertThat(IndexMetaDataUtil.getLogicIndexName("order_index_t_order", 
"t_order"), is("order_index"));
     }
     
     @Test
     public void assertGetLogicIndexNameWithMultiIndexNameSuffix() {
-        String logicIndexName = 
IndexMetaDataUtil.getLogicIndexName("order_t_order_index_t_order", "t_order");
-        Assert.assertEquals(logicIndexName, "order_t_order_index");
+        
assertThat(IndexMetaDataUtil.getLogicIndexName("order_t_order_index_t_order", 
"t_order"), is("order_t_order_index"));
     }
     
     @Test
     public void assertGetLogicIndexNameWithoutIndexNameSuffix() {
-        String logicIndexName = 
IndexMetaDataUtil.getLogicIndexName("order_index", "t_order");
-        Assert.assertEquals(logicIndexName, "order_index");
+        assertThat(IndexMetaDataUtil.getLogicIndexName("order_index", 
"t_order"), is("order_index"));
     }
     
     @Test
     public void assertGetActualIndexNameWithActualTableName() {
-        String actualIndexName = 
IndexMetaDataUtil.getActualIndexName("order_index", "t_order");
-        Assert.assertEquals(actualIndexName, "order_index_t_order");
+        assertThat(IndexMetaDataUtil.getActualIndexName("order_index", 
"t_order"), is("order_index_t_order"));
     }
     
     @Test
     public void assertGetActualIndexNameWithoutActualTableName() {
-        String actualIndexName = 
IndexMetaDataUtil.getActualIndexName("order_index", null);
-        Assert.assertEquals(actualIndexName, "order_index");
+        assertThat(IndexMetaDataUtil.getActualIndexName("order_index", null), 
is("order_index"));
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-optimize/src/test/java/org/apache/shardingsphere/infra/optimize/core/convert/SelectStatementSqlNodeConverterTest.java
 
b/shardingsphere-infra/shardingsphere-infra-optimize/src/test/java/org/apache/shardingsphere/infra/optimize/core/convert/SelectStatementSqlNodeConverterTest.java
index ef50e96..6dbe469 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-optimize/src/test/java/org/apache/shardingsphere/infra/optimize/core/convert/SelectStatementSqlNodeConverterTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-optimize/src/test/java/org/apache/shardingsphere/infra/optimize/core/convert/SelectStatementSqlNodeConverterTest.java
@@ -30,7 +30,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
@@ -43,15 +43,14 @@ import static org.junit.Assert.assertThat;
  * </p>
  */
 public final class SelectStatementSqlNodeConverterTest extends 
BaseSqlNodeConverterTest {
-
+    
     private ShardingSphereSQLParserEngine sqlStatementParserEngine;
-
+    
     @Before
     public void init() {
-        sqlStatementParserEngine = new 
ShardingSphereSQLParserEngine(DatabaseTypeRegistry.getTrunkDatabaseTypeName(
-                new MySQLDatabaseType()));
+        sqlStatementParserEngine = new 
ShardingSphereSQLParserEngine(DatabaseTypeRegistry.getTrunkDatabaseTypeName(new 
MySQLDatabaseType()));
     }
-
+    
     @Test
     public void testConvertSimpleSelect() {
         String sql = "select order_id, user_id from t_order";
@@ -59,16 +58,15 @@ public final class SelectStatementSqlNodeConverterTest 
extends BaseSqlNodeConver
         SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
         assertThat(sqlNode, instanceOf(SqlSelect.class));
         SqlSelect sqlSelect = (SqlSelect) sqlNode;
-        assertEquals(2, sqlSelect.getSelectList().size());
+        assertThat(sqlSelect.getSelectList().size(), is(2));
         assertNull(sqlSelect.getWhere());
         assertNull(sqlSelect.getOffset());
         assertNull(sqlSelect.getFetch());
-        // compare ast from calcite parser
         SqlNode calciteSqlNode = parseByCalciteParser(sql);
         assertNotNull(calciteSqlNode);
-        assertEquals(sqlNode.toString(), calciteSqlNode.toString());
+        assertThat(sqlNode.toString(), is(calciteSqlNode.toString()));
     }
-
+    
     @Test
     public void testConvertSimpleSelectLimit() {
         String sql = "select order_id, user_id from t_order limit 1, 2";
@@ -76,15 +74,15 @@ public final class SelectStatementSqlNodeConverterTest 
extends BaseSqlNodeConver
         SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
         assertThat(sqlNode, instanceOf(SqlSelect.class));
         SqlSelect sqlSelect = (SqlSelect) sqlNode;
-        assertEquals(2, sqlSelect.getSelectList().size());
+        assertThat(sqlSelect.getSelectList().size(), is(2));
         assertNull(sqlSelect.getWhere());
         assertNotNull(sqlSelect.getOffset());
         assertNotNull(sqlSelect.getFetch());
         SqlNode calciteSqlNode = parseByCalciteParser(sql, new 
MySQLDatabaseType());
         assertNotNull(calciteSqlNode);
-        assertEquals(sqlNode.toString(), calciteSqlNode.toString());
+        assertThat(sqlNode.toString(), is(calciteSqlNode.toString()));
     }
-
+    
     @Test
     public void testConvertSimpleSelectRowCount() {
         String sql = "select order_id, user_id from t_order limit 2";
@@ -92,15 +90,15 @@ public final class SelectStatementSqlNodeConverterTest 
extends BaseSqlNodeConver
         SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
         assertThat(sqlNode, instanceOf(SqlSelect.class));
         SqlSelect sqlSelect = (SqlSelect) sqlNode;
-        assertEquals(2, sqlSelect.getSelectList().size());
+        assertThat(sqlSelect.getSelectList().size(), is(2));
         assertNull(sqlSelect.getWhere());
         assertNull(sqlSelect.getOffset());
         assertNotNull(sqlSelect.getFetch());
         SqlNode calciteSqlNode = parseByCalciteParser(sql, new 
MySQLDatabaseType());
         assertNotNull(calciteSqlNode);
-        assertEquals(sqlNode.toString(), calciteSqlNode.toString());
+        assertThat(sqlNode.toString(), is(calciteSqlNode.toString()));
     }
-
+    
     @Test
     public void testConvertSimpleSelectFilter() {
         String sql = "select order_id, user_id from t_order where order_id = 
10";
@@ -108,13 +106,13 @@ public final class SelectStatementSqlNodeConverterTest 
extends BaseSqlNodeConver
         SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
         assertThat(sqlNode, instanceOf(SqlSelect.class));
         SqlSelect sqlSelect = (SqlSelect) sqlNode;
-        assertEquals(2, sqlSelect.getSelectList().size());
+        assertThat(sqlSelect.getSelectList().size(), is(2));
         assertNotNull(sqlSelect.getWhere());
         SqlNode calciteSqlNode = parseByCalciteParser(sql, new 
MySQLDatabaseType());
         assertNotNull(calciteSqlNode);
-        assertEquals(sqlNode.toString(), calciteSqlNode.toString());
+        assertThat(sqlNode.toString(), is(calciteSqlNode.toString()));
     }
-
+    
     @Test
     public void testConvertSimpleSelectFilterGroupBy() {
         String sql = "select order_id, user_id from t_order where order_id = 
10 group by order_id";
@@ -122,14 +120,14 @@ public final class SelectStatementSqlNodeConverterTest 
extends BaseSqlNodeConver
         SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
         assertThat(sqlNode, instanceOf(SqlSelect.class));
         SqlSelect sqlSelect = (SqlSelect) sqlNode;
-        assertEquals(2, sqlSelect.getSelectList().size());
+        assertThat(sqlSelect.getSelectList().size(), is(2));
         assertNotNull(sqlSelect.getWhere());
-        assertEquals(1, sqlSelect.getGroup().size());
+        assertThat(sqlSelect.getGroup().size(), is(1));
         SqlNode calciteSqlNode = parseByCalciteParser(sql, new 
MySQLDatabaseType());
         assertNotNull(calciteSqlNode);
-        assertEquals(sqlNode.toString(), calciteSqlNode.toString());
+        assertThat(sqlNode.toString(), is(calciteSqlNode.toString()));
     }
-
+    
     @Test
     public void testConvertSimpleSelectFilterOrderBy() {
         String sql = "select order_id, user_id from t_order where user_id = 10 
order by order_id desc";
@@ -137,28 +135,28 @@ public final class SelectStatementSqlNodeConverterTest 
extends BaseSqlNodeConver
         SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
         assertThat(sqlNode, instanceOf(SqlSelect.class));
         SqlSelect sqlSelect = (SqlSelect) sqlNode;
-        assertEquals(2, sqlSelect.getSelectList().size());
+        assertThat(sqlSelect.getSelectList().size(), is(2));
         assertNotNull(sqlSelect.getWhere());
-        assertEquals(1, sqlSelect.getOrderList().size());
+        assertThat(sqlSelect.getOrderList().size(), is(1));
         SqlNode calciteSqlNode = parseByCalciteParser(sql, new 
MySQLDatabaseType());
         assertNotNull(calciteSqlNode);
-        assertEquals(sqlNode.toString(), calciteSqlNode.toString());
+        assertThat(sqlNode.toString(), is(calciteSqlNode.toString()));
     }
-
+    
     @Test
     public void testConvertInnerJoin() {
         String sql = "select 10 + 30, o1.order_id + 10, o1.order_id, 
o1.user_id, o2.status from t_order o1 join t_order_item o2 on "
                 + "o1.order_id = o2.order_id where o1.status='FINISHED' and 
o2.order_item_id > 1024 and 1=1 order by "
                 + "o1.order_id desc";
         SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql, false);
-        assertEquals("INNER", ((JoinTableSegment) ((MySQLSelectStatement) 
sqlStatement).getFrom()).getJoinType());
+        assertThat(((JoinTableSegment) ((MySQLSelectStatement) 
sqlStatement).getFrom()).getJoinType(), is("INNER"));
         SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
         assertThat(sqlNode, instanceOf(SqlSelect.class));
         SqlSelect sqlSelect = (SqlSelect) sqlNode;
         assertThat(sqlSelect.getFrom(), instanceOf(SqlJoin.class));
-        assertEquals(1, sqlSelect.getOrderList().size());
+        assertThat(sqlSelect.getOrderList().size(), is(1));
     }
-
+    
     @Test
     public void testConvertLeftOuterJoin() {
         String sql = "select 10 + 30, o1.order_id + 10, o1.order_id, 
o1.user_id, o2.status from t_order o1 left outer join t_order_item o2 on "
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
index ee7e900..0fccf43 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
@@ -38,7 +38,6 @@ import java.util.Map;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
@@ -57,8 +56,8 @@ public final class ProxyContextTest {
         TransactionContexts transactionContexts = 
mock(TransactionContexts.class);
         ProxyContext proxyContext = ProxyContext.getInstance();
         proxyContext.init(metaDataContexts, transactionContexts);
-        assertEquals(metaDataContexts, proxyContext.getMetaDataContexts());
-        assertEquals(transactionContexts, 
proxyContext.getTransactionContexts());
+        assertThat(proxyContext.getMetaDataContexts(), is(metaDataContexts));
+        assertThat(proxyContext.getTransactionContexts(), 
is(transactionContexts));
     }
     
     @Test
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractorTest.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractorTest.java
index dad2075..b9a9567 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractorTest.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractorTest.java
@@ -22,32 +22,27 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.Sim
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLSelectStatement;
-import org.junit.Before;
 import org.junit.Test;
 
 import java.util.Iterator;
 import java.util.Optional;
 
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
-public class TableExtractorTest {
-
-    private TableExtractor tableExtractor;
-
-    @Before
-    public void init() {
-        tableExtractor = new TableExtractor();
-    }
-
+public final class TableExtractorTest {
+    
+    private final TableExtractor tableExtractor = new TableExtractor();
+    
     @Test
     public void assertExtractTablesFromSelectLockWithEmptyValue() {
         MySQLSelectStatement selectStatement = new MySQLSelectStatement();
         tableExtractor.extractTablesFromSelect(selectStatement);
         assertTrue(tableExtractor.getRewriteTables().isEmpty());
     }
-
+    
     @Test
     public void assertExtractTablesFromSelectLockWithValue() {
         MySQLSelectStatement selectStatement = new MySQLSelectStatement();
@@ -57,21 +52,17 @@ public class TableExtractorTest {
         lockSegment.getTables().add(new SimpleTableSegment(new 
TableNameSegment(143, 154, new IdentifierValue("t_order_item"))));
         tableExtractor.extractTablesFromSelect(selectStatement);
         assertNotNull(tableExtractor.getRewriteTables());
-        assertEquals(2, tableExtractor.getRewriteTables().size());
+        assertThat(tableExtractor.getRewriteTables().size(), is(2));
         Iterator<SimpleTableSegment> tableSegmentIterator = 
tableExtractor.getRewriteTables().iterator();
         assertTableSegment(tableSegmentIterator.next(), 122, 128, "t_order");
         assertTableSegment(tableSegmentIterator.next(), 143, 154, 
"t_order_item");
     }
-
-    private void assertTableSegment(final SimpleTableSegment actual,
-                                    final int expectedStartIndex, final int 
expectedStopIndex, final String expectedTableName) {
-        assertEquals(expectedStartIndex, actual.getStartIndex());
-        assertEquals(expectedStopIndex, actual.getStopIndex());
-        Optional<String> actualTableName = 
Optional.ofNullable(actual.getTableName())
-                                                    
.map(TableNameSegment::getIdentifier)
-                                                    
.map(IdentifierValue::getValue);
+    
+    private void assertTableSegment(final SimpleTableSegment actual, final int 
expectedStartIndex, final int expectedStopIndex, final String 
expectedTableName) {
+        assertThat(actual.getStartIndex(), is(expectedStartIndex));
+        assertThat(actual.getStopIndex(), is(expectedStopIndex));
+        Optional<String> actualTableName = 
Optional.ofNullable(actual.getTableName()).map(TableNameSegment::getIdentifier).map(IdentifierValue::getValue);
         assertTrue(actualTableName.isPresent());
-        assertEquals(expectedTableName, actualTableName.get());
+        assertThat(actualTableName.get(), is(expectedTableName));
     }
-
 }
diff --git 
a/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceDataSourceTest.java
 
b/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceDataSourceTest.java
index 58d6b1b..7a5a9d8 100644
--- 
a/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceDataSourceTest.java
+++ 
b/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceDataSourceTest.java
@@ -20,15 +20,16 @@ package org.apache.shardingsphere.transaction.core;
 import org.apache.commons.dbcp2.BasicDataSource;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 public final class ResourceDataSourceTest {
-
+    
     @Test
     public void assertNewInstance() {
         ResourceDataSource testResourceDataSource = new 
ResourceDataSource("sampleDataSource", new BasicDataSource());
-        assertEquals("sampleDataSource", 
testResourceDataSource.getOriginalName());
+        assertThat(testResourceDataSource.getOriginalName(), 
is("sampleDataSource"));
         assertTrue(testResourceDataSource.getDataSource() instanceof 
BasicDataSource);
         
assertTrue(testResourceDataSource.getUniqueResourceName().contains("resource"));
         
assertTrue(testResourceDataSource.getUniqueResourceName().contains("sampleDataSource"));

Reply via email to