| | |
| | | |
| | | import java.time.Duration; |
| | | |
| | | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | | import static org.mockito.ArgumentMatchers.any; |
| | | import static org.mockito.ArgumentMatchers.eq; |
| | | import static org.mockito.Mockito.mock; |
| | |
| | | void shouldRejectInvalidCode() { |
| | | when(valueOperations.get(any())).thenReturn("123456"); |
| | | |
| | | assertThatThrownBy(() -> service.verifyAndConsume("13800138000", "000000")) |
| | | Throwable error = org.assertj.core.api.Assertions.catchThrowable( |
| | | () -> service.verifyAndConsume("13800138000", "000000")); |
| | | assertThat(error) |
| | | .isInstanceOf(BusinessException.class) |
| | | .hasMessage("验证码错误或已过期"); |
| | | .hasMessage("验证码错误或已过期") |
| | | .extracting("code") |
| | | .isEqualTo(400); |
| | | } |
| | | } |