diff options
author | Zipeng WU <zipeng.wu@sonarsource.com> | 2022-07-06 18:17:49 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-07-07 20:03:10 +0000 |
commit | 13af94da0237ede39c11bfe33e6f1ac89aeff495 (patch) | |
tree | 7fc852e2ae4086eee92a0099b22e79c4853f6b10 /server/sonar-webserver-auth | |
parent | 6354fe3096b07caf9eb017ab7b4e0565f6d303fc (diff) | |
download | sonarqube-13af94da0237ede39c11bfe33e6f1ac89aeff495.tar.gz sonarqube-13af94da0237ede39c11bfe33e6f1ac89aeff495.zip |
SONAR-16567 remove confusing select method in UserTokenDao
Diffstat (limited to 'server/sonar-webserver-auth')
2 files changed, 4 insertions, 4 deletions
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSender.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSender.java index d40cdcc67dd..128fdfa754f 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSender.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSender.java @@ -45,7 +45,7 @@ public class TokenExpirationNotificationSender { } try (var dbSession = dbClient.openSession(false)) { var expiringTokens = dbClient.userTokenDao().selectTokensExpiredInDays(dbSession, 7); - var expiredTokens = dbClient.userTokenDao().selectExpiredTokens(dbSession); + var expiredTokens = dbClient.userTokenDao().selectTokensExpiredInDays(dbSession, 0); var tokensToNotify = Stream.concat(expiringTokens.stream(), expiredTokens.stream()).collect(Collectors.toList()); var usersToNotify = tokensToNotify.stream().map(UserTokenDto::getUserUuid).collect(Collectors.toSet()); Map<String, String> userUuidToEmail = dbClient.userDao().selectByUuids(dbSession, usersToNotify).stream() diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java index 39943e89735..0252a2540b6 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java @@ -34,7 +34,7 @@ import org.sonar.db.user.UserTokenDto; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -66,8 +66,8 @@ public class TokenExpirationNotificationSenderTest { var userTokenDao = mock(UserTokenDao.class); var userDao = mock(UserDao.class); when(userDao.selectByUuids(any(), any())).thenReturn(List.of(user)); - when(userTokenDao.selectTokensExpiredInDays(any(), anyLong())).thenReturn(List.of(expiringToken)); - when(userTokenDao.selectExpiredTokens(any())).thenReturn(List.of(expiredToken)); + when(userTokenDao.selectTokensExpiredInDays(any(), eq(7L))).thenReturn(List.of(expiringToken)); + when(userTokenDao.selectTokensExpiredInDays(any(), eq(0L))).thenReturn(List.of(expiredToken)); when(dbClient.userTokenDao()).thenReturn(userTokenDao); when(dbClient.userDao()).thenReturn(userDao); when(emailComposer.areEmailSettingsSet()).thenReturn(true); |