1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| @SpringBootTest class OrikaApplicationTests {
@Test void contextLoads() {
Account account = new Account(); account.setId(1); account.setUsername("zhangsan"); account.setPassword("zhangsan");
Friend friend1 = new Friend(); friend1.setA("a"); friend1.setB("a"); Friend friend2 = new Friend(); friend2.setA("b"); friend2.setB("b"); List<Friend> friendListA = new ArrayList<>(); friendListA.add(friend1); friendListA.add(friend2);
UserA userA = new UserA(); userA.setId(1); userA.setName("张三"); userA.setAge(18); userA.setAccount(account); userA.setFriends(friendListA); userA.setA("A");
UserB userB = new UserB(); List<Friend> friendListB = new ArrayList<>(); Friend friend3 = new Friend(); friend3.setA("c"); friend3.setB("c"); friendListB.add(friend3); userB.setFriends(friendListB);
System.out.println(userA); System.out.println(userB);
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build(); MapperFacade mapper = mapperFactory.getMapperFacade();
mapper.map(userA, userB); System.out.println(userA); System.out.println(userB); }
}
|