Skip to content

Commit

Permalink
test:Test BeanUtil tool (opengoofy#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
theNorthWindBlow authored Oct 10, 2024
1 parent c521a97 commit 0d3740e
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@

public class BeanUtilTest {

@Test
public void beanToBeanConvertTest(){
// Test BeanToAnotherBean
final Person person = new Person();
person.setName("Hippo4j");
person.setAge(1);
person.setAddress("hippo4j.cn");
person.setSize(999);
GoodPerson goodPerson = BeanUtil.convert(person, GoodPerson.class);
Assert.assertSame(goodPerson.getClass(), GoodPerson.class);
Assert.assertEquals("Hippo4j", person.getName());
Assert.assertEquals(1, person.getAge());
Assert.assertEquals("hippo4j.cn", person.getAddress());
Assert.assertEquals(999, person.getSize().intValue());
}

@Test
public void beanToMapConvertTest() {
// 测试BeanToMap
Expand Down Expand Up @@ -171,4 +187,12 @@ static class PreCustomer {
String name;
Integer statusCode;
}

@Getter
@Setter
static class GoodPerson extends Person{

String gender;
String nature;
}
}

0 comments on commit 0d3740e

Please sign in to comment.