Merge branch 'oy-test' of http://8.163.30.128:10082/java-project/baiyue-firstleg into oy-test
This commit is contained in:
@@ -64,7 +64,12 @@ public class OrderMasterDataGuard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private PartnerClient.Partner loadPartner(long tenantId,long id) {
|
private PartnerClient.Partner loadPartner(long tenantId,long id) {
|
||||||
var response=partners.active(token,tenantId,id);
|
ApiResponse<PartnerClient.Partner> response;
|
||||||
|
try {
|
||||||
|
response=partners.active(token,tenantId,id);
|
||||||
|
} catch (FeignException.NotFound exception) {
|
||||||
|
throw new BizException(ResultCode.NOT_FOUND,"\u672a\u7ed1\u5b9a\u53ef\u7528\u5f80\u6765\u5ba2\u6237");
|
||||||
|
}
|
||||||
requireSuccessful(response,"往来单位");
|
requireSuccessful(response,"往来单位");
|
||||||
if (response.data()==null) throw unavailable("往来单位");
|
if (response.data()==null) throw unavailable("往来单位");
|
||||||
var value=response.data();
|
var value=response.data();
|
||||||
@@ -78,7 +83,12 @@ public class OrderMasterDataGuard {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
private WarehouseClient.Detail loadWarehouse(long tenantId,long id,String name) {
|
private WarehouseClient.Detail loadWarehouse(long tenantId,long id,String name) {
|
||||||
var response=warehouses.active(token,tenantId,id);
|
ApiResponse<WarehouseClient.Detail> response;
|
||||||
|
try {
|
||||||
|
response=warehouses.active(token,tenantId,id);
|
||||||
|
} catch (FeignException.NotFound exception) {
|
||||||
|
throw new BizException(ResultCode.NOT_FOUND,"\u6536\u8d27\u4ed3\u5e93\u4e0d\u5b58\u5728\u6216\u5df2\u505c\u7528");
|
||||||
|
}
|
||||||
requireSuccessful(response,name);
|
requireSuccessful(response,name);
|
||||||
if (response.data()==null || response.data().warehouse()==null) throw unavailable(name);
|
if (response.data()==null || response.data().warehouse()==null) throw unavailable(name);
|
||||||
var value=response.data();
|
var value=response.data();
|
||||||
|
|||||||
@@ -100,14 +100,15 @@ class OrderMasterDataGuardTest {
|
|||||||
.isEqualTo(ResultCode.SERVICE_UNAVAILABLE);
|
.isEqualTo(ResultCode.SERVICE_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void downstreamHttpNotFoundMapsToServiceUnavailable() {
|
void downstreamHttpNotFoundReturnsUnboundCustomerMessage() {
|
||||||
WarehouseClient warehouses=mock(WarehouseClient.class); PartnerClient partners=mock(PartnerClient.class);
|
WarehouseClient warehouses=mock(WarehouseClient.class); PartnerClient partners=mock(PartnerClient.class);
|
||||||
when(partners.active("token",10001,7)).thenThrow(feign(404));
|
when(partners.active("token",10001,7)).thenThrow(feign(404));
|
||||||
|
|
||||||
assertThatThrownBy(() -> new OrderMasterDataGuard(warehouses,partners,"token").validate(10001,request(7L,8L)))
|
assertThatThrownBy(() -> new OrderMasterDataGuard(warehouses,partners,"token").validate(10001,request(7L,8L)))
|
||||||
.isInstanceOf(BizException.class)
|
.isInstanceOf(BizException.class)
|
||||||
|
.hasMessage("\u672a\u7ed1\u5b9a\u53ef\u7528\u5f80\u6765\u5ba2\u6237")
|
||||||
.extracting(exception -> ((BizException) exception).getResultCode())
|
.extracting(exception -> ((BizException) exception).getResultCode())
|
||||||
.isEqualTo(ResultCode.SERVICE_UNAVAILABLE);
|
.isEqualTo(ResultCode.NOT_FOUND);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void wrappedDownstreamHttpConflictMapsToServiceUnavailable() {
|
void wrappedDownstreamHttpConflictMapsToServiceUnavailable() {
|
||||||
|
|||||||
@@ -27,5 +27,7 @@ INSERT INTO wh_partner(id,tenant_id,data_scope_id,partner_code,partner_name,part
|
|||||||
VALUES(191000000000000001,10001,10001,'CUS-001','深圳示例贸易有限公司','CUSTOMER','张三','13800138000','contact@example.com','CN','广东省','深圳市','宝安区','航城街道示例路1号','518000','ACTIVE')
|
VALUES(191000000000000001,10001,10001,'CUS-001','深圳示例贸易有限公司','CUSTOMER','张三','13800138000','contact@example.com','CN','广东省','深圳市','宝安区','航城街道示例路1号','518000','ACTIVE')
|
||||||
ON DUPLICATE KEY UPDATE partner_name=VALUES(partner_name),status='ACTIVE';
|
ON DUPLICATE KEY UPDATE partner_name=VALUES(partner_name),status='ACTIVE';
|
||||||
INSERT INTO wh_partner_type(partner_id,tenant_id,data_scope_id,partner_type)
|
INSERT INTO wh_partner_type(partner_id,tenant_id,data_scope_id,partner_type)
|
||||||
VALUES(191000000000000001,10001,10001,'CUSTOMER')
|
VALUES
|
||||||
|
(191000000000000001,10001,10001,'CUSTOMER'),
|
||||||
|
(191000000000000001,10001,10001,'SHIPPER')
|
||||||
ON DUPLICATE KEY UPDATE tenant_id=VALUES(tenant_id),data_scope_id=VALUES(data_scope_id);
|
ON DUPLICATE KEY UPDATE tenant_id=VALUES(tenant_id),data_scope_id=VALUES(data_scope_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user