package com.ruoyi; import com.alibaba.fastjson2.JSONObject; import com.gkhy.exam.institutionalaccess.model.req.ThCertReqDTO; import com.gkhy.exam.institutionalaccess.service.TripartiteInterfaceService; import com.ruoyi.common.core.domain.model.InstitutionUser; import com.ruoyi.common.signature.AESUtils; import com.ruoyi.framework.security.context.ThreeInContextHolder; 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.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import java.time.LocalDateTime; import java.util.*; @RunWith(SpringRunner.class) @SpringBootTest(classes = RuoYiApplication.class) @ActiveProfiles("dev") @Slf4j public class CertTest { @Autowired private TripartiteInterfaceService tripartiteInterfaceService; @Test public void testCertInsert() throws Exception { ThreeInContextHolder.setContext(new InstitutionUser().setId(1L).setInstitutionalName("test")); ListthCertDTOs=new ArrayList<>(); ThCertReqDTO thCertDTO = new ThCertReqDTO(); thCertDTO.setUuid(UUID.randomUUID().toString()); thCertDTO.setName("王五"); thCertDTO.setIdcard("123456789012345679"); thCertDTO.setBatchUuid("1ef0b81f-dcb7-62a9-ad8f-63e252089bc8"); thCertDTO.setTrainOrgName("1234567890123"); thCertDTO.setCertTime(LocalDateTime.now()); thCertDTO.setCertUrl("https://p26.toutiaoimg.com/origin/tos-cn-i-qvj2lq49k0/22f10850c5234b5285350743cfa16357"); thCertDTOs.add(thCertDTO); String jsonString = JSONObject.toJSONString(thCertDTOs); JSONObject object=new JSONObject(); object.put("data", AESUtils.encrypt(jsonString)); tripartiteInterfaceService.receiveCerts(object); } }