package com.elab.spring.intercept;

import com.alibaba.fastjson.JSONObject;
import com.elab.mq.model.MessageModel;
import com.elab.mq.msg.ProducerInterceptor;
import com.elab.redis.annotation.EnableElabRedis;
import com.elab.spring.config.RmqConfiguration;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.redisson.spring.starter.RedissonAutoConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Module TODO
 * @Description TODO
 * @Author liukaixiong
 * @Date 2020/12/31 15:43
 */
@RunWith(SpringRunner.class)
@EnableConfigurationProperties(value = {RedisProperties.class})
@SpringBootTest(classes = {RmqConfiguration.class, RedissonAutoConfiguration.class})
@EnableElabRedis
public class RMQCacheProducerInterceptorTest extends TestCase {

    @Autowired
    private ProducerInterceptor producerInterceptor;

    @Test
    public void check() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("key", "test");
        MessageModel messageModel = new MessageModel("A", "B", "C", jsonObject.toString());
        messageModel.setInvokeTime(1000L);
        boolean check = producerInterceptor.check(messageModel, "");
        System.out.println(check);
    }

    @Test
    public void success() {

    }

    @Test
    public void error() {
    }
}