| | |
| | | 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; |
| | |
| | | .isInstanceOf(BusinessException.class) |
| | | .hasMessage("存在未完成订单,暂时无法注销账号"); |
| | | |
| | | verify(guideUserMapper, never()).updateById(any()); |
| | | verify(guideUserMapper, never()).cancelAccount(any(), any()); |
| | | verify(tokenSessionService, never()).remove(payload); |
| | | } |
| | | |
| | |
| | | |
| | | 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); |
| | | } |