mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-15 02:31:53 +08:00
订单:
1. 增加查询物流接口
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100.Kd100ExpressClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link Kd100ExpressClient} 的集成测试
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Slf4j
|
||||
public class Kd100ExpressClientIntegrationTest {
|
||||
|
||||
private Kd100ExpressClient client;
|
||||
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
||||
TradeExpressProperties.Kd100Config config = new TradeExpressProperties.Kd100Config()
|
||||
.setKey("pLXUGAwK5305")
|
||||
.setCustomer("E77DF18BE109F454A5CD319E44BF5177");
|
||||
client = new Kd100ExpressClient(restTemplate, config);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("集成测试,暂时忽略")
|
||||
public void testGetExpressTrackList() {
|
||||
ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO();
|
||||
reqDTO.setExpressCode("STO");
|
||||
reqDTO.setLogisticsNo("773220402764314");
|
||||
List<ExpressTrackRespDTO> tracks = client.getExpressTrackList(reqDTO);
|
||||
System.out.println(JsonUtils.toJsonPrettyString(tracks));
|
||||
}
|
||||
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
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.TradeExpressProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100.Kd100ExpressClient;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
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.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
// TODO @jason:可以参考 AliyunSmsClientTest 写,纯 mockito,无需启动 spring 容器
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = Kd100ExpressClientTest.Application.class)
|
||||
@ActiveProfiles("unit-test") // 设置使用 trade-delivery-query 配置文件
|
||||
public class Kd100ExpressClientTest {
|
||||
|
||||
@Resource
|
||||
private RestTemplateBuilder builder;
|
||||
@Resource
|
||||
private TradeExpressProperties expressQueryProperties;
|
||||
|
||||
private Kd100ExpressClient kd100ExpressClient;
|
||||
|
||||
@BeforeEach
|
||||
public void init(){
|
||||
kd100ExpressClient = new Kd100ExpressClient(builder.build(),expressQueryProperties.getKd100());
|
||||
}
|
||||
@Test
|
||||
@Disabled("需要 授权 key. 暂时忽略")
|
||||
void testRealTimeQueryExpressFailed() {
|
||||
ServiceException t = assertThrows(ServiceException.class, () -> {
|
||||
ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO();
|
||||
reqDTO.setExpressCode("yto");
|
||||
reqDTO.setLogisticsNo("YT9383342193097");
|
||||
kd100ExpressClient.getExpressTrackList(reqDTO);
|
||||
});
|
||||
assertEquals(1011003005, t.getCode());
|
||||
}
|
||||
|
||||
@Import({
|
||||
RestTemplateAutoConfiguration.class
|
||||
})
|
||||
@EnableConfigurationProperties(TradeExpressProperties.class)
|
||||
public static class Application {
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao.KdNiaoExpressClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link KdNiaoExpressClient} 的集成测试
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Slf4j
|
||||
public class KdNiaoExpressClientIntegrationTest {
|
||||
|
||||
private KdNiaoExpressClient client;
|
||||
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
||||
TradeExpressProperties.KdNiaoConfig config = new TradeExpressProperties.KdNiaoConfig()
|
||||
.setApiKey("cb022f1e-48f1-4c4a-a723-9001ac9676b8")
|
||||
.setBusinessId("1809751");
|
||||
client = new KdNiaoExpressClient(restTemplate, config);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("集成测试,暂时忽略")
|
||||
public void testGetExpressTrackList() {
|
||||
ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO();
|
||||
reqDTO.setExpressCode("STO");
|
||||
reqDTO.setLogisticsNo("663220402764314");
|
||||
List<ExpressTrackRespDTO> tracks = client.getExpressTrackList(reqDTO);
|
||||
System.out.println(JsonUtils.toJsonPrettyString(tracks));
|
||||
}
|
||||
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
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.TradeExpressProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao.KdNiaoExpressClient;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
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.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
// TODO @jason:可以参考 AliyunSmsClientTest 写,纯 mockito,无需启动 spring 容器
|
||||
/**
|
||||
* {@link KdNiaoExpressClient} 的单元测试
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = KdNiaoExpressClientTest.Application.class)
|
||||
@ActiveProfiles("unit-test")
|
||||
public class KdNiaoExpressClientTest {
|
||||
|
||||
@Resource
|
||||
private RestTemplateBuilder builder;
|
||||
@Resource
|
||||
private TradeExpressProperties expressQueryProperties;
|
||||
|
||||
private KdNiaoExpressClient kdNiaoExpressClient;
|
||||
|
||||
@BeforeEach
|
||||
public void init(){
|
||||
kdNiaoExpressClient = new KdNiaoExpressClient(builder.build(),expressQueryProperties.getKdNiao());
|
||||
}
|
||||
@Test
|
||||
@Disabled("需要 授权 key. 暂时忽略")
|
||||
void testRealTimeQueryExpressFailed() {
|
||||
assertThrows(ServiceException.class,() ->{
|
||||
ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO();
|
||||
reqDTO.setExpressCode("yy");
|
||||
reqDTO.setLogisticsNo("YT9383342193097");
|
||||
kdNiaoExpressClient.getExpressTrackList(reqDTO);
|
||||
});
|
||||
}
|
||||
|
||||
@Import({
|
||||
RestTemplateAutoConfiguration.class
|
||||
})
|
||||
@EnableConfigurationProperties(TradeExpressProperties.class)
|
||||
public static class Application {
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
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;
|
||||
|
||||
// TODO @jason:可以参考 AliyunSmsClientTest 写,纯 mockito,无需启动 spring 容器
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user