Merge remote-tracking branch 'origin/develop' into develop

pull/700/head
chen.ma 2 years ago
commit 940f7d145d

@ -36,7 +36,7 @@ Hippo-4J 通过对 JDK 线程池增强,以及扩展三方框架底层线程池
- 功能扩展 - 支持线程池任务传递上下文;项目关闭时,支持等待线程池在指定时间内完成任务。
- 多种模式 - 内置两种使用模式:[依赖配置中心](https://hippo4j.cn/docs/user_docs/getting_started/config/hippo4j-config-start) 和 [无中间件依赖](https://hippo4j.cn/docs/user_docs/getting_started/server/hippo4j-server-start)。
- 容器管理 - Tomcat、Jetty、Undertow 容器线程池运行时查看和线程数变更。
- 中间件适配 - Apache RocketMQ、Dubbo、RabbitMQ、Hystrix 消费线程池运行时数据查看和线程数变更。
- 中间件适配 - Dubbo、Hystrix、RocketMQ、RabbitMQ 等消费线程池运行时数据查看和线程数变更。
> 开源作者为爱发电不容易,看完有收获,右上角帮忙点个小星星 🤩
@ -62,12 +62,6 @@ Hippo-4J 通过对 JDK 线程池增强,以及扩展三方框架底层线程池
- [[ toBeBetterJavaer ]](https://github.com/itwanger/toBeBetterJavaer):一份通俗易懂、风趣幽默的 Java 学习指南。
## 荣誉墙
Hippo-4J 获得了一些宝贵的荣誉,肯定了 Hippo-4J 作为一款开源框架所带来的价值。
<img align="center" width="800" alt="image" src="https://user-images.githubusercontent.com/77398366/187014905-b50bdc8b-ca0e-4137-9a02-1e6b06106191.jpg">
## 开发者
Hippo-4J 获得的成就属于每一位贡献者!如果有意贡献,请参考 [good first issue](https://github.com/opengoofy/hippo4j/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) 或者 [good pro issue](https://github.com/opengoofy/hippo4j/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+pro+issue%22)。
@ -76,8 +70,12 @@ Hippo-4J 获得的成就属于每一位贡献者!如果有意贡献,请参
<img src="https://contrib.rocks/image?repo=opengoofy/hippo4j" />
</a>
## 谁在使用
如果您正在使用这个项目,可以在 [此处](https://github.com/opengoofy/hippo4j/issues/13) 登记您所在的组织或公司,谢谢。
![身边云](https://user-images.githubusercontent.com/77398366/189787832-f51d475c-d758-40f2-9812-997637804e6f.png)
![Medbanks](https://user-images.githubusercontent.com/77398366/189787960-16f89af9-a615-4da3-8309-18d0793aed05.png)
![神州数码](https://user-images.githubusercontent.com/77398366/189786973-1a924f41-1558-4b03-acfd-49f279b99ce7.png)

@ -17,8 +17,119 @@
package cn.hippo4j.config.toolkit;
import cn.hippo4j.common.toolkit.Assert;
import cn.hutool.core.collection.CollectionUtil;
import com.google.common.collect.ImmutableMap;
import org.junit.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
/**
* MapUtil Test
*/
public class MapUtilTest {
@Test
public void parseMapForFilterRetIsEmptyTest() {
Map<String, Object> map = ImmutableMap.of("abc", "123", "bcd", "456", "cde", "789");
List<String> ret = MapUtil.parseMapForFilter(map, "x");
Assert.isTrue(CollectionUtil.isEmpty(ret));
}
@Test
public void parseMapForFilterRetIsNotEmptyTest() {
Map<String, Object> map = ImmutableMap.of("abc", "123", "bcd", "456", "cde", "789");
List<String> ret = MapUtil.parseMapForFilter(map, "b");
Assert.isTrue(CollectionUtil.isNotEmpty(ret));
}
@Test
public void computeIfAbsentNotExistTargetTest() {
BiFunction<String, String, String> mappingFunction = (a, b) -> a + b;
try {
MapUtil.computeIfAbsent(null, "key", mappingFunction, "param1", "param2");
} catch (Exception e) {
if (e instanceof NullPointerException) {
Assert.isTrue(Objects.equals("target", e.getMessage()));
}
}
}
@Test
public void computeIfAbsentNotExistKeyTest() {
Map<Object, Object> map = new HashMap<>();
map.put("abc", "123");
BiFunction<String, String, String> mappingFunction = (a, b) -> a + b;
try {
MapUtil.computeIfAbsent(map, null, mappingFunction, "param1", "param2");
} catch (Exception e) {
if (e instanceof NullPointerException) {
Assert.isTrue(Objects.equals("key", e.getMessage()));
}
}
}
@Test
public void computeIfAbsentNotExistMappingFunctionTest() {
Map<Object, Object> map = new HashMap<>();
map.put("abc", "123");
try {
MapUtil.computeIfAbsent(map, "abc", null, "param1", "param2");
} catch (Exception e) {
if (e instanceof NullPointerException) {
Assert.isTrue(Objects.equals("mappingFunction", e.getMessage()));
}
}
}
@Test
public void computeIfAbsentNotExistParam1Test() {
Map<Object, Object> map = new HashMap<>();
map.put("abc", "123");
BiFunction<String, String, String> mappingFunction = (a, b) -> a + b;
try {
MapUtil.computeIfAbsent(map, "abc", mappingFunction, null, "param2");
} catch (Exception e) {
if (e instanceof NullPointerException) {
Assert.isTrue(Objects.equals("param1", e.getMessage()));
}
}
}
@Test
public void computeIfAbsentNotExistParam2Test() {
Map<Object, Object> map = new HashMap<>();
map.put("abc", "123");
BiFunction<String, String, String> mappingFunction = (a, b) -> a + b;
try {
MapUtil.computeIfAbsent(map, "abc", mappingFunction, "param1", null);
} catch (Exception e) {
if (e instanceof NullPointerException) {
Assert.isTrue(Objects.equals("param2", e.getMessage()));
}
}
}
@Test
public void computeIfAbsentValNotNullTest() {
Map<Object, Object> map = new HashMap<>();
map.put("abc", "123");
BiFunction<String, String, String> mappingFunction = (a, b) -> a + b;
Object ret = MapUtil.computeIfAbsent(map, "abc", mappingFunction, "param1", "param2");
Assert.isTrue(Objects.equals("123", String.valueOf(ret)));
}
@Test
public void computeIfAbsentValIsNullTest() {
Map<Object, Object> map = new HashMap<>();
map.put("abc", "123");
BiFunction<String, String, String> mappingFunction = (a, b) -> a + b;
Object ret = MapUtil.computeIfAbsent(map, "xyz", mappingFunction, "param1", "param2");
Assert.isTrue(Objects.equals("param1param2", String.valueOf(ret)));
}
}

Loading…
Cancel
Save