use of io.gravitee.rest.api.model.audit.AuditEntity in project gravitee-management-rest-api by gravitee-io.
the class UserServiceTest method shouldNotResetPassword_AlreadyReset.
@Test(expected = PasswordAlreadyResetException.class)
public void shouldNotResetPassword_AlreadyReset() throws TechnicalException {
when(user.getId()).thenReturn(USER_NAME);
when(user.getSource()).thenReturn("gravitee");
when(userRepository.findById(USER_NAME)).thenReturn(of(user));
MetadataPage mdPage = mock(MetadataPage.class);
AuditEntity entity1 = new AuditEntity();
entity1.setProperties(Collections.singletonMap("USER", USER_NAME));
when(mdPage.getContent()).thenReturn(Arrays.asList(entity1));
when(auditService.search(argThat(arg -> arg.getEvents().contains(User.AuditEvent.PASSWORD_RESET.name())))).thenReturn(mdPage);
userService.resetPassword(USER_NAME);
verify(user, never()).setPassword(null);
verify(userRepository, never()).update(user);
verify(emailService, never()).sendAsyncEmailNotification(any(), any());
}
Aggregations