diff options
author | Wojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com> | 2023-05-01 11:03:12 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-05-11 20:03:13 +0000 |
commit | 386525f61457626ba140cd9035da901c4918f6fd (patch) | |
tree | 01126a5c29fab5dbef9e82adf79e12011cf5164c /server/sonar-webserver-api | |
parent | 0dae9f52bb7c2d297f771de8f46ff8b1740b1879 (diff) | |
download | sonarqube-386525f61457626ba140cd9035da901c4918f6fd.tar.gz sonarqube-386525f61457626ba140cd9035da901c4918f6fd.zip |
SONAR-19084 Add step to deactivate removed users.
Diffstat (limited to 'server/sonar-webserver-api')
-rw-r--r-- | server/sonar-webserver-api/src/test/java/org/sonar/server/util/GlobalLockManagerImplTest.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/util/GlobalLockManagerImplTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/util/GlobalLockManagerImplTest.java index 13cd0d8b8b3..100b4c49144 100644 --- a/server/sonar-webserver-api/src/test/java/org/sonar/server/util/GlobalLockManagerImplTest.java +++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/util/GlobalLockManagerImplTest.java @@ -34,17 +34,18 @@ import org.sonar.db.property.InternalPropertiesDao; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +import static org.sonar.db.property.InternalPropertiesDao.LOCK_NAME_MAX_LENGTH; import static org.sonar.server.util.GlobalLockManager.DEFAULT_LOCK_DURATION_SECONDS; @RunWith(DataProviderRunner.class) public class GlobalLockManagerImplTest { - private static final int LOCK_NAME_MAX_LENGTH = 15; private final DbClient dbClient = mock(DbClient.class); private final InternalPropertiesDao internalPropertiesDao = mock(InternalPropertiesDao.class); private final DbSession dbSession = mock(DbSession.class); @@ -64,16 +65,17 @@ public class GlobalLockManagerImplTest { } @Test - public void tryLock_fails_with_IAE_if_name_length_is_16_or_more() { + public void tryLock_fails_with_IAE_if_name_length_is_more_than_max_or_more() { String badLockName = RandomStringUtils.random(LOCK_NAME_MAX_LENGTH + 1 + new Random().nextInt(96)); expectBadLockNameIAE(() -> underTest.tryLock(badLockName), badLockName); } @Test - public void tryLock_accepts_name_with_length_15_or_less() { + public void tryLock_accepts_name_with_allowed_length() { for (int i = 1; i <= LOCK_NAME_MAX_LENGTH; i++) { - underTest.tryLock(RandomStringUtils.random(i)); + String lockName = RandomStringUtils.random(i); + assertThatNoException().isThrownBy(() -> underTest.tryLock(lockName)); } } @@ -110,7 +112,7 @@ public class GlobalLockManagerImplTest { @Test @UseDataProvider("randomValidDuration") - public void tryLock_with_duration_fails_with_IAE_if_name_length_is_16_or_more(int randomValidDuration) { + public void tryLock_with_duration_fails_with_IAE_if_name_length_is_36_or_more(int randomValidDuration) { String badLockName = RandomStringUtils.random(LOCK_NAME_MAX_LENGTH + 1 + new Random().nextInt(65)); expectBadLockNameIAE(() -> underTest.tryLock(badLockName, randomValidDuration), badLockName); @@ -119,7 +121,7 @@ public class GlobalLockManagerImplTest { @Test @UseDataProvider("randomValidLockName") public void tryLock_with_duration_fails_with_IAE_if_duration_is_0(String randomValidLockName) { - expectBadDuration(() -> underTest.tryLock(randomValidLockName, 0),0); + expectBadDuration(() -> underTest.tryLock(randomValidLockName, 0), 0); } @Test @@ -156,7 +158,7 @@ public class GlobalLockManagerImplTest { @DataProvider public static Object[][] randomValidDuration() { return new Object[][] { - {1+ new Random().nextInt(2_00)} + {1 + new Random().nextInt(2_00)} }; } |