修复CopyOptions.setIgnoreCase和setIgnoreProperties冲突问题

This commit is contained in:
Looly
2023-09-12 18:28:58 +08:00
parent ead980e246
commit 1deb32aa29
2 changed files with 53 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
package org.dromara.hutool.core.bean;
import lombok.Data;
import org.dromara.hutool.core.bean.copier.CopyOptions;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class IssueI80FP4Test {
@Test
public void copyPropertiesTest() {
final Dest sourceDest = new Dest();
sourceDest.setCPF(33699);
sourceDest.setEnderDest("abc");
final Dest dest = new Dest();
final CopyOptions copyOptions = CopyOptions.of()
.setIgnoreNullValue(true)
.setIgnoreCase(true)
.setIgnoreProperties("enderDest");
BeanUtil.copyProperties(sourceDest, dest, copyOptions);
Assertions.assertNull(dest.getEnderDest());
}
@Test
public void copyPropertiesTest2() {
final Dest sourceDest = new Dest();
sourceDest.setCPF(33699);
sourceDest.setEnderDest("abc");
final Dest dest = new Dest();
final CopyOptions copyOptions = CopyOptions.of()
.setIgnoreNullValue(true)
.setIgnoreCase(true)
.setIgnoreProperties("enderdest");
BeanUtil.copyProperties(sourceDest, dest, copyOptions);
Assertions.assertNull(dest.getEnderDest());
}
@Data
static class Dest{
private int cPF;
private String enderDest;
}
}