Add unit test cases (#651)

pull/655/head
liulinfei121 2 years ago committed by GitHub
parent 6ec462bf70
commit e0bde2605f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,22 +17,36 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
import org.junit.Test;
public class ContentUtilTest {
@Test
public void assertGetPoolContent() {
String testText = "{\"tenantId\":\"prescription\",\"itemId\":\"dynamic-threadpool-example\",\"tpId\":" +
"\"message-consume\",\"queueType\":1,\"capacity\":4,\"keepAliveTime\":513,\"rejectedType\":4,\"isAlarm\"" +
":1,\"capacityAlarm\":80,\"livenessAlarm\":80,\"allowCoreThreadTimeOut\":1}";
ThreadPoolParameterInfo threadPoolParameterInfo = ThreadPoolParameterInfo.builder().tenantId("prescription")
.itemId("dynamic-threadpool-example").tpId("message-consume").content("描述信息").corePoolSize(1)
.maximumPoolSize(2).queueType(1).capacity(4).keepAliveTime(513).executeTimeOut(null).rejectedType(4)
.isAlarm(1).capacityAlarm(80).livenessAlarm(80).allowCoreThreadTimeOut(1).build();
Assert.isTrue(testText.equals(ContentUtil.getPoolContent(threadPoolParameterInfo)));
}
@Test
public void assertGetGroupKey() {
String testText = "message-consume+dynamic-threadpool-example+prescription";
ThreadPoolParameterInfo parameter = ThreadPoolParameterInfo.builder()
.tenantId("prescription").itemId("dynamic-threadpool-example").tpId("message-consume").build();
Assert.isTrue(testText.equals(ContentUtil.getGroupKey(parameter)));
}
@Test
public void assertGetGroupKeys() {
String testText = "message-consume+dynamic-threadpool-example+prescription";
String groupKey = ContentUtil.getGroupKey("message-consume", "dynamic-threadpool-example", "prescription");
Assert.isTrue(testText.equals(groupKey));
}
}
}
Loading…
Cancel
Save