package service;标签:map,reqMap,user,new,import,赋值 From: https://www.cnblogs.com/zxlk-home/p/18025195
import base.BaseSpringTest;
import com.bestpay.settle.unity.certify.integration.model.CertifyInfoBO;
import lombok.extern.log4j.Log4j2;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* 场景测试类
*
* @author zhangkuankuan
* @version Id: TestScene.java, v 0.1 2024/02/21 16:39 zhangkuankuan Exp $$
*/
@Log4j2
public class TestScene extends BaseSpringTest {
/**
* 对象赋值
*/
public String setObject(User user) {
user.setFacePath("0A02_08/unity-certify_08/20230927/unAB727346a120c3444582c62f5ae32759c938603466.png");
return "赋值成功";
}
/**
* 验证对象赋值和map赋值一样,中间没有重新new对象,值就会一直存在
*/
@Test
public void resultTest() {
User user = new User();
user.setCertificateNo("61048119960223461X");
String s = setObject(user);
System.out.println(s);
System.out.println(user);
}
/**
* requestMap赋值
*/
public void setRequestMap(Map<String, Object> reqMap) {
reqMap.put("channelCode", "101");
reqMap.put("channelClass", "personSimpleToCtidCertifyComponent");
}
/**
* 验证map赋值一样,中间没有重新new集合,值就会一直存在
*/
@Test
public void requestMapTest() {
Map<String, Object> reqMap = new HashMap<>();
reqMap.put("operator", "张三");
setRequestMap(reqMap);
// 遍历打印map的key/value
reqMap.forEach((key, value) -> {
System.out.print(key);
System.out.println(":" + value);
});
}
}