summaryrefslogtreecommitdiffstats
path: root/adapters/mso-ve-vnfm-adapter/src/test
diff options
context:
space:
mode:
authorPiotr Borelowski <p.borelowski@partner.samsung.com>2020-02-27 11:36:01 +0100
committerPiotr Borelowski <p.borelowski@partner.samsung.com>2020-02-27 15:14:54 +0100
commit052ca56869f350b77250db3505cb55f344e3980a (patch)
tree188c66aee0ce6d9afd5b0305a04604babed50d2c /adapters/mso-ve-vnfm-adapter/src/test
parent20a3f923ccc0635a2fdf99643e4680433d39977d (diff)
The Ve-Vnfm Adapter can now subscribe to multiple VNFMs
Ve-Vnfm (SOL002) Adapter project Issue-ID: SO-2574 Signed-off-by: Piotr Borelowski <p.borelowski@partner.samsung.com> Change-Id: I0418fe1fd62b9fd40d47ab90c6b31c8a5a28b793
Diffstat (limited to 'adapters/mso-ve-vnfm-adapter/src/test')
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java9
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java69
2 files changed, 75 insertions, 3 deletions
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java
index d1d34a706f..9b18cf96dc 100644
--- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java
+++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java
@@ -23,6 +23,8 @@ package org.onap.so.adapters.vevnfm.service;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.util.Collections;
+import java.util.List;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -52,14 +54,15 @@ public class StartupServiceTest {
// given
final EsrSystemInfo info = new EsrSystemInfo();
info.setServiceUrl(URL);
+ final List<EsrSystemInfo> infos = Collections.singletonList(info);
- when(aaiConnection.receiveVnfm()).thenReturn(info);
+ when(aaiConnection.receiveVnfm()).thenReturn(infos);
// when
- final EsrSystemInfo systemInfo = startupService.receiveVnfm();
+ final List<EsrSystemInfo> systemInfo = startupService.receiveVnfm();
// then
verify(aaiConnection).receiveVnfm();
- assertEquals(info, systemInfo);
+ assertEquals(infos, systemInfo);
}
}
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java
new file mode 100644
index 0000000000..d3da7c86ec
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vevnfm.service;
+
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Collections;
+import java.util.List;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SubscriptionSchedulerTest {
+
+ private static final String URL = "url";
+ private static final String ID = "id044";
+
+ @Mock
+ private SubscriberService subscriberService;
+
+ @InjectMocks
+ private SubscriptionScheduler subscriptionScheduler;
+
+ @Test
+ public void testFullScenario() throws Exception {
+ // given
+ final EsrSystemInfo info = new EsrSystemInfo();
+ info.setServiceUrl(URL);
+ final List<EsrSystemInfo> infos = Collections.singletonList(info);
+
+ when(subscriberService.subscribe(eq(info))).thenReturn(ID);
+ when(subscriberService.checkSubscription(eq(info), eq(ID))).thenReturn(false);
+
+ // when
+ subscriptionScheduler.setInfos(infos);
+ subscriptionScheduler.subscribeTask();
+ subscriptionScheduler.checkSubscribeTask();
+
+ // then
+ verify(subscriberService).subscribe(info);
+ verify(subscriberService).checkSubscription(info, ID);
+
+ assertNull(subscriptionScheduler.getEsrIds().get(0).getId());
+ }
+}