| | |
| | | } |
| | | |
| | | @Test |
| | | void shouldReuseCancelledGuideForNewRegistration() { |
| | | void shouldCreateNewGuideForCancelledRegistration() { |
| | | GuideUser cancelledGuide = new GuideUser(); |
| | | cancelledGuide.setId(12L); |
| | | cancelledGuide.setStatus(GuideUserService.STATUS_CANCELLED); |
| | | cancelledGuide.setMobile("13800138000"); |
| | | cancelledGuide.setUsername("13800138000"); |
| | | cancelledGuide.setCertificateNo("CERT-12"); |
| | | cancelledGuide.setIdCardNo("11010519491231002X"); |
| | | cancelledGuide.setAutoDisableWhitelisted(1); |
| | | cancelledGuide.setAutoDisabled(1); |
| | | when(userMapper.selectOne(any())).thenReturn(cancelledGuide); |
| | |
| | | |
| | | service.createPendingFromApplication(application); |
| | | |
| | | ArgumentCaptor<GuideUser> captor = ArgumentCaptor.forClass(GuideUser.class); |
| | | verify(userMapper).updateById(captor.capture()); |
| | | GuideUser reusedGuide = captor.getValue(); |
| | | assertThat(reusedGuide.getStatus()).isEqualTo(GuideUserService.STATUS_PENDING); |
| | | assertThat(reusedGuide.getAutoDisableWhitelisted()).isZero(); |
| | | assertThat(reusedGuide.getAutoDisabled()).isZero(); |
| | | ArgumentCaptor<GuideUser> updateCaptor = ArgumentCaptor.forClass(GuideUser.class); |
| | | verify(userMapper).updateById(updateCaptor.capture()); |
| | | GuideUser anonymizedGuide = updateCaptor.getValue(); |
| | | assertThat(anonymizedGuide.getStatus()).isEqualTo(GuideUserService.STATUS_CANCELLED); |
| | | assertThat(anonymizedGuide.getUsername()).startsWith("deleted_").hasSize(32); |
| | | assertThat(anonymizedGuide.getMobile()).isNull(); |
| | | assertThat(anonymizedGuide.getCertificateNo()).isNull(); |
| | | assertThat(anonymizedGuide.getIdCardNo()).isNull(); |
| | | |
| | | ArgumentCaptor<GuideUser> insertCaptor = ArgumentCaptor.forClass(GuideUser.class); |
| | | verify(userMapper).insert(insertCaptor.capture()); |
| | | GuideUser newGuide = insertCaptor.getValue(); |
| | | assertThat(newGuide.getStatus()).isEqualTo(GuideUserService.STATUS_PENDING); |
| | | assertThat(newGuide.getUsername()).isEqualTo("13800138000"); |
| | | assertThat(newGuide.getMobile()).isEqualTo("13800138000"); |
| | | assertThat(newGuide.getAutoDisableWhitelisted()).isNull(); |
| | | assertThat(newGuide.getAutoDisabled()).isNull(); |
| | | } |
| | | |
| | | @Test |