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

import cn.axzo.msg.center.MsgCenterApplication;
import cn.axzo.msg.center.api.MessageAPIV3;
import cn.axzo.msg.center.api.request.v3.MessageSendReqV3;
import cn.axzo.msg.center.api.request.v3.PendingSendInfo;
import cn.axzo.msg.center.api.response.v3.MessageSendRespV3;
import cn.axzo.msg.center.service.dto.PersonV3DTO;
import cn.axzo.msg.center.service.enums.TodoType;
import cn.axzo.msg.center.service.pending.client.PendingMessageClient;
import cn.azxo.framework.common.model.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Commit;

import java.util.Arrays;

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

    private final PendingMessageClient pendingMessageClient;
    private final MessageAPIV3 messageAPIV3;

    @Test @Commit
    void sendTodoViaEventMapping() {
        MessageSendReqV3 req = new MessageSendReqV3();
        req.setBizEventMappingCode("test_send_to_via_mapping");
        req.setSender(new PersonV3DTO(1L));
        req.setReceivers(Arrays.asList(new PersonV3DTO(2L), new PersonV3DTO(3L)));
        req.setBizCode("3333");
        req.setSenderOuId(1L);
        req.setReceiversOuId(2L);
        PendingSendInfo pendingInfo = new PendingSendInfo();
        pendingInfo.setTodoType(TodoType.COPIED_TO_ME);
        //req.addChannelParam(MessageSendReqV3.CHANNEL_PENDING, pendingInfo);
        CommonResponse<MessageSendRespV3> resp = messageAPIV3.send(req);
        System.out.println(resp.getData());
    }

}