liujie
2026-09-16 a3a56121a476cd23d0f29bc391c07374dc5008f2
backend/src/test/java/com/tourguide/modules/user/service/GuideAccountServiceTest.java
@@ -11,11 +11,11 @@
import com.tourguide.security.TokenSessionService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -50,7 +50,7 @@
                .isInstanceOf(BusinessException.class)
                .hasMessage("存在未完成订单,暂时无法注销账号");
        verify(guideUserMapper, never()).updateById(any());
        verify(guideUserMapper, never()).cancelAccount(any(), any());
        verify(tokenSessionService, never()).remove(payload);
    }
@@ -71,16 +71,8 @@
        accountService.cancel(8L, "guide-token");
        ArgumentCaptor<GuideUser> userCaptor = ArgumentCaptor.forClass(GuideUser.class);
        verify(guideUserMapper).updateById(userCaptor.capture());
        assertThat(userCaptor.getValue().getStatus()).isEqualTo(GuideUserService.STATUS_CANCELLED);
        assertThat(userCaptor.getValue().getAutoDisableWhitelisted()).isZero();
        assertThat(userCaptor.getValue().getUsername()).startsWith("deleted_").hasSize(32);
        assertThat(userCaptor.getValue().getMobile()).isNull();
        assertThat(userCaptor.getValue().getCertificateNo()).isNull();
        assertThat(userCaptor.getValue().getIdCardNo()).isNull();
        assertThat(userCaptor.getValue().getIdCardFrontUrl()).isNull();
        assertThat(userCaptor.getValue().getIdCardBackUrl()).isNull();
        verify(guideUserMapper).cancelAccount(eq(8L), org.mockito.ArgumentMatchers.argThat(
                username -> username.startsWith("deleted_") && username.length() == 32));
        verify(guideApplicationMapper).clearIdentityByIdCard("11010519491231002X");
        verify(tokenSessionService).remove(payload);
    }