This commit is contained in:
Looly 2022-11-08 20:27:24 +08:00
parent a293fd5510
commit dacf9c80bb

View File

@ -8,20 +8,8 @@ import java.util.LinkedHashMap;
public class Issue2718Test { public class Issue2718Test {
@Setter
private static class Deployment{
public String getResources() {
// setIgnoreProperties会被转换为propertiesFilter这个filter是过滤键和值的因此会获取源对象的值调用getXXX方法然后做判断因此此方法会被执行
return resources;
}
private String resources;
}
@Test @Test
public void copyTest(){ public void copyToMapTest(){
final Deployment deployment = new Deployment(); final Deployment deployment = new Deployment();
deployment.setResources("test"); deployment.setResources("test");
final LinkedHashMap<String, Object> target = BeanCopier final LinkedHashMap<String, Object> target = BeanCopier
@ -30,4 +18,26 @@ public class Issue2718Test {
Assert.assertTrue(target.isEmpty()); Assert.assertTrue(target.isEmpty());
} }
@Test
public void copyToBeanTest(){
final Deployment deployment = new Deployment();
deployment.setResources("test");
final Deployment target = BeanCopier
.create(deployment, new Deployment(), CopyOptions.create().setIgnoreProperties("resources"))
.copy();
Assert.assertNull(target.resources);
}
@Setter
private static class Deployment{
public String getResources() {
// setIgnoreProperties会被转换为propertiesFilter这个filter是过滤键和值的因此会获取源对象的值调用getXXX方法然后做判断因此此方法会被执行
throw new RuntimeException("这个方法不应该被调用");
//return resources;
}
private String resources;
}
} }