summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java7
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java8
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceProxyCustomization.java124
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/AaiEvent.java44
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java110
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java30
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java13
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java78
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json45
10 files changed, 453 insertions, 10 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java
index b1911654c4..6c1c81c6ef 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java
@@ -65,6 +65,9 @@ public class QueryServiceInfo extends CatalogQuery {
@Override
public String JSON2(boolean isArray, boolean isEmbed) {
+ if (serviceInfo == null) {
+ return "\"serviceInfo\": null";
+ }
StringBuilder sb = new StringBuilder();
sb.append("\"serviceInfo\": ");
sb.append("\n");
@@ -73,8 +76,8 @@ public class QueryServiceInfo extends CatalogQuery {
put(valueMap, "ID", null == serviceInfo ? null : serviceInfo.getId());
put(valueMap, "SERVICE_INPUT", null == serviceInfo ? null : serviceInfo.getServiceInput());
put(valueMap, "SERVICE_PROPERTIES", null == serviceInfo ? null : serviceInfo.getServiceProperties());
- // String subitem = new QueryServiceArtifact(service.getServiceArtifactList()).JSON2(true, true);
- // valueMap.put("_SERVICEARTIFACT_", subitem.replaceAll("(?m)^", "\t\t"));m
+ String subitem = new QueryServiceArtifact(service.getServiceArtifactList()).JSON2(true, true);
+ valueMap.put("_SERVICEARTIFACT_", subitem.replaceAll("(?m)^", "\t\t"));
sb.append(this.setTemplate(TEMPLATE, valueMap));
sb.append("}");
return sb.toString();
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
index 0eb7d0418e..d5aa472c8d 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
@@ -40,7 +40,7 @@ public class QueryServiceMacroHolder extends CatalogQuery {
+ "\t\"serviceType\" : <SERVICE_TYPE>,\n" + "\t\"serviceRole\" : <SERVICE_ROLE>,\n"
+ "\t\"environmentContext\" : <ENVIRONMENT_CONTEXT>,\n" + "\t\"resourceOrder\" : <RESOURCE_ORDER>,\n"
+ "\t\"workloadContext\" : <WORKLOAD_CONTEXT>,\n" + "<_SERVICEVNFS_>,\n" + "<_SERVICENETWORKS_>,\n"
- + "<_SERVICEALLOTTEDRESOURCES_>\n" + "\t}}";
+ + "<_SERVICEINFO_>,\n" + "<_SERVICEPROXY_>,\n" + "<_SERVICEALLOTTEDRESOURCES_>\n" + "\t}}";
public QueryServiceMacroHolder() {
super();
@@ -94,6 +94,12 @@ public class QueryServiceMacroHolder extends CatalogQuery {
subitem = new QueryAllottedResourceCustomization(service.getAllottedCustomizations()).JSON2(true, true);
valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll(LINE_BEGINNING, "\t"));
+ subitem = new QueryServiceInfo(serviceMacroHolder.getServiceInfo()).JSON2(true, true);
+ valueMap.put("_SERVICEINFO_", subitem.replaceAll(LINE_BEGINNING, "\t"));
+
+ subitem = new QueryServiceProxyCustomization(service.getServiceProxyCustomizations()).JSON2(true, true);
+ valueMap.put("_SERVICEPROXY_", subitem.replaceAll(LINE_BEGINNING, "\t"));
+
buf.append(this.setTemplate(TEMPLATE, valueMap));
return buf.toString();
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceProxyCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceProxyCustomization.java
new file mode 100644
index 0000000000..94cf304120
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceProxyCustomization.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ * ================================================================================
+ * 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.catalogdb.catalogrest;
+
+import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@XmlRootElement(name = "serviceProxyCustomizations")
+public class QueryServiceProxyCustomization extends CatalogQuery {
+
+ protected static Logger logger = LoggerFactory.getLogger(QueryServiceProxyCustomization.class);
+
+ private List<ServiceProxyResourceCustomization> serviceProxyResourceCustomizationList;
+
+ private static final String TEMPLATE =
+ "\t{\n" + "\t\t\"modelInfo\" : {\n" + "\t\t\t\"modelName\" : <MODEL_NAME>,\n"
+ + "\t\t\t\"modelUuid\" : <MODEL_UUID>,\n"
+ + "\t\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_UUID>,\n"
+ + "\t\t\t\"modelVersion\" : <MODEL_VERSION>,\n"
+ + "\t\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"
+ + "\t\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>\n" + "\t},\n"
+ + "\t\t\"toscaNodeType\" : <TOSCA_NODE_TYPE>,\n"
+ + "\t\t\"description\" : <DESCRIPTION>,\n"
+ + "\t\t\"sourceModelUuid\" : <SOURCE_SERVICE_MODEL_UUID>\n" + "\t}";
+
+ public QueryServiceProxyCustomization() {
+ super();
+ this.serviceProxyResourceCustomizationList = new ArrayList<>();
+ }
+
+ public QueryServiceProxyCustomization(
+ List<ServiceProxyResourceCustomization> serviceProxyResourceCustomizationList) {
+ this.serviceProxyResourceCustomizationList = serviceProxyResourceCustomizationList;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ boolean first = true;
+ int i = 1;
+ for (ServiceProxyResourceCustomization o : serviceProxyResourceCustomizationList) {
+ sb.append(i).append("\t");
+ if (!first)
+ sb.append("\n");
+
+ first = false;
+ sb.append(o);
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray)
+ sb.append("{ ");
+ if (isArray)
+ sb.append("\"serviceProxy\": [");
+ Map<String, String> valueMap = new HashMap<>();
+ String sep = "";
+ boolean first = true;
+
+ if (this.serviceProxyResourceCustomizationList != null) {
+ for (ServiceProxyResourceCustomization o : serviceProxyResourceCustomizationList) {
+ if (first)
+ sb.append("\n");
+
+ first = false;
+
+ boolean arNull = o == null;
+
+ put(valueMap, "MODEL_CUSTOMIZATION_UUID", arNull ? null : o.getModelCustomizationUUID());
+ put(valueMap, "MODEL_INSTANCE_NAME", arNull ? null : o.getModelInstanceName());
+ put(valueMap, "MODEL_UUID", arNull ? null : o.getModelUUID());
+ put(valueMap, "MODEL_INVARIANT_UUID", arNull ? null : o.getModelInvariantUUID());
+ put(valueMap, "MODEL_VERSION", arNull ? null : o.getModelVersion());
+ put(valueMap, "MODEL_NAME", arNull ? null : o.getModelName());
+ put(valueMap, "TOSCA_NODE_TYPE", arNull ? null : o.getToscaNodeType());
+ put(valueMap, "DESCRIPTION", arNull ? null : o.getDescription());
+ put(valueMap, "SOURCE_SERVICE_MODEL_UUID", (String) (arNull ? null
+ : o.getSourceService() == null ? null : o.getSourceService().getModelUUID()));
+
+ sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
+ sep = ",\n";
+ }
+ }
+ if (!first)
+ sb.append("\n");
+
+ if (isArray)
+ sb.append("]");
+
+ if (!isEmbed && isArray)
+ sb.append("}");
+
+ return sb.toString();
+ }
+
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/AaiEvent.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/AaiEvent.java
new file mode 100644
index 0000000000..ceabb8a020
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/AaiEvent.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.event;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AaiEvent {
+
+ private final boolean vserverIsClosedLoopDisabled;
+ private final String genericVnfVnfId;
+
+ public AaiEvent(final boolean cld, final String id) {
+ this.vserverIsClosedLoopDisabled = cld;
+ this.genericVnfVnfId = id;
+ }
+
+ @JsonProperty("vserver.is-closed-loop-disabled")
+ public boolean isVserverIsClosedLoopDisabled() {
+ return vserverIsClosedLoopDisabled;
+ }
+
+ @JsonProperty("generic-vnf.vnf-id")
+ public String getGenericVnfVnfId() {
+ return genericVnfVnfId;
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java
new file mode 100644
index 0000000000..dc0c5502dd
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java
@@ -0,0 +1,110 @@
+/*-
+ * ============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.event;
+
+import static java.time.temporal.ChronoField.INSTANT_SECONDS;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.time.Instant;
+import java.util.UUID;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification;
+
+public class DmaapEvent {
+
+ public static final String MSERVICE = "microservice.stringmatcher";
+ public static final String ONSET = "ONSET";
+ public static final String VNF = "VNF";
+ public static final String VNFID = "generic-vnf.vnf-id";
+ public static final String ETSI = "ETSI";
+
+ private final String closedLoopControlName;
+ private final long closedLoopAlarmStart;
+ private final String closedLoopEventClient;
+ private final String closedLoopEventStatus;
+ private final String requestId;
+ private final String targetType;
+ private final String target;
+ private final AaiEvent aaiEvent;
+ private final String from;
+ private final String version;
+ private final VnfLcmOperationOccurrenceNotification etsiLcmEvent;
+
+ public DmaapEvent(final String closedLoopControlName, final String version,
+ final VnfLcmOperationOccurrenceNotification etsiLcmEvent) {
+ this.closedLoopControlName = closedLoopControlName;
+ this.closedLoopAlarmStart = Instant.now().getLong(INSTANT_SECONDS);
+ this.closedLoopEventClient = MSERVICE;
+ this.closedLoopEventStatus = ONSET;
+ this.requestId = UUID.randomUUID().toString();
+ this.targetType = VNF;
+ this.target = VNFID;
+ this.aaiEvent = new AaiEvent(false, etsiLcmEvent.getId());
+ this.from = ETSI;
+ this.version = version;
+ this.etsiLcmEvent = etsiLcmEvent;
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public long getClosedLoopAlarmStart() {
+ return closedLoopAlarmStart;
+ }
+
+ public String getClosedLoopEventClient() {
+ return closedLoopEventClient;
+ }
+
+ public String getClosedLoopEventStatus() {
+ return closedLoopEventStatus;
+ }
+
+ @JsonProperty("requestID")
+ public String getRequestId() {
+ return requestId;
+ }
+
+ @JsonProperty("target_type")
+ public String getTargetType() {
+ return targetType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ @JsonProperty("AAI")
+ public AaiEvent getAaiEvent() {
+ return aaiEvent;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public VnfLcmOperationOccurrenceNotification getEtsiLcmEvent() {
+ return etsiLcmEvent;
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java
index 36a4c3300d..c685ae815a 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java
@@ -1,5 +1,26 @@
+/*-
+ * ============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 org.onap.so.adapters.vevnfm.event.DmaapEvent;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.slf4j.Logger;
@@ -21,12 +42,19 @@ public class DmaapService {
@Value("${dmaap.topic}")
private String topic;
+ @Value("${dmaap.closed-loop.control.name}")
+ private String closedLoopControlName;
+
+ @Value("${dmaap.version}")
+ private String version;
+
@Autowired
private HttpRestServiceProvider restProvider;
public void send(final VnfLcmOperationOccurrenceNotification notification) {
try {
- final ResponseEntity<String> response = restProvider.postHttpRequest(notification, getUrl(), String.class);
+ final DmaapEvent event = new DmaapEvent(closedLoopControlName, version, notification);
+ final ResponseEntity<String> response = restProvider.postHttpRequest(event, getUrl(), String.class);
final HttpStatus statusCode = response.getStatusCode();
final String body = response.getBody();
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
index 72198b83c1..a2a33bfb5c 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
@@ -35,6 +35,10 @@ vnfm:
dmaap:
endpoint: http://message-router.onap:30227
topic: /events/unauthenticated.DCAE_CL_OUTPUT
+ closed-loop:
+ control:
+ name: ClosedLoopControlName
+ version: 1.0.2
spring:
security:
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java
index d0fd4c9e7c..6d566c07ad 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java
@@ -50,7 +50,7 @@ public class PkgmSubscriptionRequestConverter implements
@Override
public org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest convert(
- PkgmSubscriptionRequest pkgmSubscriptionRequest) {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest) {
final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest =
new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest();
@@ -86,8 +86,10 @@ public class PkgmSubscriptionRequestConverter implements
return etsiCatalogManagerFilters;
}
- // TODO 'operationalState' in the Sol003 Swagger is type 'OperationalStateEnum'. The ETSI Catalog Manager Swagger
- // 'operationalState' is type 'List<OperationalStateEnum>'. This method needs to be updated once swagger is updated.
+ // TODO 'operationalState' in the Sol003 Swagger is type 'OperationalStateEnum'. The ETSI
+ // Catalog Manager Swagger
+ // 'operationalState' is type 'List<OperationalStateEnum>'. This method needs to be updated once
+ // swagger is updated.
private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> getOperationalState(
final OperationalStateEnum operationalState) {
if (operationalState != null) {
@@ -104,6 +106,7 @@ public class PkgmSubscriptionRequestConverter implements
vnfPkgId.forEach(type -> {
etsiCatalogManagerVnfPkgId.add(type);
});
+ return etsiCatalogManagerVnfPkgId;
}
return Collections.emptyList();
}
@@ -114,6 +117,7 @@ public class PkgmSubscriptionRequestConverter implements
vnfdId.forEach(type -> {
etsiCatalogManagerVnfdId.add(type);
});
+ return etsiCatalogManagerVnfdId;
}
return Collections.emptyList();
}
@@ -147,7 +151,7 @@ public class PkgmSubscriptionRequestConverter implements
private List<Version> getVersion(final List<SubscriptionsFilterVersions> sol003FilterVersions) {
if (sol003FilterVersions != null && !sol003FilterVersions.isEmpty()) {
- List<Version> etsiCatalogVersionList = new ArrayList<>();
+ final List<Version> etsiCatalogVersionList = new ArrayList<>();
sol003FilterVersions.forEach(vnfFilterVersion -> {
etsiCatalogVersionList.add(new Version().vnfSoftwareVersion(vnfFilterVersion.getVnfSoftwareVersion())
.vnfdVersions(vnfFilterVersion.getVnfdVersions()));
@@ -166,6 +170,7 @@ public class PkgmSubscriptionRequestConverter implements
notificationTypes.forEach(type -> etsiCatalogManagerNotificationTypes.add(
org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum
.fromValue(type.getValue())));
+ return etsiCatalogManagerNotificationTypes;
}
return Collections.emptyList();
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java
index ba1bf71936..7466895d97 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java
@@ -26,28 +26,38 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.vnfmadapter.Constants;
import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.LinkSelf;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
@@ -59,6 +69,8 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.http.HttpHeaders;
@@ -69,6 +81,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.test.web.client.match.MockRestRequestMatchers;
import org.springframework.web.client.RestTemplate;
import com.google.gson.Gson;
@@ -83,6 +96,10 @@ public class Sol003PackageManagementSubscriptionControllerTest {
private final Gson gson = new Gson();
private final URI msbEndpoint = URI.create("http://msb-iag.onap:80/api/vnfpkgm/v1/subscriptions");
+ private static final String _NOTIFICATION_CALLBACK_URI =
+ "https://so-vnfm-adapter.onap:30406" + Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL;
+ private static final String LOCALHOST_URL = "http://localhost:";
+
@Autowired
@Qualifier(CONFIGURABLE_REST_TEMPLATE)
private RestTemplate restTemplate;
@@ -92,6 +109,12 @@ public class Sol003PackageManagementSubscriptionControllerTest {
@Autowired
private Sol003PackageManagementSubscriptionController sol003PackageManagementSubscriptionController;
+ @Autowired
+ private TestRestTemplate testRestTemplate;
+
+ @LocalServerPort
+ private int port;
+
private static final String ID = UUID.randomUUID().toString();
@Before
@@ -101,6 +124,11 @@ public class Sol003PackageManagementSubscriptionControllerTest {
cache.clear();
}
+ @After
+ public void after() {
+ mockRestServiceServer.reset();
+ }
+
@Test
public void testSuccessPostSubscription() throws GeneralSecurityException, URISyntaxException {
final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest();
@@ -269,6 +297,47 @@ public class Sol003PackageManagementSubscriptionControllerTest {
assertEquals(HttpStatus.NOT_FOUND, responseDelete.getStatusCode());
}
+
+ @Test
+ public void testSuccessPostSubscriptionWithValidNotificationTypes() throws Exception {
+
+ final String file = getAbsolutePath("src/test/resources/requests/SubscriptionRequest.json");
+ final String json = new String(Files.readAllBytes(Paths.get(file)));
+ final PkgmSubscriptionRequest request = gson.fromJson(json, PkgmSubscriptionRequest.class);
+
+ mockRestServiceServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
+ .andExpect(MockRestRequestMatchers.content().json(gson.toJson(getEtsiCatalogPkgmSubscriptionRequest())))
+ .andRespond(withSuccess(gson.toJson(buildPkgmSubscription()), MediaType.APPLICATION_JSON));
+
+
+ final ResponseEntity<InlineResponse2002> responseEntity = testRestTemplate.postForEntity(
+ LOCALHOST_URL + port + Constants.PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions", request,
+ InlineResponse2002.class);
+
+ assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
+ assertTrue(responseEntity.hasBody());
+ final InlineResponse2002 actual = responseEntity.getBody();
+ assertEquals(ID, actual.getId());
+
+
+ }
+
+ private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest getEtsiCatalogPkgmSubscriptionRequest() {
+ return new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest()
+ .filters(new PkgmNotificationsFilter()
+ .addNotificationTypesItem(
+ PkgmNotificationsFilter.NotificationTypesEnum.VNFPACKAGEONBOARDINGNOTIFICATION)
+ .addVnfdIdItem("VNFDID").addVnfPkgIdItem("VNFPKGID")
+ .addOperationalStateItem(PkgmNotificationsFilter.OperationalStateEnum.ENABLED)
+ .addVnfProductsFromProvidersItem(new VnfProductsProviders().vnfProvider("EST")
+ .addVnfProductsItem(new VnfProducts().vnfProductName("VnfProducts")
+ .addVersionsItem(new Version().vnfSoftwareVersion("vnfSoftwareVersion")
+ .addVnfdVersionsItem("version1")))))
+ .callbackUri(_NOTIFICATION_CALLBACK_URI).authentication(
+ new SubscriptionAuthentication().addAuthTypeItem(SubscriptionAuthentication.AuthTypeEnum.BASIC)
+ .paramsBasic(new BasicAuth().userName("vnfm").password("password1$")));
+ }
+
private PkgmSubscriptionRequest buildPkgmSubscriptionRequest() {
final PkgmSubscriptionRequest pkgmSubscriptionRequest = new PkgmSubscriptionRequest();
final SubscriptionsFilter sub = buildSubscriptionsFilter();
@@ -281,8 +350,8 @@ public class Sol003PackageManagementSubscriptionControllerTest {
private SubscriptionsFilter buildSubscriptionsFilter() {
final SubscriptionsFilter sub = new SubscriptionsFilter();
- final List<String> vnfdIdList = new ArrayList();
- final List<String> vnfPkgIdList = new ArrayList();
+ final List<String> vnfdIdList = new ArrayList<>();
+ final List<String> vnfPkgIdList = new ArrayList<>();
final List<NotificationTypesEnum> notificationTypes = new ArrayList<>();
final SubscriptionsFilterVnfProductsFromProviders subscriptionsFilterVnfProductsFromProviders =
new SubscriptionsFilterVnfProductsFromProviders();
@@ -324,4 +393,9 @@ public class Sol003PackageManagementSubscriptionControllerTest {
return headers;
}
+ private String getAbsolutePath(final String path) {
+ final File file = new File(path);
+ return file.getAbsolutePath();
+ }
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json
new file mode 100644
index 0000000000..85ffb99d8d
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json
@@ -0,0 +1,45 @@
+{
+ "filter":
+ {
+ "notificationTypes": [
+ "VnfPackageOnboardingNotification"
+ ],
+ "vnfProductsFromProviders": [
+ {
+ "vnfProvider": "EST",
+ "vnfProducts": [
+ {
+ "vnfProductName": "VnfProducts",
+ "versions": [
+ {
+ "vnfSoftwareVersion": "vnfSoftwareVersion",
+ "vnfdVersions": [
+ "version1"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "vnfdId": [
+ "VNFDID"
+ ],
+ "vnfPkgId": [
+ "VNFPKGID"
+ ],
+ "operationalState": "ENABLED"
+ },
+ "callbackUri": "http://so-vnfm-adapter:9093/api/vnfpkgm/v1/subscriptions",
+ "authentication":
+ {
+ "authType": [
+ "BASIC"
+ ],
+ "paramsBasic":
+ {
+ "userName": "vnfm",
+ "password": "vnfm"
+ }
+ }
+}