package org.dromara.test;

import org.dromara.DromaraApplication;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.elevator.domain.message.DevFaultReq;
import org.dromara.elevator.domain.message.ReqMsg;
import org.dromara.elevator.service.message.FaultService;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * Kafka单元测试
 *
 * @author ym
 * @version 1.0.0
 * @date 2024-08-23 18:33
 */
@SpringBootTest(classes = {DromaraApplication.class})
@DisplayName("KafkaProducer单元测试案例")
public class KafkaProducerTest {

    @Autowired
    private FaultService faultService;

    @Test
    @DisplayName("测试故障消息推送")
    public void testFaultMsg() {
        DevFaultReq req = new DevFaultReq();
        ReqMsg<DevFaultReq.DevFaultInfo> msg = new ReqMsg<>();
        msg.setId(11111L);
        msg.setSendTime(DateUtils.getTime());
        msg.setType(1);
        msg.setTitle("测试故障消息");
        DevFaultReq.DevFaultInfo faultInfo = new DevFaultReq.DevFaultInfo();
        faultInfo.setFaultCode("test_fault_code");
        faultInfo.setFaultName("test_fault_name");
        faultInfo.setFloor("3F");
        faultInfo.setCode("dev_code_123");
        faultInfo.setType(1);
        faultInfo.setPhoto("photo");
        faultInfo.setResource(1);
        faultInfo.setCreateTime(DateUtils.getTime());
        faultInfo.setElevatorCode("test_elevator_code");
        msg.setObj(faultInfo);
        req.setMsg(msg);
        req.setSecretkey("123456");
        faultService.pushDevFault(req);
    }

}
