mirror of https://github.com/longtai-cn/hippo4j
Add test case for MessageWrapper (#1346)
* Create ThreadFactoryBuilderTest * Update ThreadFactoryBuilderTest Methods are covered by multiple unit test cases . Console printing in English * Update ThreadFactoryBuilderTest Add open source protocol. use @before annotation * Update ThreadFactoryBuilderTest * Update ThreadFactoryBuilderTest * Update ThreadFactoryBuilderTest * Add test case for MessageWrapper * Update MessageWrapperTestpull/1354/head
parent
13f35ad745
commit
1ca11dca09
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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 cn.hippo4j.common.monitor;
|
||||
|
||||
import cn.hippo4j.common.monitor.MessageTypeEnum;
|
||||
import cn.hippo4j.common.monitor.MessageWrapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
public class MessageWrapperTest {
|
||||
|
||||
private static List<Map<String, Object>> contentParams;
|
||||
private static Class responseClass;
|
||||
private static MessageTypeEnum messageType;
|
||||
private static MessageWrapper messageWrapper;
|
||||
|
||||
@BeforeAll
|
||||
static void setUp() {
|
||||
// init data
|
||||
Map<String, Object> data1 = new HashMap<>();
|
||||
data1.put("key1", "value1");
|
||||
data1.put("key2", 123);
|
||||
Map<String, Object> data2 = new HashMap<>();
|
||||
data2.put("key3", true);
|
||||
data2.put("key4", 3.14);
|
||||
contentParams = Arrays.asList(data1, data2);
|
||||
responseClass = String.class;
|
||||
messageType = MessageTypeEnum.DEFAULT;
|
||||
messageWrapper = new MessageWrapper(contentParams, responseClass, messageType);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetContentParams() {
|
||||
Assert.assertEquals(contentParams, messageWrapper.getContentParams());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetResponseClass() {
|
||||
Assert.assertEquals(responseClass, messageWrapper.getResponseClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetMessageType() {
|
||||
Assert.assertEquals(messageType, messageWrapper.getMessageType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSettersAndGetters() {
|
||||
List<Map<String, Object>> newContentParams = Collections.singletonList(Collections.emptyMap());
|
||||
Class newResponseClass = Integer.class;
|
||||
MessageTypeEnum newMessageType = MessageTypeEnum.DEFAULT;
|
||||
messageWrapper.setContentParams(newContentParams);
|
||||
messageWrapper.setResponseClass(newResponseClass);
|
||||
messageWrapper.setMessageType(newMessageType);
|
||||
Assert.assertEquals(newContentParams, messageWrapper.getContentParams());
|
||||
Assert.assertEquals(newResponseClass, messageWrapper.getResponseClass());
|
||||
Assert.assertEquals(newMessageType, messageWrapper.getMessageType());
|
||||
}
|
||||
}
|
Loading…
Reference in new issue