Helius
2020-05-13 d0de0bf06f69c8584330e857ec1ecce34b244c9f
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.xcong.excoin.mapper;
 
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * @author wzy
 * @date 2020-05-05 10:59
 **/
@Slf4j
@SpringBootTest
public class MapStructMapper {
 
 
    @Test
    public void mapperConvert() {
        Car car = new Car();
        car.setColor("123");
        car.setName("321");
        car.setCreateTime(new Date());
        CarDto carDto = CarMapper.INSTANCE.carToCarDto(car);
        log.info(carDto.toString());
    }
 
    @Test
    public void carDtoToCarConvert() {
        CarDto carDto = new CarDto();
        carDto.setName("dddd");
        carDto.setColor("aaaa");
        carDto.setCreateTime("2020-12-12 12:22:22");
        Car car = CarMapper.INSTANCE.carDtoToCar(carDto);
        log.info(car.toString());
    }
 
    @Test
    public void carToCarEntity() {
        Car car = new Car();
        car.setName("123");
        car.setColor("33333");
        car.setCreateTime(new Date());
        CarEntity carEntity = CarMapper.INSTANCE.carToCarEntity(car);
        log.info(carEntity.toString());
    }
 
    @Test
    public void carEntityToCar() {
        CarEntity carEntity = new CarEntity();
        carEntity.setUserName("11111");
        carEntity.setUserColor("33333");
        carEntity.setTime("2020-12-12 12:22:22");
        Car car = CarMapper.INSTANCE.carEntityToCar(carEntity);
        log.info(car.toString());
    }
 
    @Test
    public void carEntityListToCarList() {
        List<CarEntity> list = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            CarEntity carEntity = new CarEntity();
            carEntity.setTime("2020-12-12 12:22:33");
            carEntity.setUserName("zs" + i);
            carEntity.setUserColor("red" + i);
            list.add(carEntity);
        }
        List<Car> cars = CarMapper.INSTANCE.carsToCarEntities(list);
        log.info(cars.toString());
    }
 
    @Test
    public void carToCarEntityList() {
        List<Car> list = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            Car car = new Car();
            car.setName("zs"+i);
            car.setColor("black" + i);
            car.setCreateTime(new Date());
            list.add(car);
        }
 
        List<CarEntity> entities = CarMapper.INSTANCE.carEntitiesToCarList(list);
        log.info(entities.toString());
    }
 
}