aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2022-02-25 10:19:08 +0100
committersonartech <sonartech@sonarsource.com>2022-02-25 20:02:53 +0000
commit1bab6541f5d25f1c8ca2d36ae0900bc19aae9ef0 (patch)
treeb01d50693280ff255ed87f8c56fe741230fab12b /server/sonar-process
parent0253f591bd017cb9a9c8e365fa074a7bc4b0a2a0 (diff)
downloadsonarqube-1bab6541f5d25f1c8ca2d36ae0900bc19aae9ef0.tar.gz
sonarqube-1bab6541f5d25f1c8ca2d36ae0900bc19aae9ef0.zip
SONAR-15919 Improving code quality
Diffstat (limited to 'server/sonar-process')
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
index cc3e712f63d..86418d5f637 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
@@ -21,6 +21,8 @@ package org.sonar.process.cluster.hz;
import com.hazelcast.cluster.Member;
import com.hazelcast.cluster.memberselector.MemberSelectors;
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.topic.ITopic;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.List;
@@ -34,10 +36,17 @@ import org.junit.Test;
import org.junit.rules.DisableOnDebug;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
+import org.mockito.verification.VerificationMode;
+import org.sonar.core.util.RuleActivationListener;
import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class HazelcastMemberImplTest {
@@ -106,6 +115,19 @@ public class HazelcastMemberImplTest {
assertThat(failures.get(0)).hasMessageContaining("BOOM");
}
+ @Test
+ public void subscribeRuleActivationTopic_listenerAdded() {
+ RuleActivationListener listener = mock(RuleActivationListener.class);
+ HazelcastInstance hzInstance = mock(HazelcastInstance.class);
+ ITopic<Object> topic = mock(ITopic.class);
+ when(hzInstance.getTopic(any())).thenReturn(topic);
+ HazelcastMemberImpl underTest = new HazelcastMemberImpl(hzInstance);
+
+ underTest.subscribeRuleActivationTopic(listener);
+
+ verify(topic, times(1)).addMessageListener(any());
+ }
+
private static HazelcastMember newHzMember(int port, int... otherPorts) {
return new HazelcastMemberBuilder(JoinConfigurationType.TCP_IP)
.setProcessId(ProcessId.COMPUTE_ENGINE)