VehicleServiceTest.java 1.4 KB
package cn.com.glsx.stdinterface.modules.service;

import cn.com.glsx.Application;
import cn.com.glsx.stdinterface.dto.VehicleDto;
import cn.com.glsx.stdinterface.modules.entity.Vehicle;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class VehicleServiceTest {

    @Autowired
    private VehicleService vehicleService;

    @Test
    public void testddd() {
        String sn = "1190909618";
        Vehicle vehicle = vehicleService.getVehicleInfoBySn(sn);
        if (vehicle != null) {
            VehicleDto vehicleDto = new VehicleDto();
            vehicleDto.setId(vehicle.getId());
            vehicleDto.setVin(vehicle.getVin());
            vehicleDto.setCreateBy(vehicle.getCreatedBy());
            vehicleDto.setCreateDate((vehicle.getCreatedDate() != null) ? DateUtil.format(vehicle.getCreatedDate(), "yyyy-MM-dd HH:mm:ss") : "");
            System.out.println("==" + JSONObject.toJSONString(vehicleDto));
        }
        System.out.println("end");
    }

}