package cn.axzo.msg.center.message.service.card;

import cn.axzo.msg.center.MsgCenterApplication;
import cn.axzo.msg.center.common.utils.BizAssertions;
import cn.axzo.msg.center.dal.CardDao;
import cn.axzo.msg.center.domain.entity.Card;
import cn.axzo.msg.center.message.domain.dto.TemplateModelV3;
import lombok.RequiredArgsConstructor;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Collections;

/**
 * @author yanglin
 */
@SpringBootTest(classes = MsgCenterApplication.class)
@RequiredArgsConstructor(onConstructor_ = @Autowired)
class CardManagerTest {

    private final CardManager cardManager;
    private final CardSupport cardSupport;
    private final CardDao cardDao;

    @Test
    void rebuildCardContent() {
        TemplateModelV3 templateModel = cardSupport.ensureImChannelPresent("8733f93de8db49699a78eda5a342763c");
        Card card = cardDao.findCardByBizMessageId("c0d696b2178f442f9488cfc74c518042").orElse(null);
        BizAssertions.assertNotNull(card, "card not found");
        cardManager.rebuildCardContent(templateModel, Collections.singletonList(card));
    }

}