import reactor.test.StepVerifier;
@ExtendWith(MockitoExtension.class)
-public class LockTest {
+class LockTest {
- @SuppressWarnings("squid:S2276") // Remove this use of "Thread.sleep()".
+ @SuppressWarnings("squid:S2925") // "Thread.sleep" should not be used in tests.
private void sleep() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
+ // Do nothing.
}
}
private void asynchUnlock(Lock lock) {
- Thread t = new Thread(() -> {
+ Thread thread = new Thread(() -> {
sleep();
lock.unlockBlocking();
});
- t.start();
+ thread.start();
}
@Test
- public void testLock() throws IOException, ServiceException {
+ void testLock() throws IOException, ServiceException {
Lock lock = new Lock();
lock.lockBlocking(LockType.SHARED);
lock.unlockBlocking();
lock.lockBlocking(LockType.SHARED);
lock.unlockBlocking();
- assertThat(lock.getLockCounter()).isEqualTo(0);
+ assertThat(lock.getLockCounter()).isZero();
}
@Test
- public void testReactiveLock() {
+ void testReactiveLock() {
Lock lock = new Lock();
Mono<Lock> seq = lock.lock(LockType.EXCLUSIVE) //
.expectNext(lock) //
.verifyComplete();
- assertThat(lock.getLockCounter()).isEqualTo(0);
+ assertThat(lock.getLockCounter()).isZero();
}