CarDataServiceTest.java 1.04 KB
package com.bs.cardata.service;

import com.bs.cardata.dto.CarBrandHierarchyDto;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.List;

@Slf4j
@SpringBootTest(properties = "spring.application.name=bs-car-data")
@ActiveProfiles("local")//测试环境
public class CarDataServiceTest {

    @Autowired
    private CarDataService carDataService;

    @Autowired
    private CarbrandService carbrandService;

    @Test
    public void testSyncCarInfo() {
        String baseUrl = "https://www.autohome.com.cn/web-main/car/web/price/treeMenu?extendseries=1";
        carDataService.syncCarInfo(baseUrl);
    }

    @Test
    public void testGetCarBrandHierarchyData() {
        List<CarBrandHierarchyDto> allBrandHierarchyData = carbrandService.getAllBrandHierarchyData();
        log.info("allBrandHierarchyData:{}", allBrandHierarchyData);
    }
}