优化
This commit is contained in:
@@ -7,10 +7,10 @@ spring:
|
|||||||
baiyue:
|
baiyue:
|
||||||
security-event:
|
security-event:
|
||||||
event-bridge-url: ${SECURITY_EVENT_BRIDGE_URL:http://event-bridge-overseas:9312}
|
event-bridge-url: ${SECURITY_EVENT_BRIDGE_URL:http://event-bridge-overseas:9312}
|
||||||
customer-dimension-initialization:
|
security-event:
|
||||||
fixed-delay-ms: ${CUSTOMER_DIMENSION_INITIALIZATION_FIXED_DELAY_MS:5000}
|
event-bridge-url: ${SECURITY_EVENT_BRIDGE_URL:http://event-bridge-overseas:9312}
|
||||||
max-attempts: ${CUSTOMER_DIMENSION_INITIALIZATION_MAX_ATTEMPTS:12}
|
|
||||||
notification:
|
notification:
|
||||||
scheduler-enabled: ${NOTIFICATION_SCHEDULER_ENABLED:false}
|
scheduler-enabled: ${NOTIFICATION_SCHEDULER_ENABLED:false}
|
||||||
dispatch-timeout-seconds: ${NOTIFICATION_DISPATCH_TIMEOUT_SECONDS:300}
|
dispatch-timeout-seconds: ${NOTIFICATION_DISPATCH_TIMEOUT_SECONDS:300}
|
||||||
mq-consumer-enabled: ${NOTIFICATION_MQ_CONSUMER_ENABLED:false}
|
mq-consumer-enabled: ${NOTIFICATION_MQ_CONSUMER_ENABLED:false}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,8 @@ spring:
|
|||||||
baiyue:
|
baiyue:
|
||||||
security-event:
|
security-event:
|
||||||
event-bridge-url: ${SECURITY_EVENT_BRIDGE_URL:http://event-bridge-overseas:9312}
|
event-bridge-url: ${SECURITY_EVENT_BRIDGE_URL:http://event-bridge-overseas:9312}
|
||||||
customer-dimension-initialization:
|
security-event:
|
||||||
fixed-delay-ms: ${CUSTOMER_DIMENSION_INITIALIZATION_FIXED_DELAY_MS:5000}
|
event-bridge-url: ${SECURITY_EVENT_BRIDGE_URL:http://event-bridge-overseas:9312}
|
||||||
max-attempts: ${CUSTOMER_DIMENSION_INITIALIZATION_MAX_ATTEMPTS:12}
|
|
||||||
notification:
|
notification:
|
||||||
scheduler-enabled: ${NOTIFICATION_SCHEDULER_ENABLED:false}
|
scheduler-enabled: ${NOTIFICATION_SCHEDULER_ENABLED:false}
|
||||||
dispatch-timeout-seconds: ${NOTIFICATION_DISPATCH_TIMEOUT_SECONDS:300}
|
dispatch-timeout-seconds: ${NOTIFICATION_DISPATCH_TIMEOUT_SECONDS:300}
|
||||||
@@ -50,3 +49,4 @@ logging:
|
|||||||
max-history: "${LOGGING_ROLLING_MAX_HISTORY:7}"
|
max-history: "${LOGGING_ROLLING_MAX_HISTORY:7}"
|
||||||
total-size-cap: "${LOGGING_ROLLING_TOTAL_SIZE_CAP:5GB}"
|
total-size-cap: "${LOGGING_ROLLING_TOTAL_SIZE_CAP:5GB}"
|
||||||
clean-history-on-start: "${LOGGING_ROLLING_CLEAN_HISTORY_ON_START:false}"
|
clean-history-on-start: "${LOGGING_ROLLING_CLEAN_HISTORY_ON_START:false}"
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class MerchantOnboardingServiceTest {
|
|||||||
@MockBean private CustomerDimensionRuleInitializationService dimensionRuleInitialization;
|
@MockBean private CustomerDimensionRuleInitializationService dimensionRuleInitialization;
|
||||||
@MockBean private OverseasStorageFeeInitializationService overseasStorageFeeInitialization;
|
@MockBean private OverseasStorageFeeInitializationService overseasStorageFeeInitialization;
|
||||||
@MockBean private SecurityEventOutboxService securityEvents;
|
@MockBean private SecurityEventOutboxService securityEvents;
|
||||||
|
@MockBean private SecurityEventOutboxService securityEvents;
|
||||||
@Resource private MerchantOnboardingService service;
|
@Resource private MerchantOnboardingService service;
|
||||||
@Test
|
@Test
|
||||||
void clientRegistrationCreatesOwnerAndAssignsGlobalMerchantOwnerRole() {
|
void clientRegistrationCreatesOwnerAndAssignsGlobalMerchantOwnerRole() {
|
||||||
@@ -55,8 +56,8 @@ class MerchantOnboardingServiceTest {
|
|||||||
when(roles.selectOne(any())).thenReturn(ownerRole);
|
when(roles.selectOne(any())).thenReturn(ownerRole);
|
||||||
|
|
||||||
var result = service.register(new MerchantRegistrationRequest(
|
var result = service.register(new MerchantRegistrationRequest(
|
||||||
9001L, "注册人", "测试企业", "张三", "13800138000",
|
9001L, "注册人", "测试企业", "张三", "13800138000",
|
||||||
"owner@example.com", "CN", "深圳市宝安区"));
|
"owner@example.com", "CN", "深圳市宝安区"));
|
||||||
|
|
||||||
ArgumentCaptor<IamTenant> tenant = ArgumentCaptor.forClass(IamTenant.class);
|
ArgumentCaptor<IamTenant> tenant = ArgumentCaptor.forClass(IamTenant.class);
|
||||||
ArgumentCaptor<IamUser> user = ArgumentCaptor.forClass(IamUser.class);
|
ArgumentCaptor<IamUser> user = ArgumentCaptor.forClass(IamUser.class);
|
||||||
@@ -67,19 +68,21 @@ class MerchantOnboardingServiceTest {
|
|||||||
verify(memberships).insert(membership.capture());
|
verify(memberships).insert(membership.capture());
|
||||||
verify(membershipRoles).insert(roleGrant.capture());
|
verify(membershipRoles).insert(roleGrant.capture());
|
||||||
verify(dimensionRuleInitialization).initialize(result.tenantId(), 9001L);
|
verify(dimensionRuleInitialization).initialize(result.tenantId(), 9001L);
|
||||||
verify(overseasStorageFeeInitialization).initialize(result.tenantId(), 9001L, "测试企业");
|
verify(overseasStorageFeeInitialization).initialize(result.tenantId(), 9001L, "测试企业");
|
||||||
|
verify(securityEvents).tenantStatus(result.tenantId(), "PROFILE_REQUIRED");
|
||||||
|
verify(securityEvents).userStatus(9001L, result.tenantId(), "MERCHANT", "ACTIVE");
|
||||||
|
verify(securityEvents).permissionChanged(9001L, result.tenantId(), "MERCHANT",
|
||||||
|
"INITIAL_AUTHORIZATION");
|
||||||
verify(securityEvents).tenantStatus(result.tenantId(), "PROFILE_REQUIRED");
|
verify(securityEvents).tenantStatus(result.tenantId(), "PROFILE_REQUIRED");
|
||||||
verify(securityEvents).userStatus(9001L, result.tenantId(), "MERCHANT", "ACTIVE");
|
verify(securityEvents).userStatus(9001L, result.tenantId(), "MERCHANT", "ACTIVE");
|
||||||
verify(securityEvents).permissionChanged(9001L, result.tenantId(), "MERCHANT",
|
verify(securityEvents).permissionChanged(9001L, result.tenantId(), "MERCHANT",
|
||||||
"INITIAL_AUTHORIZATION");
|
"INITIAL_AUTHORIZATION");
|
||||||
|
|
||||||
assertEquals("PROFILE_REQUIRED", result.tenantStatus());
|
assertEquals("PROFILE_REQUIRED", result.tenantStatus());
|
||||||
assertEquals("PENDING", result.dimensionInitializationStatus());
|
|
||||||
assertEquals("PENDING", tenant.getValue().getDimensionInitializationStatus());
|
|
||||||
assertEquals(result.tenantId(), tenant.getValue().getId());
|
assertEquals(result.tenantId(), tenant.getValue().getId());
|
||||||
assertEquals("测试企业", tenant.getValue().getLegalName());
|
assertEquals("测试企业", tenant.getValue().getLegalName());
|
||||||
assertEquals("张三", tenant.getValue().getLegalRepresentative());
|
assertEquals("张三", tenant.getValue().getLegalRepresentative());
|
||||||
assertEquals("注册人", tenant.getValue().getContactName());
|
assertEquals("注册人", tenant.getValue().getContactName());
|
||||||
assertEquals(9001L, user.getValue().getAuthUserId());
|
assertEquals(9001L, user.getValue().getAuthUserId());
|
||||||
assertEquals("ACTIVE", user.getValue().getStatus());
|
assertEquals("ACTIVE", user.getValue().getStatus());
|
||||||
assertEquals(result.tenantId(), membership.getValue().getTenantId());
|
assertEquals(result.tenantId(), membership.getValue().getTenantId());
|
||||||
@@ -124,7 +127,7 @@ class MerchantOnboardingServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void clientRegistrationFailsWhenDurableInitializationIntentCannotBePersisted() {
|
void clientRegistrationFailsWhenFourDefaultBoxDimensionsCannotBeInitialized() {
|
||||||
IamRole ownerRole = new IamRole();
|
IamRole ownerRole = new IamRole();
|
||||||
ownerRole.setId(4000100L);
|
ownerRole.setId(4000100L);
|
||||||
ownerRole.setTenantId(0L);
|
ownerRole.setTenantId(0L);
|
||||||
@@ -133,14 +136,14 @@ class MerchantOnboardingServiceTest {
|
|||||||
ownerRole.setStatus("ACTIVE");
|
ownerRole.setStatus("ACTIVE");
|
||||||
when(roles.selectOne(any())).thenReturn(ownerRole);
|
when(roles.selectOne(any())).thenReturn(ownerRole);
|
||||||
org.mockito.Mockito.doThrow(new com.baiyue.common.core.exception.BizException(
|
org.mockito.Mockito.doThrow(new com.baiyue.common.core.exception.BizException(
|
||||||
com.baiyue.common.core.api.ResultCode.SERVICE_UNAVAILABLE, "初始化失败"))
|
com.baiyue.common.core.api.ResultCode.SERVICE_UNAVAILABLE, "初始化失败"))
|
||||||
.when(dimensionRuleInitialization).initialize(
|
.when(dimensionRuleInitialization).initialize(
|
||||||
org.mockito.ArgumentMatchers.anyLong(), org.mockito.ArgumentMatchers.anyLong());
|
org.mockito.ArgumentMatchers.anyLong(), org.mockito.ArgumentMatchers.anyLong());
|
||||||
|
|
||||||
var failure = assertThrows(com.baiyue.common.core.exception.BizException.class,
|
var failure = assertThrows(com.baiyue.common.core.exception.BizException.class,
|
||||||
() -> service.register(new MerchantRegistrationRequest(
|
() -> service.register(new MerchantRegistrationRequest(
|
||||||
9001L, "注册人", "测试企业", "张三", "13800138000",
|
9001L, "注册人", "测试企业", "张三", "13800138000",
|
||||||
"owner@example.com", "CN", "深圳市宝安区")));
|
"owner@example.com", "CN", "深圳市宝安区")));
|
||||||
|
|
||||||
assertEquals(com.baiyue.common.core.api.ResultCode.SERVICE_UNAVAILABLE, failure.getResultCode());
|
assertEquals(com.baiyue.common.core.api.ResultCode.SERVICE_UNAVAILABLE, failure.getResultCode());
|
||||||
}
|
}
|
||||||
@@ -190,7 +193,7 @@ class MerchantOnboardingServiceTest {
|
|||||||
when(qualifications.selectCount(any())).thenReturn(0L);
|
when(qualifications.selectCount(any())).thenReturn(0L);
|
||||||
when(reviews.selectCount(any())).thenReturn(0L);
|
when(reviews.selectCount(any())).thenReturn(0L);
|
||||||
org.mockito.Mockito.doThrow(new com.baiyue.common.core.exception.BizException(
|
org.mockito.Mockito.doThrow(new com.baiyue.common.core.exception.BizException(
|
||||||
com.baiyue.common.core.api.ResultCode.SERVICE_UNAVAILABLE, "补偿失败"))
|
com.baiyue.common.core.api.ResultCode.SERVICE_UNAVAILABLE, "补偿失败"))
|
||||||
.when(dimensionRuleInitialization).compensateRegistration(10001L);
|
.when(dimensionRuleInitialization).compensateRegistration(10001L);
|
||||||
|
|
||||||
assertThrows(com.baiyue.common.core.exception.BizException.class,
|
assertThrows(com.baiyue.common.core.exception.BizException.class,
|
||||||
@@ -201,3 +204,4 @@ class MerchantOnboardingServiceTest {
|
|||||||
verify(tenants, never()).deleteById((java.io.Serializable) any());
|
verify(tenants, never()).deleteById((java.io.Serializable) any());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,22 +151,22 @@ class TenantServiceTest {
|
|||||||
|
|
||||||
var updated = service.updateMerchant(10001L,
|
var updated = service.updateMerchant(10001L,
|
||||||
new UpdateTenantRequest("New name", "New legal", "Bob", "Alice", "13800138000", "alice@example.com",
|
new UpdateTenantRequest("New name", "New legal", "Bob", "Alice", "13800138000", "alice@example.com",
|
||||||
"专业版", "alice_wechat", "Sales Zhang", 45, "LIMITED_COMPANY", LocalDate.of(2020, 1, 2),
|
"专业版", "alice_wechat", "Sales Zhang", 45, "LIMITED_COMPANY", LocalDate.of(2020, 1, 2),
|
||||||
new BigDecimal("5000000.00"), "CNY", "深圳市南山区示例路 1 号", "一期重点客户"));
|
new BigDecimal("5000000.00"), "CNY", "深圳市南山区示例路 1 号", "一期重点客户"));
|
||||||
var disabled = service.changeMerchantStatus(10001L, new ChangeTenantStatusRequest("DISABLED"));
|
var disabled = service.changeMerchantStatus(10001L, new ChangeTenantStatusRequest("DISABLED"));
|
||||||
|
|
||||||
assertEquals("New name", updated.tenantName());
|
assertEquals("New name", updated.tenantName());
|
||||||
assertEquals("Bob", updated.legalRepresentative());
|
assertEquals("Bob", updated.legalRepresentative());
|
||||||
assertEquals("alice_wechat", updated.contactWechat());
|
assertEquals("alice_wechat", updated.contactWechat());
|
||||||
assertEquals("专业版", updated.servicePackage());
|
assertEquals("专业版", updated.servicePackage());
|
||||||
assertEquals("Sales Zhang", updated.salesOwnerName());
|
assertEquals("Sales Zhang", updated.salesOwnerName());
|
||||||
assertEquals(45, updated.paymentTermDays());
|
assertEquals(45, updated.paymentTermDays());
|
||||||
assertEquals("LIMITED_COMPANY", updated.enterpriseType());
|
assertEquals("LIMITED_COMPANY", updated.enterpriseType());
|
||||||
assertEquals(LocalDate.of(2020, 1, 2), updated.establishedDate());
|
assertEquals(LocalDate.of(2020, 1, 2), updated.establishedDate());
|
||||||
assertEquals(new BigDecimal("5000000.00"), updated.registeredCapital());
|
assertEquals(new BigDecimal("5000000.00"), updated.registeredCapital());
|
||||||
assertEquals("CNY", updated.registeredCapitalCurrency());
|
assertEquals("CNY", updated.registeredCapitalCurrency());
|
||||||
assertEquals("深圳市南山区示例路 1 号", updated.registeredAddress());
|
assertEquals("深圳市南山区示例路 1 号", updated.registeredAddress());
|
||||||
assertEquals("一期重点客户", updated.internalRemark());
|
assertEquals("一期重点客户", updated.internalRemark());
|
||||||
assertEquals("DISABLED", disabled.status());
|
assertEquals("DISABLED", disabled.status());
|
||||||
verify(repository, org.mockito.Mockito.times(2)).saveTenant(tenant);
|
verify(repository, org.mockito.Mockito.times(2)).saveTenant(tenant);
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ class TenantServiceTest {
|
|||||||
|
|
||||||
BizException exception = assertThrows(BizException.class, () -> service.updateMerchant(10001L,
|
BizException exception = assertThrows(BizException.class, () -> service.updateMerchant(10001L,
|
||||||
new UpdateTenantRequest("New name", "New legal", "Bob", "Alice", "13900139000", null,
|
new UpdateTenantRequest("New name", "New legal", "Bob", "Alice", "13900139000", null,
|
||||||
"基础版", null, null, 30, null, null, null, "CNY", null, null)));
|
"基础版", null, null, 30, null, null, null, "CNY", null, null)));
|
||||||
|
|
||||||
assertEquals(ResultCode.CONFLICT, exception.getResultCode());
|
assertEquals(ResultCode.CONFLICT, exception.getResultCode());
|
||||||
assertEquals("13800138000", tenant.getContactPhone());
|
assertEquals("13800138000", tenant.getContactPhone());
|
||||||
@@ -273,7 +273,7 @@ class TenantServiceTest {
|
|||||||
|
|
||||||
BizException platformFailure = assertThrows(BizException.class, () -> service.updateMerchant(10001L,
|
BizException platformFailure = assertThrows(BizException.class, () -> service.updateMerchant(10001L,
|
||||||
new UpdateTenantRequest("New name", "New legal", "Bob", "Alice", "13800138000", null,
|
new UpdateTenantRequest("New name", "New legal", "Bob", "Alice", "13800138000", null,
|
||||||
"基础版", null, null, 30, null, null, null, "CNY", null, null)));
|
"基础版", null, null, 30, null, null, null, "CNY", null, null)));
|
||||||
BizException merchantFailure = assertThrows(BizException.class, () -> service.update(10001L,
|
BizException merchantFailure = assertThrows(BizException.class, () -> service.update(10001L,
|
||||||
new UpdateProfileRequest("New name", "New legal", "Bob", "Alice",
|
new UpdateProfileRequest("New name", "New legal", "Bob", "Alice",
|
||||||
"13800138000", "alice@example.com")));
|
"13800138000", "alice@example.com")));
|
||||||
@@ -308,32 +308,32 @@ class TenantServiceTest {
|
|||||||
|
|
||||||
var created = service.register(new RegisterRequest(
|
var created = service.register(new RegisterRequest(
|
||||||
"Example Merchant", "Example Merchant Ltd", "Bob", "Alice", "13800138000",
|
"Example Merchant", "Example Merchant Ltd", "Bob", "Alice", "13800138000",
|
||||||
"alice@example.com", "基础版", "alice_wechat", "Sales Zhang", 30, "LIMITED_COMPANY",
|
"alice@example.com", "基础版", "alice_wechat", "Sales Zhang", 30, "LIMITED_COMPANY",
|
||||||
LocalDate.of(2020, 1, 2), new BigDecimal("5000000.00"), "CNY", "深圳市南山区", "草稿客户"),
|
LocalDate.of(2020, 1, 2), new BigDecimal("5000000.00"), "CNY", "深圳市南山区", "草稿客户"),
|
||||||
9001L);
|
9001L);
|
||||||
|
|
||||||
assertEquals("PROFILE_REQUIRED", created.tenant().status());
|
assertEquals("PROFILE_REQUIRED", created.tenant().status());
|
||||||
assertEquals("PENDING", created.tenant().dimensionInitializationStatus());
|
|
||||||
assertEquals("Bob", created.tenant().legalRepresentative());
|
assertEquals("Bob", created.tenant().legalRepresentative());
|
||||||
assertEquals("基础版", created.tenant().servicePackage());
|
assertEquals("基础版", created.tenant().servicePackage());
|
||||||
assertEquals("13800138000", created.administratorUsername());
|
assertEquals("13800138000", created.administratorUsername());
|
||||||
assertEquals("Password1234", created.temporaryPassword());
|
assertEquals("Password1234", created.temporaryPassword());
|
||||||
verify(repository).insertTenant(argThat(tenant -> Long.valueOf(9001L).equals(tenant.getCreatedBy())
|
verify(repository).insertTenant(argThat(tenant -> Long.valueOf(9001L).equals(tenant.getCreatedBy())
|
||||||
&& Long.valueOf(9001L).equals(tenant.getUpdatedBy())));
|
&& Long.valueOf(9001L).equals(tenant.getUpdatedBy())));
|
||||||
verify(dimensionRuleInitialization).initialize(created.tenant().id(), 9001L);
|
verify(dimensionRuleInitialization).initialize(created.tenant().id(), 9001L);
|
||||||
verify(securityEvents).tenantStatus(created.tenant().id(), "PROFILE_REQUIRED");
|
verify(securityEvents).tenantStatus(created.tenant().id(), "PROFILE_REQUIRED");
|
||||||
|
verify(securityEvents).tenantStatus(created.tenant().id(), "PROFILE_REQUIRED");
|
||||||
verify(provisioning).provisionPlatformCreatedTenant(any(), eq(9001L));
|
verify(provisioning).provisionPlatformCreatedTenant(any(), eq(9001L));
|
||||||
verify(repository, never()).insertReview(any());
|
verify(repository, never()).insertReview(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void platformRegistrationFailsWhenDurableInitializationIntentCannotBePersisted() {
|
void platformRegistrationFailsWhenFourDefaultBoxDimensionsCannotBeInitialized() {
|
||||||
doThrow(new BizException(ResultCode.SERVICE_UNAVAILABLE, "初始化失败"))
|
doThrow(new BizException(ResultCode.SERVICE_UNAVAILABLE, "初始化失败"))
|
||||||
.when(dimensionRuleInitialization).initialize(any(Long.class), any(Long.class));
|
.when(dimensionRuleInitialization).initialize(any(Long.class), any(Long.class));
|
||||||
|
|
||||||
BizException failure = assertThrows(BizException.class, () -> service.register(new RegisterRequest(
|
BizException failure = assertThrows(BizException.class, () -> service.register(new RegisterRequest(
|
||||||
"Example Merchant", "Example Merchant Ltd", "Bob", "Alice", "13800138000",
|
"Example Merchant", "Example Merchant Ltd", "Bob", "Alice", "13800138000",
|
||||||
"alice@example.com", "基础版", null, null, 30, null,
|
"alice@example.com", "基础版", null, null, 30, null,
|
||||||
null, null, "CNY", null, null), 9001L));
|
null, null, "CNY", null, null), 9001L));
|
||||||
|
|
||||||
assertEquals(ResultCode.SERVICE_UNAVAILABLE, failure.getResultCode());
|
assertEquals(ResultCode.SERVICE_UNAVAILABLE, failure.getResultCode());
|
||||||
@@ -347,7 +347,7 @@ class TenantServiceTest {
|
|||||||
|
|
||||||
var created = service.register(new RegisterRequest(
|
var created = service.register(new RegisterRequest(
|
||||||
"Example Merchant", "Example Merchant Ltd", "Bob", "Alice", "13800138000",
|
"Example Merchant", "Example Merchant Ltd", "Bob", "Alice", "13800138000",
|
||||||
"alice@example.com", "基础版", null, null, 30, null,
|
"alice@example.com", "基础版", null, null, 30, null,
|
||||||
null, null, "CNY", null, null), 9001L);
|
null, null, "CNY", null, null), 9001L);
|
||||||
|
|
||||||
assertEquals(null, created.tenant().unifiedSocialCreditCode());
|
assertEquals(null, created.tenant().unifiedSocialCreditCode());
|
||||||
@@ -420,7 +420,7 @@ class TenantServiceTest {
|
|||||||
TenantAdministratorProvisioningService.ProvisioningResult.created(
|
TenantAdministratorProvisioningService.ProvisioningResult.created(
|
||||||
81L, "merchant_10001", "Password1234")).when(provisioning).initialize(any());
|
81L, "merchant_10001", "Password1234")).when(provisioning).initialize(any());
|
||||||
|
|
||||||
var result = service.review(71L, 9001L, true, "资料完整");
|
var result = service.review(71L, 9001L, true, "资料完整");
|
||||||
|
|
||||||
assertEquals(10001L, result.tenantId());
|
assertEquals(10001L, result.tenantId());
|
||||||
assertEquals(true, result.administratorCreated());
|
assertEquals(true, result.administratorCreated());
|
||||||
@@ -431,6 +431,7 @@ class TenantServiceTest {
|
|||||||
verify(repository).saveReview(review);
|
verify(repository).saveReview(review);
|
||||||
verify(repository).saveTenant(tenant);
|
verify(repository).saveTenant(tenant);
|
||||||
verify(securityEvents).tenantStatus(10001L, "ACTIVE");
|
verify(securityEvents).tenantStatus(10001L, "ACTIVE");
|
||||||
|
verify(securityEvents).tenantStatus(10001L, "ACTIVE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -446,7 +447,7 @@ class TenantServiceTest {
|
|||||||
doReturn(TenantAdministratorProvisioningService.ProvisioningResult.existing())
|
doReturn(TenantAdministratorProvisioningService.ProvisioningResult.existing())
|
||||||
.when(provisioning).initialize(any());
|
.when(provisioning).initialize(any());
|
||||||
|
|
||||||
var result = service.review(71L, 9001L, true, "资料完整");
|
var result = service.review(71L, 9001L, true, "资料完整");
|
||||||
|
|
||||||
assertEquals(false, result.administratorCreated());
|
assertEquals(false, result.administratorCreated());
|
||||||
assertEquals(null, result.administratorUsername());
|
assertEquals(null, result.administratorUsername());
|
||||||
@@ -470,7 +471,7 @@ class TenantServiceTest {
|
|||||||
doReturn(administrator).when(provisioning).initialize(any());
|
doReturn(administrator).when(provisioning).initialize(any());
|
||||||
doThrow(new RuntimeException("review write failed")).when(repository).saveReview(review);
|
doThrow(new RuntimeException("review write failed")).when(repository).saveReview(review);
|
||||||
|
|
||||||
assertThrows(RuntimeException.class, () -> service.review(71L, 9001L, true, "资料完整"));
|
assertThrows(RuntimeException.class, () -> service.review(71L, 9001L, true, "资料完整"));
|
||||||
|
|
||||||
verify(provisioning).compensate(any(), eq(administrator));
|
verify(provisioning).compensate(any(), eq(administrator));
|
||||||
verify(repository, never()).saveTenant(tenant);
|
verify(repository, never()).saveTenant(tenant);
|
||||||
@@ -492,26 +493,12 @@ class TenantServiceTest {
|
|||||||
assertEquals(true, withQualification.eligible());
|
assertEquals(true, withQualification.eligible());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void activeCustomerCannotOrderUntilDefaultDimensionsAreReady() {
|
|
||||||
IamTenant tenant = merchant(10001L, "ACTIVE");
|
|
||||||
tenant.setDimensionInitializationStatus("FAILED");
|
|
||||||
when(repository.findTenant(10001L)).thenReturn(tenant);
|
|
||||||
|
|
||||||
var result = service.orderEligibility(10001L);
|
|
||||||
|
|
||||||
assertEquals(false, result.eligible());
|
|
||||||
assertEquals("Customer default dimensions are not ready", result.reason());
|
|
||||||
verify(profileRepository, never()).findQualifications(10001L);
|
|
||||||
}
|
|
||||||
|
|
||||||
private IamTenant merchant(long id, String status) {
|
private IamTenant merchant(long id, String status) {
|
||||||
IamTenant tenant = new IamTenant();
|
IamTenant tenant = new IamTenant();
|
||||||
tenant.setId(id);
|
tenant.setId(id);
|
||||||
tenant.setTenantCode("TEN" + id);
|
tenant.setTenantCode("TEN" + id);
|
||||||
tenant.setTenantType("MERCHANT");
|
tenant.setTenantType("MERCHANT");
|
||||||
tenant.setStatus(status);
|
tenant.setStatus(status);
|
||||||
tenant.setDimensionInitializationStatus("READY");
|
|
||||||
tenant.setTenantName("Example Merchant");
|
tenant.setTenantName("Example Merchant");
|
||||||
tenant.setLegalName("Example Merchant Ltd");
|
tenant.setLegalName("Example Merchant Ltd");
|
||||||
tenant.setUnifiedSocialCreditCode("91330100EXAMPLE001");
|
tenant.setUnifiedSocialCreditCode("91330100EXAMPLE001");
|
||||||
@@ -544,3 +531,4 @@ class TenantServiceTest {
|
|||||||
return review;
|
return review;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,19 +130,6 @@ test('every reviewed synchronous client has a complete and exclusive executable
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test('IAM customer dimension Feign is reachable only from the background relay', async () => {
|
|
||||||
const references = []
|
|
||||||
for (const file of await javaFiles(path.join(root, 'iam', 'src', 'main', 'java'))) {
|
|
||||||
const source = await readFile(file, 'utf8')
|
|
||||||
if (source.includes('CustomerDimensionRuleClient')) {
|
|
||||||
references.push(path.relative(root, file).replaceAll('\\', '/'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert.deepEqual(references.sort(), [
|
|
||||||
'iam/src/main/java/com/baiyue/iam/client/CustomerDimensionRuleClient.java',
|
|
||||||
'iam/src/main/java/com/baiyue/iam/service/CustomerDimensionInitializationRelay.java'
|
|
||||||
])
|
|
||||||
})
|
|
||||||
|
|
||||||
test('all four Lastleg RestClient gateways use explicit bounded transports', async () => {
|
test('all four Lastleg RestClient gateways use explicit bounded transports', async () => {
|
||||||
const clients = new Map([
|
const clients = new Map([
|
||||||
|
|||||||
Reference in New Issue
Block a user