summaryrefslogtreecommitdiffstats
path: root/common/src/test/java
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2020-02-07 17:14:39 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-02-07 17:19:04 -0500
commitd0ec4426cbe4da7dbf94a4faf6e36c032a81c395 (patch)
tree80dad5b6047dda91c0272aab40d5fc576070ac2c /common/src/test/java
parent6db24e72ecbf4f5c63085085c10dc656568b563b (diff)
Initial commit to check client alive
Initial commit to check client alive Issue-ID: SO-2653 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ib9f4cf7f5815bd9b8d0d42417f3e5fd83382547a
Diffstat (limited to 'common/src/test/java')
-rw-r--r--common/src/test/java/org/onap/so/utils/ExternalTaskServiceUtilsTest.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/common/src/test/java/org/onap/so/utils/ExternalTaskServiceUtilsTest.java b/common/src/test/java/org/onap/so/utils/ExternalTaskServiceUtilsTest.java
new file mode 100644
index 0000000000..c9fc27ebe0
--- /dev/null
+++ b/common/src/test/java/org/onap/so/utils/ExternalTaskServiceUtilsTest.java
@@ -0,0 +1,62 @@
+package org.onap.so.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import org.camunda.bpm.client.ExternalTaskClient;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.springframework.core.env.Environment;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ExternalTaskServiceUtilsTest {
+
+ @Spy
+ @InjectMocks
+ private ExternalTaskServiceUtils utils = new ExternalTaskServiceUtils();
+
+ @Mock
+ private ExternalTaskClient actualClient1;
+
+ @Mock
+ private ExternalTaskClient actualClient2;
+
+ @Mock
+ private ExternalTaskClient actualClient3;
+
+ @Mock
+ private ExternalTaskClient actualClient4;
+
+ @Test
+ public void testCheckActiveClients() throws Exception {
+ Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet();
+ taskClients.add(actualClient1);
+ taskClients.add(actualClient2);
+ taskClients.add(actualClient3);
+ taskClients.add(actualClient4);
+ when(utils.getClients()).thenReturn(taskClients);
+ when(actualClient1.isActive()).thenReturn(false);
+ when(actualClient2.isActive()).thenReturn(true);
+ when(actualClient3.isActive()).thenReturn(false);
+ when(actualClient4.isActive()).thenReturn(true);
+ utils.checkAllClientsActive();
+ verify(actualClient1, times(1)).isActive();
+ verify(actualClient2, times(1)).isActive();
+ verify(actualClient3, times(1)).isActive();
+ verify(actualClient4, times(1)).isActive();
+ verify(actualClient1, times(1)).start();
+ verify(actualClient3, times(1)).start();
+ }
+
+}