mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-15 02:31:53 +08:00
快递客户端 review 修改
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.impl;
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressQueryProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressQueryReqDTO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -21,36 +21,36 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = Kd100ExpressQueryProviderTest.Application.class)
|
||||
@ActiveProfiles("trade-delivery-query") // 设置使用 trade-delivery-query 配置文件
|
||||
public class Kd100ExpressQueryProviderTest {
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = Kd100ExpressClientTest.Application.class)
|
||||
@ActiveProfiles("unit-test") // 设置使用 trade-delivery-query 配置文件
|
||||
public class Kd100ExpressClientTest {
|
||||
@Resource
|
||||
private RestTemplateBuilder builder;
|
||||
@Resource
|
||||
private TradeExpressQueryProperties expressQueryProperties;
|
||||
private TradeExpressProperties expressQueryProperties;
|
||||
|
||||
private Kd100ExpressQueryProvider kd100ExpressQueryProvider;
|
||||
private Kd100ExpressClient kd100ExpressClient;
|
||||
|
||||
@BeforeEach
|
||||
public void init(){
|
||||
kd100ExpressQueryProvider = new Kd100ExpressQueryProvider(builder.build(),expressQueryProperties.getKd100());
|
||||
kd100ExpressClient = new Kd100ExpressClient(builder.build(),expressQueryProperties.getKd100());
|
||||
}
|
||||
@Test
|
||||
@Disabled("需要 授权 key. 暂时忽略")
|
||||
void testRealTimeQueryExpressFailed() {
|
||||
ServiceException t = assertThrows(ServiceException.class, () -> {
|
||||
ExpressQueryReqDTO reqDTO = new ExpressQueryReqDTO();
|
||||
reqDTO.setExpressCompanyCode("yto");
|
||||
reqDTO.setExpressCode("yto");
|
||||
reqDTO.setLogisticsNo("YT9383342193097");
|
||||
kd100ExpressQueryProvider.realTimeQueryExpress(reqDTO);
|
||||
kd100ExpressClient.getExpressTrackList(reqDTO);
|
||||
});
|
||||
assertEquals(1011003007, t.getCode());
|
||||
assertEquals(1011003005, t.getCode());
|
||||
}
|
||||
|
||||
@Import({
|
||||
RestTemplateAutoConfiguration.class
|
||||
})
|
||||
@EnableConfigurationProperties(TradeExpressQueryProperties.class)
|
||||
@EnableConfigurationProperties(TradeExpressProperties.class)
|
||||
public static class Application {
|
||||
}
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.impl;
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressQueryProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressQueryReqDTO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -21,35 +21,35 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = KdNiaoExpressQueryProviderTest.Application.class)
|
||||
@ActiveProfiles("trade-delivery-query") // 设置使用 trade-delivery-query 配置文件 TODO @jason:可以直接写到 application-unit-test.yaml 配置文件里
|
||||
public class KdNiaoExpressQueryProviderTest {
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = KdNiaoExpressClientTest.Application.class)
|
||||
@ActiveProfiles("unit-test")
|
||||
public class KdNiaoExpressClientTest {
|
||||
@Resource
|
||||
private RestTemplateBuilder builder;
|
||||
@Resource
|
||||
private TradeExpressQueryProperties expressQueryProperties;
|
||||
private TradeExpressProperties expressQueryProperties;
|
||||
|
||||
private KdNiaoExpressQueryProvider kdNiaoExpressQueryProvider;
|
||||
private KdNiaoExpressClient kdNiaoExpressClient;
|
||||
|
||||
@BeforeEach
|
||||
public void init(){
|
||||
kdNiaoExpressQueryProvider = new KdNiaoExpressQueryProvider(builder.build(),expressQueryProperties.getKdNiao());
|
||||
kdNiaoExpressClient = new KdNiaoExpressClient(builder.build(),expressQueryProperties.getKdNiao());
|
||||
}
|
||||
@Test
|
||||
@Disabled("需要 授权 key. 暂时忽略")
|
||||
void testRealTimeQueryExpressFailed() {
|
||||
assertThrows(ServiceException.class,() ->{
|
||||
ExpressQueryReqDTO reqDTO = new ExpressQueryReqDTO();
|
||||
reqDTO.setExpressCompanyCode("yy");
|
||||
reqDTO.setExpressCode("yy");
|
||||
reqDTO.setLogisticsNo("YT9383342193097");
|
||||
kdNiaoExpressQueryProvider.realTimeQueryExpress(reqDTO);
|
||||
kdNiaoExpressClient.getExpressTrackList(reqDTO);
|
||||
});
|
||||
}
|
||||
|
||||
@Import({
|
||||
RestTemplateAutoConfiguration.class
|
||||
})
|
||||
@EnableConfigurationProperties(TradeExpressQueryProperties.class)
|
||||
@EnableConfigurationProperties(TradeExpressProperties.class)
|
||||
public static class Application {
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.ExpressClientConfig;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = NoProvideExpressClientTest.Application.class)
|
||||
@ActiveProfiles("unit-test") // 设置使用 trade-delivery-query 配置文件
|
||||
@Import({ExpressClientConfig.class})
|
||||
public class NoProvideExpressClientTest {
|
||||
|
||||
@Resource
|
||||
private ExpressClient expressClient;
|
||||
|
||||
@Test
|
||||
void getExpressTrackList() {
|
||||
ServiceException t = assertThrows(ServiceException.class, () -> {
|
||||
expressClient.getExpressTrackList(null);
|
||||
});
|
||||
assertEquals(1011003006, t.getCode());
|
||||
}
|
||||
|
||||
@Import({
|
||||
RestTemplateAutoConfiguration.class,
|
||||
})
|
||||
@EnableConfigurationProperties(TradeExpressProperties.class)
|
||||
public static class Application {
|
||||
|
||||
@Bean
|
||||
private RestTemplate restTemplate(RestTemplateBuilder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
spring:
|
||||
main:
|
||||
lazy-initialization: true # 开启懒加载,加快速度
|
||||
banner-mode: off # 单元测试,禁用 Banner
|
||||
|
||||
--- #################### 交易快递查询相关配置 ####################
|
||||
|
||||
yudao:
|
||||
trade:
|
||||
express:
|
||||
query:
|
||||
express-query-provider: kd_niao
|
||||
kd-niao:
|
||||
api-key: xxx
|
||||
business-id: xxxxxxxx
|
||||
kd100:
|
||||
customer: xxxx
|
||||
key: xxxxx
|
@@ -51,3 +51,11 @@ yudao:
|
||||
order:
|
||||
app-id: 1
|
||||
merchant-order-id: 1
|
||||
express:
|
||||
kd-niao:
|
||||
api-key: xxxx
|
||||
business-id: xxxxx
|
||||
kd100:
|
||||
customer: xxxxx
|
||||
key: xxxxx
|
||||
client: not_provide
|
Reference in New Issue
Block a user