package com.inspur.customer; import com.inspur.customer.object.inform.CommonMessageCO; import com.inspur.customer.service.inform.handler.EmailMessageHandler; import com.inspur.customer.service.inform.handler.WeChatAppletMessageHandler; import com.inspur.customer.service.inform.handler.WeChatMessageHandler; import com.inspur.inform.object.applet.WeChatAppletUserDataDto; import com.inspur.inform.object.applet.message.WxAppletUserMessageDto; import com.inspur.inform.object.message.EmailMessage; import com.inspur.inform.object.message.WechatMessage; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.BitSet; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * @author linwenhua * @date 2022-07-01 13:56 **/ @Slf4j class MessageHandlerTest { private final EmailMessageHandler emailMessageHandler = new EmailMessageHandler(); private final WeChatAppletMessageHandler weChatAppletMessageHandler = new WeChatAppletMessageHandler(); private final WeChatMessageHandler weChatMessageHandler = new WeChatMessageHandler(); @Test void testEmail() throws IOException { CommonMessageCO commonMessageCo = new CommonMessageCO(); commonMessageCo.setSubject("测试"); Map attributes = new HashMap<>(10); attributes.put("MSRlevel", "紧急"); attributes.put("MSRdevice", "紧急"); attributes.put("MSRarea", "紧急"); attributes.put("MSRtime", "紧急"); commonMessageCo.setMessageMap(attributes); EmailMessage emailMessage = emailMessageHandler.makeEmailMessage(commonMessageCo, "BatchDeviceEmptyOrchestration", Collections.emptyList()); log.info("message: {}", emailMessage); } @Test void testApplet() throws IOException { CommonMessageCO commonMessageCo = new CommonMessageCO(); commonMessageCo.setSubject("测试"); Map attributes = new HashMap<>(10); attributes.put("MSRlevel", "紧急"); attributes.put("MSRdevice", "紧急"); attributes.put("MSRarea", "紧急"); attributes.put("MSRtime", "紧急"); commonMessageCo.setMessageMap(attributes); WxAppletUserMessageDto wxAppletUserMessageDto = weChatAppletMessageHandler.makeWeChatAppletMessage(commonMessageCo, "MultiWarn"); log.info("message: {}", wxAppletUserMessageDto); } @Test void testWeChat() throws IOException { CommonMessageCO commonMessageCo = new CommonMessageCO(); commonMessageCo.setSubject("测试"); Map attributes = new HashMap<>(10); attributes.put("keyword1", "紧急"); attributes.put("keyword3", "紧急"); commonMessageCo.setMessageMap(attributes); WechatMessage wechatMessage = weChatMessageHandler.makeWeChatMessage(commonMessageCo, Collections.emptyList(), "device"); log.info("message: {}", wechatMessage); } @Test void testBitset() { BitSet bitSet = new BitSet(4); bitSet.set(2); log.info("size: {}", bitSet.length()); } }