package com.liquidnet.client.admin;

import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.commons.lang.util.CollectionUtil;
import lombok.extern.slf4j.Slf4j;
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.data.redis.connection.stream.StreamRecords;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.HashMap;

/**
 * @author AnJiabin <anjiabin@zhengzai.tv>
 * @version V1.0
 * @Description: TODO
 * @class: TestRedisMultdb
 * @Package com.liquidnet.client.admin
 * @Copyright: LightNet @ Copyright (c) 2021
 * @date 2021/10/22 11:30
 */
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class TestRedisMultdb {
    @Autowired
    private RedisDataSourceUtil redisDataSourceUtil;
    @Test
    public void testRedisTemplate(){
//        redisDataSourceUtil.getRedisKylinUtil().set("redis-test","12345");
//        System.out.println(redisDataSourceUtil.getRedisKylinUtil().get("redis-test"));

//        redisDataSourceUtil.getRedisDragonUtil().set("redis-test2","12345");
//        System.out.println(redisDataSourceUtil.getRedisDragonUtil().get("redis-test2"));

        redisDataSourceUtil.getRedisAdamUtil().set("redis-test3","12345");
        System.out.println(redisDataSourceUtil.getRedisAdamUtil().get("redis-test3"));
    }

    @Test
    public void testStringRedisTemplate(){
        HashMap<String, String> map = CollectionUtil.mapStringString();
        map.put("message", "testAdmin20211022-001");
        log.info("testStringRedisTemplate.stream===",redisDataSourceUtil.getRedisKylinUtil().getStringRedisTemplate().opsForStream().add(StreamRecords.mapBacked(map).withStreamKey("dragon:stream:dragon-pay")));
    }
}
