优化
This commit is contained in:
+4
-1
@@ -9,7 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CustomerDimensionRuleClientContractTest {
|
||||
@Test
|
||||
void usesTheFirstlegInternalDimensionConfigContract() throws Exception {
|
||||
void usesOneAtomicCallForTheFourDefaultBoxDimensionRecords() throws Exception {
|
||||
FeignClient feign = CustomerDimensionRuleClient.class.getAnnotation(FeignClient.class);
|
||||
PostMapping initialize = CustomerDimensionRuleClient.class
|
||||
.getMethod("initialize", String.class,
|
||||
@@ -23,5 +23,8 @@ class CustomerDimensionRuleClientContractTest {
|
||||
assertThat(feign.path()).isEqualTo("/internal/firstleg/v1/customer-dimension-configs");
|
||||
assertThat(initialize.value()).containsExactly("/defaults");
|
||||
assertThat(compensate.value()).containsExactly("/defaults");
|
||||
assertThat(CustomerDimensionRuleClient.InitializationResponse.class.getRecordComponents())
|
||||
.extracting(java.lang.reflect.RecordComponent::getName)
|
||||
.containsExactly("configId", "createdByThisInitialization");
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -42,7 +42,7 @@ class CustomerDimensionRuleInitializationServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void retriesWithOneStableKeyAndReturnsTheIdempotentResult() {
|
||||
void retriesOneAtomicFourBoxDefaultsCallWithAStableKey() {
|
||||
when(client.initialize(anyString(), any()))
|
||||
.thenThrow(new RuntimeException("timeout"))
|
||||
.thenReturn(ApiResponse.failure(ResultCode.SERVICE_UNAVAILABLE,
|
||||
@@ -66,7 +66,7 @@ class CustomerDimensionRuleInitializationServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void reportsServiceUnavailableAfterThreeFailedAttemptsAndTriesCompensation() {
|
||||
void reportsServiceUnavailableWhenFourBoxDefaultsFailThreeTimesAndTriesCompensation() {
|
||||
when(client.initialize(anyString(), any())).thenThrow(new RuntimeException("timeout"));
|
||||
when(client.compensate(anyString(), anyLong(), anyString())).thenReturn(ApiResponse.success(null));
|
||||
|
||||
@@ -78,7 +78,7 @@ class CustomerDimensionRuleInitializationServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void localRollbackCompensatesOnlyAConfigurationCreatedByThisRegistration() {
|
||||
void localRollbackCompensatesFourBoxDefaultsCreatedByThisRegistration() {
|
||||
when(client.initialize(anyString(), any()))
|
||||
.thenReturn(ApiResponse.success(new CustomerDimensionRuleClient.InitializationResponse(91L, true)));
|
||||
when(client.compensate(anyString(), anyLong(), anyString())).thenReturn(ApiResponse.success(null));
|
||||
@@ -95,7 +95,7 @@ class CustomerDimensionRuleInitializationServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void localRollbackDoesNotDeleteAConfigurationThatAlreadyExisted() {
|
||||
void localRollbackKeepsFourBoxDefaultsThatAlreadyExisted() {
|
||||
when(client.initialize(anyString(), any()))
|
||||
.thenReturn(ApiResponse.success(new CustomerDimensionRuleClient.InitializationResponse(91L, false)));
|
||||
TransactionSynchronizationManager.initSynchronization();
|
||||
@@ -110,7 +110,7 @@ class CustomerDimensionRuleInitializationServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void responseTimeoutThenIdempotentSuccessStillCompensatesOnLocalRollback() {
|
||||
void responseTimeoutThenIdempotentFourBoxSuccessStillCompensatesOnLocalRollback() {
|
||||
when(client.initialize(anyString(), any()))
|
||||
.thenThrow(new RuntimeException("response timeout"))
|
||||
.thenReturn(ApiResponse.success(new CustomerDimensionRuleClient.InitializationResponse(91L, true)));
|
||||
|
||||
@@ -115,7 +115,7 @@ class MerchantOnboardingServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void clientRegistrationFailsWhenDefaultDimensionRuleCannotBeInitialized() {
|
||||
void clientRegistrationFailsWhenFourDefaultBoxDimensionsCannotBeInitialized() {
|
||||
IamRole ownerRole = new IamRole();
|
||||
ownerRole.setId(4000100L);
|
||||
ownerRole.setTenantId(0L);
|
||||
|
||||
@@ -183,7 +183,7 @@ class TenantServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformRegistrationFailsWhenDefaultDimensionRuleCannotBeInitialized() {
|
||||
void platformRegistrationFailsWhenFourDefaultBoxDimensionsCannotBeInitialized() {
|
||||
doThrow(new BizException(ResultCode.SERVICE_UNAVAILABLE, "初始化失败"))
|
||||
.when(dimensionRuleInitialization).initialize(any(Long.class), any(Long.class));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user