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

import cn.axzo.msg.center.MsgCenterApplication;
import cn.axzo.msg.center.service.template.request.MessageTemplateV3SyncRequest;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import static org.junit.jupiter.api.Assertions.*;

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

    private final MessageTemplateV3SyncService messageTemplateV3SyncService;

    @Test
    void exec() {
        String json = "{\"operatorId\":9000404670,\"operatorName\":\"杨林\",\"template\":{\"template\":{\"code\":\"98578da4950740bba02114e47f69ad98\",\"orCreateRecordExt\":{\"isMigrated\":true},\"updatePersonName\":\"system\",\"icon\":\"\",\"updateAt\":1728527876000,\"createPersonId\":0,\"title\":\"发薪逾期整改\",\"pushTerminal\":\"[\\\"B_ENTERPRISE_APP\\\"]\",\"createAt\":1726045715000,\"content\":\"您有一条发薪逾期整改单，请及时处理\",\"imSendPriority\":1000,\"displayOnList\":\"YES\",\"minAppVersion\":\"\",\"id\":968,\"createPersonName\":\"system\",\"msgCategory\":\"APPROVAL_PENDING_MESSAGE\",\"detailStyleCode\":\"FLOW_COMMON\",\"isDelete\":0,\"cardUrlOpenStrategy\":\"OPEN_TODO_DETAIL\",\"recordExt\":{\"isMigrated\":true},\"pushData\":{},\"name\":\"发薪逾期整改\",\"updatePersonId\":0,\"status\":\"ENABLE\"},\"buttons\":[{\"urlConfig\":{\"appManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/agree?processInstanceId=${processInstanceId}&taskId=${taskId}&userAgreeSignature=${userAgreeSignature}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fapprove&workspaceType=2\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/agree?processInstanceId=${processInstanceId}&taskId=${taskId}&userAgreeSignature=${userAgreeSignature}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fapprove&workspaceType=2\"}},\"orCrateAppWorker\":{},\"orCreateAppManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/agree?processInstanceId=${processInstanceId}&taskId=${taskId}&userAgreeSignature=${userAgreeSignature}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fapprove&workspaceType=2\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/agree?processInstanceId=${processInstanceId}&taskId=${taskId}&userAgreeSignature=${userAgreeSignature}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fapprove&workspaceType=2\"}}},\"orCreateRecordExt\":{\"btnCode\":\"BPMN_APPROVE\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"BPMN_APPROVE\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"SYSTEM\",\"priority\":1,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"\",\"name\":\"同意\",\"id\":1596,\"createPersonName\":\"system\",\"category\":\"JUMP\",\"updatePersonId\":0,\"executorShow\":false},{\"urlConfig\":{\"appManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/reject?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Freject&workspaceType=2\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/reject?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Freject&workspaceType=2\"}},\"orCrateAppWorker\":{},\"orCreateAppManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/reject?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Freject&workspaceType=2\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/reject?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Freject&workspaceType=2\"}}},\"orCreateRecordExt\":{\"btnCode\":\"BPMN_REJECT\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"BPMN_REJECT\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"SYSTEM\",\"priority\":2,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"\",\"name\":\"驳回\",\"id\":1597,\"createPersonName\":\"system\",\"category\":\"JUMP\",\"updatePersonId\":0,\"executorShow\":false},{\"orCreateRecordExt\":{\"btnCode\":\"BPMN_REVOCATION\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"BPMN_REVOCATION\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"SYSTEM\",\"priority\":3,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&modalText=%E6%92%A4%E5%9B%9E%E5%90%8E%E6%B5%81%E7%A8%8B%E7%BB%93%E6%9D%9F%EF%BC%8C%E7%A1%AE%E5%AE%9A%E6%92%A4%E5%9B%9E%E5%90%97%EF%BC%9F&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Fprocess%2Fcancel\",\"name\":\"撤回\",\"id\":1598,\"createPersonName\":\"system\",\"category\":\"ACTION\",\"updatePersonId\":0,\"executorShow\":false},{\"urlConfig\":{\"appManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/transfer?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Ftransfer&workspaceType=2\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/transfer?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Ftransfer&workspaceType=2\"}},\"orCrateAppWorker\":{},\"orCreateAppManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/transfer?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Ftransfer&workspaceType=2\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/transfer?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Ftransfer&workspaceType=2\"}}},\"orCreateRecordExt\":{\"btnCode\":\"BPMN_TRANSFER\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"BPMN_TRANSFER\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"SYSTEM\",\"priority\":4,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"\",\"name\":\"转交\",\"id\":1599,\"createPersonName\":\"system\",\"category\":\"JUMP\",\"updatePersonId\":0,\"executorShow\":false},{\"urlConfig\":{\"appManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/endorse?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcountersign&workspaceType=2\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/endorse?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcountersign&workspaceType=2\"}},\"orCrateAppWorker\":{},\"orCreateAppManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/endorse?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcountersign&workspaceType=2\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/endorse?processInstanceId=${processInstanceId}&taskId=${taskId}&workspaceId=${tenantId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcountersign&workspaceType=2\"}}},\"orCreateRecordExt\":{\"btnCode\":\"BPMN_COUNTERSIGN\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"BPMN_COUNTERSIGN\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"SYSTEM\",\"priority\":5,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"\",\"name\":\"加签\",\"id\":1600,\"createPersonName\":\"system\",\"category\":\"JUMP\",\"updatePersonId\":0,\"executorShow\":false},{\"urlConfig\":{\"appManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/discuss?processInstanceId=${processInstanceId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcomment\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/discuss?processInstanceId=${processInstanceId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcomment\"}},\"orCrateAppWorker\":{},\"orCreateAppManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/discuss?processInstanceId=${processInstanceId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcomment\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/discuss?processInstanceId=${processInstanceId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcomment\"}}},\"orCreateRecordExt\":{\"btnCode\":\"BPMN_COMMENT\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"BPMN_COMMENT\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"SYSTEM\",\"priority\":6,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"\",\"name\":\"评论\",\"id\":1601,\"createPersonName\":\"system\",\"category\":\"JUMP\",\"updatePersonId\":0,\"executorShow\":false},{\"urlConfig\":{\"appManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/returned?processInstanceId=${processInstanceId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcomment\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/returned?processInstanceId=${processInstanceId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcomment\"}},\"orCrateAppWorker\":{},\"orCreateAppManager\":{\"android\":{\"url\":\"__UNI__UGA98VS#/pages/approve/returned?processInstanceId=${processInstanceId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcomment\"},\"ios\":{\"url\":\"__UNI__UGA98VS#/pages/approve/returned?processInstanceId=${processInstanceId}&apiPath=%2Fyoke%2FwebApi%2Fprocess%2Finstance%2Fv1%2Ftask%2Fcomment\"}}},\"orCreateRecordExt\":{\"btnCode\":\"BPMN_ROLLBACK\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"BPMN_ROLLBACK\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"SYSTEM\",\"priority\":7,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"\",\"name\":\"回退\",\"id\":1602,\"createPersonName\":\"system\",\"category\":\"JUMP\",\"updatePersonId\":0,\"executorShow\":false},{\"urlConfig\":{\"orCrateAppWorker\":{},\"orCreateAppManager\":{},\"pcCms\":{\"openStrategy\":\"NEW_PAGE\",\"url\":\"/goverToNeed/rectificationTodo/detail?id=${id}&workspaceId=${workspaceId}\"}},\"orCreateRecordExt\":{\"btnCode\":\"70f8b1ba26744d56ad0eee0b56d1ce1d\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"70f8b1ba26744d56ad0eee0b56d1ce1d\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"CUSTOM\",\"priority\":8,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"\",\"name\":\"详情\",\"id\":1603,\"createPersonName\":\"system\",\"category\":\"JUMP\",\"updatePersonId\":0,\"executorShow\":false},{\"urlConfig\":{\"orCrateAppWorker\":{},\"orCreateAppManager\":{},\"pcCms\":{\"openStrategy\":\"NEW_PAGE\",\"url\":\"/warn-manage/rectification-form/rectification-check?id=${id}\"}},\"orCreateRecordExt\":{\"btnCode\":\"64200b607a8a42b0b0fa7cfcb2180e7c\",\"isMigrated\":true},\"updatePersonName\":\"system\",\"isDelete\":0,\"recordExt\":{\"btnCode\":\"64200b607a8a42b0b0fa7cfcb2180e7c\",\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"source\":\"CUSTOM\",\"priority\":9,\"createAt\":1728527876000,\"pendingShow\":false,\"apiUrl\":\"\",\"name\":\"查看详情\",\"id\":1604,\"createPersonName\":\"system\",\"category\":\"JUMP\",\"updatePersonId\":0,\"executorShow\":false}],\"groups\":[{\"groupType\":\"KV_VALUES\",\"orCreateRecordExt\":{\"isMigrated\":true},\"updatePersonName\":\"system\",\"orCreateGroupConfig\":{\"keyValues\":[{\"displayOnCard\":true,\"contentType\":\"TEXT\",\"value\":\"${projectName}\",\"key\":\"工程名称\"},{\"displayOnCard\":true,\"contentType\":\"TEXT\",\"value\":\"${initiateTime}\",\"key\":\"下发时间\"},{\"displayOnCard\":true,\"contentType\":\"TEXT\",\"value\":\"${askRectificationTime}\",\"key\":\"整改期限\"},{\"displayOnCard\":false,\"contentType\":\"TEXT\",\"value\":\"${rectificationReason}\",\"key\":\"下发原因\"},{\"displayOnCard\":false,\"contentType\":\"TEXT\",\"value\":\"${rectificationRequest}\",\"key\":\"整改要求\"}]},\"isDelete\":0,\"recordExt\":{\"isMigrated\":true},\"updateAt\":1728527876000,\"createPersonId\":0,\"templateCode\":\"98578da4950740bba02114e47f69ad98\",\"groupConfig\":{\"keyValues\":[{\"displayOnCard\":true,\"contentType\":\"TEXT\",\"value\":\"${projectName}\",\"key\":\"工程名称\"},{\"displayOnCard\":true,\"contentType\":\"TEXT\",\"value\":\"${initiateTime}\",\"key\":\"下发时间\"},{\"displayOnCard\":true,\"contentType\":\"TEXT\",\"value\":\"${askRectificationTime}\",\"key\":\"整改期限\"},{\"displayOnCard\":false,\"contentType\":\"TEXT\",\"value\":\"${rectificationReason}\",\"key\":\"下发原因\"},{\"displayOnCard\":false,\"contentType\":\"TEXT\",\"value\":\"${rectificationRequest}\",\"key\":\"整改要求\"}]},\"createAt\":1728527876000,\"sortOrder\":1,\"name\":\"基本信息\",\"id\":397,\"createPersonName\":\"system\",\"updatePersonId\":0}]}}";
        MessageTemplateV3SyncRequest request = JSON.parseObject(json, MessageTemplateV3SyncRequest.class);
        messageTemplateV3SyncService.syncTemplate(request);
    }

}