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

yx9o 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 ac0ef03f9ae Replace assertTrue(obj instanceof class) with 
assertInstanceOf (#30292)
ac0ef03f9ae is described below

commit ac0ef03f9ae551bc04050075113abb10a30844df
Author: Raigor <[email protected]>
AuthorDate: Mon Feb 26 14:36:56 2024 +0800

    Replace assertTrue(obj instanceof class) with assertInstanceOf (#30292)
---
 .../NewYamlShardingRuleConfigurationSwapperTest.java     | 16 ++++++++++------
 .../ingest/wal/decode/MppdbDecodingPluginTest.java       |  6 +++---
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapperTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapperTest.java
index 3283020767e..ad926dcb1c2 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapperTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapperTest.java
@@ -33,11 +33,13 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -184,15 +186,17 @@ class NewYamlShardingRuleConfigurationSwapperTest {
         config.add(new 
YamlDataNode("/metadata/foo_db/rules/sharding/key_generators/auto_increment/versions/0",
 "type: AUTO_INCREMENT.FIXTURE\n"));
         config.add(new 
YamlDataNode("/metadata/foo_db/rules/sharding/auditors/audit_algorithm/versions/0",
 "type: DML_SHARDING_CONDITIONS\n"));
         config.add(new 
YamlDataNode("/metadata/foo_db/rules/sharding/default_strategies/default_sharding_column/versions/0",
 "table_id"));
-        ShardingRuleConfiguration result = swapper.swapToObject(config).get();
+        Optional<ShardingRuleConfiguration> shardingRuleConfig = 
swapper.swapToObject(config);
+        assertTrue(shardingRuleConfig.isPresent());
+        ShardingRuleConfiguration result = shardingRuleConfig.get();
         assertThat(result.getTables().size(), is(2));
         assertThat(result.getTables().iterator().next().getLogicTable(), 
is("LOGIC_TABLE"));
         assertThat(result.getTables().iterator().next().getActualDataNodes(), 
is("ds_${0..1}.table_${0..2}"));
-        
assertTrue(result.getTables().iterator().next().getDatabaseShardingStrategy() 
instanceof StandardShardingStrategyConfiguration);
+        assertInstanceOf(StandardShardingStrategyConfiguration.class, 
result.getTables().iterator().next().getDatabaseShardingStrategy());
         assertThat(((StandardShardingStrategyConfiguration) 
result.getTables().iterator().next().getDatabaseShardingStrategy()).getShardingColumn(),
 is("user_id"));
         
assertThat(result.getTables().iterator().next().getDatabaseShardingStrategy().getShardingAlgorithmName(),
 is("database_inline"));
         
assertThat(result.getTables().iterator().next().getDatabaseShardingStrategy().getType(),
 is("STANDARD"));
-        
assertTrue(result.getTables().iterator().next().getTableShardingStrategy() 
instanceof StandardShardingStrategyConfiguration);
+        assertInstanceOf(StandardShardingStrategyConfiguration.class, 
result.getTables().iterator().next().getTableShardingStrategy());
         assertThat(((StandardShardingStrategyConfiguration) 
result.getTables().iterator().next().getTableShardingStrategy()).getShardingColumn(),
 is("order_id"));
         
assertThat(result.getTables().iterator().next().getTableShardingStrategy().getShardingAlgorithmName(),
 is("table_inline"));
         
assertThat(result.getTables().iterator().next().getTableShardingStrategy().getType(),
 is("STANDARD"));
@@ -204,7 +208,7 @@ class NewYamlShardingRuleConfigurationSwapperTest {
         assertThat(result.getAutoTables().size(), is(1));
         assertThat(result.getAutoTables().iterator().next().getLogicTable(), 
is("auto_table"));
         
assertThat(result.getAutoTables().iterator().next().getActualDataSources(), 
is("ds_1,ds_2"));
-        
assertTrue(result.getAutoTables().iterator().next().getShardingStrategy() 
instanceof StandardShardingStrategyConfiguration);
+        assertInstanceOf(StandardShardingStrategyConfiguration.class, 
result.getAutoTables().iterator().next().getShardingStrategy());
         assertThat(((StandardShardingStrategyConfiguration) 
result.getAutoTables().iterator().next().getShardingStrategy()).getShardingColumn(),
 is("user_id"));
         
assertThat(result.getAutoTables().iterator().next().getShardingStrategy().getShardingAlgorithmName(),
 is("hash_mod"));
         
assertThat(result.getAutoTables().iterator().next().getShardingStrategy().getType(),
 is("STANDARD"));
@@ -216,11 +220,11 @@ class NewYamlShardingRuleConfigurationSwapperTest {
         assertThat(result.getBindingTableGroups().size(), is(1));
         assertThat(result.getBindingTableGroups().iterator().next().getName(), 
is("foo"));
         
assertThat(result.getBindingTableGroups().iterator().next().getReference(), 
is("LOGIC_TABLE,SUB_LOGIC_TABLE"));
-        assertTrue(result.getDefaultDatabaseShardingStrategy() instanceof 
StandardShardingStrategyConfiguration);
+        assertInstanceOf(StandardShardingStrategyConfiguration.class, 
result.getDefaultDatabaseShardingStrategy());
         assertThat(((StandardShardingStrategyConfiguration) 
result.getDefaultDatabaseShardingStrategy()).getType(), is("STANDARD"));
         assertThat(((StandardShardingStrategyConfiguration) 
result.getDefaultDatabaseShardingStrategy()).getShardingColumn(), is("ds_id"));
         
assertThat(result.getDefaultDatabaseShardingStrategy().getShardingAlgorithmName(),
 is("standard"));
-        assertTrue(result.getDefaultTableShardingStrategy() instanceof 
StandardShardingStrategyConfiguration);
+        assertInstanceOf(StandardShardingStrategyConfiguration.class, 
result.getDefaultTableShardingStrategy());
         assertThat(((StandardShardingStrategyConfiguration) 
result.getDefaultTableShardingStrategy()).getType(), is("STANDARD"));
         assertThat(((StandardShardingStrategyConfiguration) 
result.getDefaultTableShardingStrategy()).getShardingColumn(), is("table_id"));
         
assertThat(result.getDefaultTableShardingStrategy().getShardingAlgorithmName(), 
is("standard"));
diff --git 
a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPluginTest.java
 
b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPluginTest.java
index 23d4bf31512..c8471e329b8 100644
--- 
a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPluginTest.java
+++ 
b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPluginTest.java
@@ -46,8 +46,8 @@ import java.util.stream.IntStream;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -253,10 +253,10 @@ class MppdbDecodingPluginTest {
         }
         assertThat(expectedEvent.size(), is(4));
         AbstractWALEvent actualFirstEvent = expectedEvent.get(0);
-        assertTrue(actualFirstEvent instanceof BeginTXEvent);
+        assertInstanceOf(BeginTXEvent.class, actualFirstEvent);
         assertThat(((BeginTXEvent) actualFirstEvent).getXid(), is(1L));
         AbstractWALEvent actualLastEvent = 
expectedEvent.get(expectedEvent.size() - 1);
-        assertTrue(actualLastEvent instanceof CommitTXEvent);
+        assertInstanceOf(CommitTXEvent.class, actualLastEvent);
         assertThat(((CommitTXEvent) actualLastEvent).getCsn(), is(3468L));
         assertThat(((CommitTXEvent) actualLastEvent).getXid(), is(1L));
     }

Reply via email to