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

xingfudeshi pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new 9e78cddad0 test: enhance test coverage of seata common (#6430)
9e78cddad0 is described below

commit 9e78cddad0a6f674ea25985d6f09b604f4ffe0a3
Author: MikhailNavitski <[email protected]>
AuthorDate: Wed Mar 20 04:55:34 2024 +0100

    test: enhance test coverage of seata common (#6430)
---
 changes/en-us/2.x.md                               |  2 ++
 changes/zh-cn/2.x.md                               |  2 ++
 .../exception/RepeatRegistrationExceptionTest.java | 41 ++++++++++++++++++++++
 .../SkipCallbackWrapperExceptionTest.java          | 40 +++++++++++++++++++++
 .../apache/seata/common/util/LambdaUtilsTest.java  | 36 +++++++++++++++++++
 5 files changed, 121 insertions(+)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 60602ebc53..0f6dd5d4c0 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -134,6 +134,7 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#6157](https://github.com/apache/incubator-seata/pull/6157)] increase 
common module unit test coverage
 - [[#6250](https://github.com/apache/incubator-seata/pull/6250)] increase 
seata-core module unit test coverage
 - [[#6325](https://github.com/apache/incubator-seata/pull/6325)] fix 
mockServerTest fail cause using same port with seata-server
+- [[#6430](https://github.com/apache/incubator-seata/pull/6430)] increase 
common module unit test coverage
 
 ### refactor:
 - [[#6280](https://github.com/apache/incubator-seata/pull/6280)] refactor Saga 
designer using diagram-js
@@ -166,5 +167,6 @@ Thanks to these contributors for their code commits. Please 
report an unintended
 - [gggyd123](https://github.com/gggyd123)
 - [jonasHanhan](https://github.com/jonasHanhan)
 - [Code-breaker1998](https://github.com/Code-breaker1998)
+- [MikhailNavitski](https://github.com/MikhailNavitski)
 
 Also, we receive many valuable issues, questions and advices from our 
community. Thanks for you all.
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 0720041568..d20f9babe2 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -136,6 +136,7 @@
 - [[#6157](https://github.com/apache/incubator-seata/pull/6157)] 
增加common模块单测覆盖率
 - [[#6250](https://github.com/apache/incubator-seata/pull/6250)] 
增加seata-core模块单测覆盖率
 - [[#6325](https://github.com/apache/incubator-seata/pull/6325)] 
修复mock-server相关测试用例
+- [[#6430](https://github.com/apache/incubator-seata/pull/6430)] 增加 common 
模块单元测试覆盖率
 
 ### refactor:
 - [[#6280](https://github.com/apache/incubator-seata/pull/6280)] 
使用diagram-js重构Saga设计器
@@ -168,5 +169,6 @@
 - [gggyd123](https://github.com/gggyd123)
 - [jonasHanhan](https://github.com/jonasHanhan)
 - [Code-breaker1998](https://github.com/Code-breaker1998)
+- [MikhailNavitski](https://github.com/MikhailNavitski)
 
 同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
diff --git 
a/common/src/test/java/org/apache/seata/common/exception/RepeatRegistrationExceptionTest.java
 
b/common/src/test/java/org/apache/seata/common/exception/RepeatRegistrationExceptionTest.java
new file mode 100644
index 0000000000..9c56c33804
--- /dev/null
+++ 
b/common/src/test/java/org/apache/seata/common/exception/RepeatRegistrationExceptionTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.seata.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
+
+
+class RepeatRegistrationExceptionTest {
+
+    @Test
+    void testRepeatRegistrationException() {
+        assertAll(
+                () -> assertThrowsExactly(RepeatRegistrationException.class, 
() -> {
+                    throw new RepeatRegistrationException("error");
+                }),
+                () -> assertThrowsExactly(RepeatRegistrationException.class, 
() -> {
+                    throw new RepeatRegistrationException("error", new 
Throwable("error"));
+                }),
+                () -> assertThrowsExactly(RepeatRegistrationException.class, 
() -> {
+                    throw new RepeatRegistrationException(new 
Throwable("error"));
+                })
+        );
+    }
+}
\ No newline at end of file
diff --git 
a/common/src/test/java/org/apache/seata/common/exception/SkipCallbackWrapperExceptionTest.java
 
b/common/src/test/java/org/apache/seata/common/exception/SkipCallbackWrapperExceptionTest.java
new file mode 100644
index 0000000000..f51a0bce8b
--- /dev/null
+++ 
b/common/src/test/java/org/apache/seata/common/exception/SkipCallbackWrapperExceptionTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.seata.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
+
+class SkipCallbackWrapperExceptionTest {
+
+    @Test
+    void testSkipCallbackWrapperException() {
+        assertThrowsExactly(SkipCallbackWrapperException.class, () -> {
+            throw new SkipCallbackWrapperException(new Throwable("error"));
+        });
+
+    }
+
+    @Test
+    void testFillInStackTrace() {
+        SkipCallbackWrapperException skipCallbackWrapperException = new 
SkipCallbackWrapperException(new Throwable("error"));
+        assertNull(skipCallbackWrapperException.fillInStackTrace());
+
+    }
+}
\ No newline at end of file
diff --git 
a/common/src/test/java/org/apache/seata/common/util/LambdaUtilsTest.java 
b/common/src/test/java/org/apache/seata/common/util/LambdaUtilsTest.java
new file mode 100644
index 0000000000..ccb7979be4
--- /dev/null
+++ b/common/src/test/java/org/apache/seata/common/util/LambdaUtilsTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.seata.common.util;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class LambdaUtilsTest {
+
+    @Test
+    void shouldReturnTrueForDistinctKeys() {
+        Function<Object, Object> keyExtractor = Object::getClass;
+        Predicate<Object> distinctByKey = 
LambdaUtils.distinctByKey(keyExtractor);
+
+        boolean result = distinctByKey.test(new Object());
+        assertTrue(result);
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to