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

zhangliang 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 0c783e4e4b3 YamlShardingAuditStrategyConfigurationSwapperTest UTs 
(#30931)
0c783e4e4b3 is described below

commit 0c783e4e4b35597138d610821f551d70b58bf1fa
Author: shubham-j-sde <[email protected]>
AuthorDate: Sat Apr 20 18:16:50 2024 +0530

    YamlShardingAuditStrategyConfigurationSwapperTest UTs (#30931)
    
    Co-authored-by: Shubham Jaiswal <[email protected]>
---
 ...rdingAuditStrategyConfigurationSwapperTest.java | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingAuditStrategyConfigurationSwapperTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingAuditStrategyConfigurationSwapperTest.java
new file mode 100644
index 00000000000..5f9c11b377f
--- /dev/null
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingAuditStrategyConfigurationSwapperTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sharding.yaml.swapper.strategy;
+
+import 
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
+import 
org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+class YamlShardingAuditStrategyConfigurationSwapperTest {
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        ShardingAuditStrategyConfiguration data = new 
ShardingAuditStrategyConfiguration(Collections.singletonList("audit_algorithm"),
 false);
+        YamlShardingAuditStrategyConfigurationSwapper swapper = new 
YamlShardingAuditStrategyConfigurationSwapper();
+        YamlShardingAuditStrategyConfiguration actual = 
swapper.swapToYamlConfiguration(data);
+        assertThat(actual.getAuditorNames(), 
is(Collections.singletonList("audit_algorithm")));
+        assertFalse(actual.isAllowHintDisable());
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        YamlShardingAuditStrategyConfiguration yamlConfig = new 
YamlShardingAuditStrategyConfiguration();
+        
yamlConfig.setAuditorNames(Collections.singletonList("audit_algorithm"));
+        yamlConfig.setAllowHintDisable(false);
+        YamlShardingAuditStrategyConfigurationSwapper swapper = new 
YamlShardingAuditStrategyConfigurationSwapper();
+        ShardingAuditStrategyConfiguration actual = 
swapper.swapToObject(yamlConfig);
+        assertThat(actual.getAuditorNames(), 
is(Collections.singletonList("audit_algorithm")));
+        assertFalse(actual.isAllowHintDisable());
+    }
+}

Reply via email to