You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2021/07/27 13:01:23 UTC
[shardingsphere] branch master updated: Rename test case method
name from testXXX to assertXXX (#11542)
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 59101cd Rename test case method name from testXXX to assertXXX (#11542)
59101cd is described below
commit 59101cd962a4a21fb1842e97b12d98da58fc4626
Author: Liang Zhang <te...@163.com>
AuthorDate: Tue Jul 27 21:00:43 2021 +0800
Rename test case method name from testXXX to assertXXX (#11542)
---
.../subscriber/ProcessRegistrySubscriberTest.java | 42 +++++++++++-----------
.../authority/checker/AuthorityCheckerTest.java | 8 ++---
.../builder/StoragePrivilegeBuilderTest.java | 4 +--
.../RuleConfigurationCheckerFactoryTest.java | 11 ++----
.../SelectStatementSqlNodeConverterTest.java | 16 ++++-----
.../scaling/test/mysql/util/ScalingUtil.java | 6 ++--
6 files changed, 41 insertions(+), 46 deletions(-)
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/process/subscriber/ProcessRegistrySubscriberTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/process/subscriber/ProcessRegistrySubscriberTest.java
index 09d5882..65dba20 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/process/subscriber/ProcessRegistrySubscriberTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/process/subscriber/ProcessRegistrySubscriberTest.java
@@ -17,8 +17,6 @@
package org.apache.shardingsphere.governance.core.registry.process.subscriber;
-import java.util.Collection;
-import java.util.Collections;
import org.apache.shardingsphere.governance.core.registry.process.event.ExecuteProcessReportEvent;
import org.apache.shardingsphere.governance.core.registry.process.event.ExecuteProcessSummaryReportEvent;
import org.apache.shardingsphere.governance.core.registry.process.event.ExecuteProcessUnitReportEvent;
@@ -34,39 +32,43 @@ import org.apache.shardingsphere.infra.executor.sql.process.model.yaml.YamlExecu
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.junit.Before;
import org.junit.Test;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
-import org.mockito.MockitoAnnotations;
public final class ProcessRegistrySubscriberTest {
-
+
@Mock
private RegistryCenterRepository repository;
-
+
@InjectMocks
private ProcessRegistrySubscriber processRegistrySubscriber;
-
+
@Before
public void init() {
MockitoAnnotations.initMocks(this);
}
-
+
@Test
- public void testLoadShowProcessListData() {
+ public void assertLoadShowProcessListData() {
ShowProcessListRequestEvent showProcessListRequestEvent = mock(ShowProcessListRequestEvent.class);
Mockito.when(repository.getChildrenKeys(any())).thenReturn(Collections.singletonList("abc"));
Mockito.when(repository.get(any())).thenReturn("abc");
processRegistrySubscriber.loadShowProcessListData(showProcessListRequestEvent);
Mockito.verify(repository, times(1)).get(any());
}
-
+
@Test
- public void testReportExecuteProcessSummary() {
+ public void assertReportExecuteProcessSummary() {
ExecuteProcessContext executeProcessContext = mock(ExecuteProcessContext.class);
ExecuteProcessSummaryReportEvent event = mock(ExecuteProcessSummaryReportEvent.class);
Mockito.when(event.getExecuteProcessContext()).thenReturn(executeProcessContext);
@@ -75,9 +77,9 @@ public final class ProcessRegistrySubscriberTest {
Mockito.verify(event, times(1)).getExecuteProcessContext();
Mockito.verify(repository, times(1)).persist(anyString(), any());
}
-
+
@Test
- public void testReportExecuteProcessSummaryWithId() {
+ public void assertReportExecuteProcessSummaryWithId() {
ExecutionGroupContext executionGroupContext = mock(ExecutionGroupContext.class);
Mockito.when(executionGroupContext.getExecutionID()).thenReturn("id");
ExecuteProcessContext executeProcessContext = new ExecuteProcessContext("sql1", executionGroupContext, ExecuteProcessConstants.EXECUTE_STATUS_START);
@@ -86,9 +88,9 @@ public final class ProcessRegistrySubscriberTest {
subscriber.reportExecuteProcessSummary(event);
Mockito.verify(repository).persist("/executionnodes/id", YamlEngine.marshal(new YamlExecuteProcessContext(executeProcessContext)));
}
-
+
@Test
- public void testReportExecuteProcessUnit() {
+ public void assertReportExecuteProcessUnit() {
ExecuteProcessUnitReportEvent event = mock(ExecuteProcessUnitReportEvent.class);
Mockito.when(event.getExecutionID()).thenReturn("id");
Mockito.when(repository.get(anyString())).thenReturn(mockYamlExecuteProcessContext());
@@ -96,16 +98,16 @@ public final class ProcessRegistrySubscriberTest {
processRegistrySubscriber.reportExecuteProcessUnit(event);
Mockito.verify(repository, times(1)).persist(any(), any());
}
-
+
@Test
- public void testReportExecuteProcess() {
+ public void assertReportExecuteProcess() {
ExecuteProcessReportEvent event = mock(ExecuteProcessReportEvent.class);
Mockito.when(event.getExecutionID()).thenReturn("id");
Mockito.when(repository.get(anyString())).thenReturn(mockYamlExecuteProcessContext());
processRegistrySubscriber.reportExecuteProcess(event);
Mockito.verify(repository, times(1)).delete(any());
}
-
+
private String mockYamlExecuteProcessContext() {
YamlExecuteProcessUnit yamlExecuteProcessUnit = new YamlExecuteProcessUnit();
yamlExecuteProcessUnit.setUnitID("159917166");
@@ -115,7 +117,7 @@ public final class ProcessRegistrySubscriberTest {
yamlExecuteProcessContext.setUnitStatuses(unitStatuses);
return YamlEngine.marshal(yamlExecuteProcessContext);
}
-
+
private ExecuteProcessUnit mockExecuteProcessUnit() {
ExecutionUnit executionUnit = mock(ExecutionUnit.class);
return new ExecuteProcessUnit(executionUnit, ExecuteProcessConstants.EXECUTE_STATUS_DONE);
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/checker/AuthorityCheckerTest.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/checker/AuthorityCheckerTest.java
index b77a36b..ded7678 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/checker/AuthorityCheckerTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/checker/AuthorityCheckerTest.java
@@ -64,7 +64,7 @@ public final class AuthorityCheckerTest {
@SuppressWarnings("unchecked")
@Test
- public void testCheckSchemaByAllPrivilegesPermitted() {
+ public void assertCheckSchemaByAllPrivilegesPermitted() {
Collection<ShardingSphereUser> users = new LinkedList<>();
ShardingSphereUser root = new ShardingSphereUser("root", "", "localhost");
users.add(root);
@@ -77,7 +77,7 @@ public final class AuthorityCheckerTest {
@SuppressWarnings("unchecked")
@Test
- public void testCheckSchemaByNative() throws SQLException {
+ public void assertCheckSchemaByNative() throws SQLException {
Collection<ShardingSphereUser> users = new LinkedList<>();
ShardingSphereUser root = new ShardingSphereUser("root", "", "localhost");
users.add(root);
@@ -92,7 +92,7 @@ public final class AuthorityCheckerTest {
@SuppressWarnings("unchecked")
@Test
- public void testCheckUser() {
+ public void assertCheckUser() {
Collection<ShardingSphereUser> users = new LinkedList<>();
ShardingSphereUser root = new ShardingSphereUser("root", "", "localhost");
users.add(root);
@@ -107,7 +107,7 @@ public final class AuthorityCheckerTest {
@SuppressWarnings("unchecked")
@Test
- public void testCheckSqlStatement() {
+ public void assertCheckSQLStatement() {
Collection<ShardingSphereUser> users = new LinkedList<>();
ShardingSphereUser root = new ShardingSphereUser("root", "", "localhost");
users.add(root);
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeBuilderTest.java
index 1233a67..9a7d532 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeBuilderTest.java
@@ -43,7 +43,7 @@ import static org.mockito.Mockito.when;
public final class StoragePrivilegeBuilderTest {
@Test
- public void testBuildInCache() {
+ public void assertBuildInCache() {
Collection<ShardingSphereMetaData> metaDataList = new LinkedList<>();
Collection<ShardingSphereUser> users = new LinkedList<>();
ShardingSphereUser root = new ShardingSphereUser("root", "", "localhost");
@@ -54,7 +54,7 @@ public final class StoragePrivilegeBuilderTest {
}
@Test
- public void testBuildPrivilegesInStorage() throws SQLException {
+ public void assertBuildPrivilegesInStorage() throws SQLException {
Collection<ShardingSphereUser> users = new LinkedList<>();
ShardingSphereUser root = new ShardingSphereUser("root", "", "localhost");
users.add(root);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/checker/RuleConfigurationCheckerFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/checker/RuleConfigurationCheckerFactoryTest.java
index 275adf9..35dbee9 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/checker/RuleConfigurationCheckerFactoryTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/checker/RuleConfigurationCheckerFactoryTest.java
@@ -25,16 +25,11 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
public final class RuleConfigurationCheckerFactoryTest {
-
- private TestRuleConfiguration testRuleConfiguration() {
- return new TestRuleConfiguration();
- }
-
+
@Test
- public void testNewInstance() {
- RuleConfigurationChecker checker = RuleConfigurationCheckerFactory.newInstance(testRuleConfiguration());
+ public void assertNewInstance() {
+ RuleConfigurationChecker<?> checker = RuleConfigurationCheckerFactory.newInstance(new TestRuleConfiguration());
assertNotNull(checker);
assertTrue(checker instanceof RuleConfigurationCheckerFixture);
}
-
}
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 6dbe469..215712f 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
@@ -52,7 +52,7 @@ public final class SelectStatementSqlNodeConverterTest extends BaseSqlNodeConver
}
@Test
- public void testConvertSimpleSelect() {
+ public void assertConvertSimpleSelect() {
String sql = "select order_id, user_id from t_order";
SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql.toUpperCase(), false);
SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
@@ -68,7 +68,7 @@ public final class SelectStatementSqlNodeConverterTest extends BaseSqlNodeConver
}
@Test
- public void testConvertSimpleSelectLimit() {
+ public void assertConvertSimpleSelectLimit() {
String sql = "select order_id, user_id from t_order limit 1, 2";
SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql.toUpperCase(), false);
SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
@@ -84,7 +84,7 @@ public final class SelectStatementSqlNodeConverterTest extends BaseSqlNodeConver
}
@Test
- public void testConvertSimpleSelectRowCount() {
+ public void assertConvertSimpleSelectRowCount() {
String sql = "select order_id, user_id from t_order limit 2";
SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql.toUpperCase(), false);
SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
@@ -100,7 +100,7 @@ public final class SelectStatementSqlNodeConverterTest extends BaseSqlNodeConver
}
@Test
- public void testConvertSimpleSelectFilter() {
+ public void assertConvertSimpleSelectFilter() {
String sql = "select order_id, user_id from t_order where order_id = 10";
SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql.toUpperCase(), false);
SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
@@ -114,7 +114,7 @@ public final class SelectStatementSqlNodeConverterTest extends BaseSqlNodeConver
}
@Test
- public void testConvertSimpleSelectFilterGroupBy() {
+ public void assertConvertSimpleSelectFilterGroupBy() {
String sql = "select order_id, user_id from t_order where order_id = 10 group by order_id";
SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql.toUpperCase(), false);
SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
@@ -129,7 +129,7 @@ public final class SelectStatementSqlNodeConverterTest extends BaseSqlNodeConver
}
@Test
- public void testConvertSimpleSelectFilterOrderBy() {
+ public void assertConvertSimpleSelectFilterOrderBy() {
String sql = "select order_id, user_id from t_order where user_id = 10 order by order_id desc";
SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql.toUpperCase(), false);
SqlNode sqlNode = SqlNodeConvertEngine.convert(sqlStatement);
@@ -144,7 +144,7 @@ public final class SelectStatementSqlNodeConverterTest extends BaseSqlNodeConver
}
@Test
- public void testConvertInnerJoin() {
+ public void assertConvertInnerJoin() {
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";
@@ -158,7 +158,7 @@ public final class SelectStatementSqlNodeConverterTest extends BaseSqlNodeConver
}
@Test
- public void testConvertLeftOuterJoin() {
+ public void assertConvertLeftOuterJoin() {
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 "
+ "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";
diff --git a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/ScalingUtil.java b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/ScalingUtil.java
index eb17115..cef7fd3 100644
--- a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/ScalingUtil.java
+++ b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/ScalingUtil.java
@@ -122,13 +122,11 @@ public final class ScalingUtil {
*/
public Map<String, Tuple2<Boolean, Boolean>> getJobCheckResult(final String jobId) throws IOException {
JsonElement response = getInstance().get(scalingUrl + "/scaling/job/check/" + jobId);
- return response.getAsJsonObject().getAsJsonObject("model").getAsJsonObject().entrySet().stream().collect(
- Collectors.toMap(Entry::getKey, this::createTaskResult));
+ return response.getAsJsonObject().getAsJsonObject("model").getAsJsonObject().entrySet().stream().collect(Collectors.toMap(Entry::getKey, this::createTaskResult));
}
private Tuple2<Boolean, Boolean> createTaskResult(final Entry<String, JsonElement> entry) {
- return new Tuple2<>(entry.getValue().getAsJsonObject().get("countValid").getAsBoolean(),
- entry.getValue().getAsJsonObject().get("dataValid").getAsBoolean());
+ return new Tuple2<>(entry.getValue().getAsJsonObject().get("countValid").getAsBoolean(), entry.getValue().getAsJsonObject().get("dataValid").getAsBoolean());
}
/**