package com.elab.spring.intercept;

import com.elab.core.aop.annotations.EnableElabDB;
import com.elab.mq.config.RocketMQConfiguration;
import com.elab.mq.model.MessageModel;
import com.elab.mq.msg.ProducerInterceptor;
import com.elab.spring.config.RmqConfiguration;
import com.elab.spring.dao.IConsumerDao;
import com.elab.spring.dao.IProducerDao;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Module rmq模块测试
 * @Description 测试mysql拦截
 * @Author liukaixiong
 * @Date 2021/1/11 16:33
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {RocketMQConfiguration.class, RmqConfiguration.class})
@EnableElabDB(basePackageClasses = {IConsumerDao.class, IProducerDao.class})
public class RMQMsgTableProducerInterceptorTest extends TestCase {


    @Autowired
    private ProducerInterceptor producerInterceptor;

    @Test
    public void check() {
        sendMsg();
    }

    @Test
    public void success() {
    }

    @Test
    public void error() {
    }

    public MessageModel sendMsg() {
        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
        jsonObject.put("key", "test");
        MessageModel messageModel = new MessageModel("A", "B", "C", jsonObject.toString());
        messageModel.setInvokeTime(1000L);
        producerInterceptor.check(messageModel, "");
        return messageModel;
    }
}