summaryrefslogtreecommitdiffstats
path: root/adapters/etsi-sol002-adapter/src/test
diff options
context:
space:
mode:
authorPiotr Borelowski <p.borelowski@partner.samsung.com>2020-05-06 12:45:37 +0200
committerPiotr Borelowski <p.borelowski@partner.samsung.com>2020-05-20 12:54:25 +0200
commitb69bec9d271ecffd2b3b172219d53ffab417e253 (patch)
treed43022c36e75d9dd937cb0922fccc40fcbb634b6 /adapters/etsi-sol002-adapter/src/test
parent8f6932185e2914dff70084b76b6f9b72971089df (diff)
etsi-sol002-adapter's support for vserver
Include vserver.vserver-name in the DMaaP event Issue-ID: SO-2901 Signed-off-by: Piotr Borelowski <p.borelowski@partner.samsung.com> Change-Id: I2fa32624b9626802a8645cac0f00259bd170a9aa
Diffstat (limited to 'adapters/etsi-sol002-adapter/src/test')
-rw-r--r--adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/aai/AaiConnectionTest.java65
-rw-r--r--adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/DmaapConditionalSenderTest.java34
2 files changed, 90 insertions, 9 deletions
diff --git a/adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/aai/AaiConnectionTest.java b/adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/aai/AaiConnectionTest.java
new file mode 100644
index 0000000000..12928ae9ed
--- /dev/null
+++ b/adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/aai/AaiConnectionTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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.aai;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.onap.aai.domain.yang.RelatedToProperty;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
+
+public class AaiConnectionTest {
+
+ private static final String KEY = "key";
+ private static final String VALUE = "value";
+
+ @Test
+ public void testRelationshipData() {
+ // given
+ final Relationship relationship = new Relationship();
+ final RelationshipData data = new RelationshipData();
+ data.setRelationshipKey(KEY);
+ data.setRelationshipValue(VALUE);
+ relationship.getRelationshipData().add(data);
+
+ // when
+ final String value = AaiConnection.getRelationshipData(relationship, KEY);
+
+ // then
+ assertEquals(VALUE, value);
+ }
+
+ @Test
+ public void testRelatedToProperty() {
+ // given
+ final Relationship relationship = new Relationship();
+ final RelatedToProperty property = new RelatedToProperty();
+ property.setPropertyKey(KEY);
+ property.setPropertyValue(VALUE);
+ relationship.getRelatedToProperty().add(property);
+
+ // when
+ final String value = AaiConnection.getRelatedToProperty(relationship, KEY);
+
+ // then
+ assertEquals(VALUE, value);
+ }
+}
diff --git a/adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/DmaapConditionalSenderTest.java b/adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/DmaapConditionalSenderTest.java
index b430c2bb7a..428ccad054 100644
--- a/adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/DmaapConditionalSenderTest.java
+++ b/adapters/etsi-sol002-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/DmaapConditionalSenderTest.java
@@ -22,9 +22,7 @@ package org.onap.so.adapters.vevnfm.service;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -35,10 +33,12 @@ import org.onap.so.adapters.etsisol003adapter.lcm.lcn.model.VnfLcmOperationOccur
import org.onap.so.adapters.vevnfm.aai.AaiConnection;
import org.onap.so.adapters.vevnfm.configuration.ConfigProperties;
import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType;
+import org.onap.so.adapters.vevnfm.event.DmaapEvent;
@RunWith(MockitoJUnitRunner.class)
public class DmaapConditionalSenderTest {
+ private static final String VSERVER_NAME = "vsn";
private static final String GENERIC_ID = "gener77";
private static final String INSTANCE_ID = "insta44";
private static final String HREF = "/href";
@@ -66,6 +66,10 @@ public class DmaapConditionalSenderTest {
return notification;
}
+ private static DmaapEvent createDmaapEvent() {
+ return new DmaapEvent(null, null, null, null, null);
+ }
+
@Test
public void testSendNone() {
// given
@@ -79,41 +83,52 @@ public class DmaapConditionalSenderTest {
// then
verify(aaiConnection, never()).receiveGenericVnfId(any());
- verify(dmaapService, never()).send(any(), any());
+ verify(dmaapService, never()).createDmaapEvent(any(), any(), any());
+ verify(dmaapService, never()).send(any());
}
@Test
public void testSendAll() {
// given
+ final VnfLcmOperationOccurrenceNotification notification = createNotification();
+ final DmaapEvent dmaapEvent = createDmaapEvent();
+
when(configProperties.getNotificationVnfFilterType()).thenReturn(NotificationVnfFilterType.ALL);
when(aaiConnection.receiveGenericVnfId(eq(HREF))).thenReturn(GENERIC_ID);
+ when(aaiConnection.receiveVserverName(eq(GENERIC_ID))).thenReturn(VSERVER_NAME);
+ when(dmaapService.createDmaapEvent(eq(notification), eq(VSERVER_NAME), eq(GENERIC_ID))).thenReturn(dmaapEvent);
final DmaapConditionalSender sender = new DmaapConditionalSender(configProperties, aaiConnection, dmaapService);
- final VnfLcmOperationOccurrenceNotification notification = createNotification();
// when
sender.send(notification);
// then
verify(aaiConnection).receiveGenericVnfId(eq(HREF));
- verify(dmaapService).send(eq(notification), eq(GENERIC_ID));
+ verify(dmaapService).createDmaapEvent(eq(notification), eq(VSERVER_NAME), eq(GENERIC_ID));
+ verify(dmaapService).send(eq(dmaapEvent));
}
@Test
public void testSendAaiCheckedPresent() {
// given
+ final DmaapEvent dmaapEvent = createDmaapEvent();
+ final VnfLcmOperationOccurrenceNotification notification = createNotification();
+
when(configProperties.getNotificationVnfFilterType()).thenReturn(NotificationVnfFilterType.AAI_CHECKED);
when(aaiConnection.receiveGenericVnfId(eq(HREF))).thenReturn(GENERIC_ID);
+ when(aaiConnection.receiveVserverName(eq(GENERIC_ID))).thenReturn(VSERVER_NAME);
+ when(dmaapService.createDmaapEvent(eq(notification), eq(VSERVER_NAME), eq(GENERIC_ID))).thenReturn(dmaapEvent);
final DmaapConditionalSender sender = new DmaapConditionalSender(configProperties, aaiConnection, dmaapService);
- final VnfLcmOperationOccurrenceNotification notification = createNotification();
// when
sender.send(notification);
// then
verify(aaiConnection).receiveGenericVnfId(eq(HREF));
- verify(dmaapService).send(eq(notification), eq(GENERIC_ID));
+ verify(dmaapService).createDmaapEvent(eq(notification), eq(VSERVER_NAME), eq(GENERIC_ID));
+ verify(dmaapService).send(eq(dmaapEvent));
}
@Test
@@ -130,6 +145,7 @@ public class DmaapConditionalSenderTest {
// then
verify(aaiConnection).receiveGenericVnfId(eq(HREF));
- verify(dmaapService, never()).send(any(), any());
+ verify(dmaapService, never()).createDmaapEvent(any(), any(), any());
+ verify(dmaapService, never()).send(any());
}
}