summaryrefslogtreecommitdiffstats
path: root/nokia
diff options
context:
space:
mode:
Diffstat (limited to 'nokia')
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml108
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/AaiVnfmInfo.java80
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/entity/EsrSystemInfo.java187
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java74
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java26
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java10
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java145
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java26
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java168
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java81
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java13
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java52
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java28
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java113
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java109
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java3
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java48
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java2
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java51
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/inf/VnfContinueProcessorInf.java30
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties21
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java208
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java35
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java113
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java54
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java72
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vfcadaptor/VfcadaptorApplicationTests.java7
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverControllerTest.java283
28 files changed, 1915 insertions, 232 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml
index e6ada4e0..827af562 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml
@@ -34,8 +34,12 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
+ <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+ <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+ <sonar.jacoco.itReportPath>${project.basedir}/target/jacoco.exec</sonar.jacoco.itReportPath>
+ <sonar.language>java</sonar.language>
</properties>
-
+
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -61,7 +65,18 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
-
+<!--
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-log4j2</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@@ -108,7 +123,60 @@
</dependency>
</dependencies>
<build>
+ <!--
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.7.9</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+-->
<plugins>
+ <!--
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <includes>org.onap.vfc.nfvo.driver.vnfm.svnfm.*</includes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>default-prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-report</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-prepare-agent-integration</id>
+ <goals>
+ <goal>prepare-agent-integration</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-check</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-report-integration</id>
+ <goals>
+ <goal>report-integration</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -123,6 +191,42 @@
<target>1.8</target>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <!--
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-integration-test</id>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ -->
</plugins>
</build>
+ <!--
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>report</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ -->
</project>
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/AaiVnfmInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/AaiVnfmInfo.java
new file mode 100644
index 00000000..0d75003b
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/AaiVnfmInfo.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo;
+
+import java.util.List;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.entity.EsrSystemInfo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AaiVnfmInfo {
+ @JsonProperty("vnfm-id")
+ private String vnfmId;
+
+ @JsonProperty("vim-id")
+ private String vimId;
+
+ @JsonProperty("certificate-url")
+ private String certificateUrl;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("esr-system-info-list")
+ private List<EsrSystemInfo> esrSystemInfoList;
+
+ public String getVnfmId() {
+ return vnfmId;
+ }
+
+ public void setVnfmId(String vnfmId) {
+ this.vnfmId = vnfmId;
+ }
+
+ public String getVimId() {
+ return vimId;
+ }
+
+ public void setVimId(String vimId) {
+ this.vimId = vimId;
+ }
+
+ public String getCertificateUrl() {
+ return certificateUrl;
+ }
+
+ public void setCertificateUrl(String certificateUrl) {
+ this.certificateUrl = certificateUrl;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public List<EsrSystemInfo> getEsrSystemInfoList() {
+ return esrSystemInfoList;
+ }
+
+ public void setEsrSystemInfoList(List<EsrSystemInfo> esrSystemInfoList) {
+ this.esrSystemInfoList = esrSystemInfoList;
+ }
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/entity/EsrSystemInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/entity/EsrSystemInfo.java
new file mode 100644
index 00000000..75e0e7fa
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/entity/EsrSystemInfo.java
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class EsrSystemInfo {
+ @JsonProperty("esr-system-info-id")
+ private String esrSystemId;
+
+ @JsonProperty("system-name")
+ private String esrSystemName;
+
+ @JsonProperty("type")
+ private String type;
+
+ @JsonProperty("vendor")
+ private String vendor;
+
+ @JsonProperty("version")
+ private String version;
+
+ @JsonProperty("service-url")
+ private String serviceUrl;
+
+ @JsonProperty("user-name")
+ private String userName;
+
+ @JsonProperty("password")
+ private String password;
+
+ @JsonProperty("protocal")
+ private String protocal;
+
+ @JsonProperty("ssl-cacert")
+ private String sslCacert;
+
+ @JsonProperty("ssl-insecure")
+ private String sslInsecure;
+
+ @JsonProperty("ip-address")
+ private String ip;
+
+ @JsonProperty("port")
+ private String port;
+
+ @JsonProperty("cloud-domain")
+ private String cloudDomain;
+
+ @JsonProperty("default-tenant")
+ private String defaultTenant;
+
+ public String getEsrSystemId() {
+ return esrSystemId;
+ }
+
+ public void setEsrSystemId(String esrSystemId) {
+ this.esrSystemId = esrSystemId;
+ }
+
+ public String getEsrSystemName() {
+ return esrSystemName;
+ }
+
+ public void setEsrSystemName(String esrSystemName) {
+ this.esrSystemName = esrSystemName;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(String vendor) {
+ this.vendor = vendor;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getServiceUrl() {
+ return serviceUrl;
+ }
+
+ public void setServiceUrl(String serviceUrl) {
+ this.serviceUrl = serviceUrl;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getProtocal() {
+ return protocal;
+ }
+
+ public void setProtocal(String protocal) {
+ this.protocal = protocal;
+ }
+
+ public String getSslCacert() {
+ return sslCacert;
+ }
+
+ public void setSslCacert(String sslCacert) {
+ this.sslCacert = sslCacert;
+ }
+
+ public String getSslInsecure() {
+ return sslInsecure;
+ }
+
+ public void setSslInsecure(String sslInsecure) {
+ this.sslInsecure = sslInsecure;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getCloudDomain() {
+ return cloudDomain;
+ }
+
+ public void setCloudDomain(String cloudDomain) {
+ this.cloudDomain = cloudDomain;
+ }
+
+ public String getDefaultTenant() {
+ return defaultTenant;
+ }
+
+ public void setDefaultTenant(String defaultTenant) {
+ this.defaultTenant = defaultTenant;
+ }
+
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java
new file mode 100644
index 00000000..caec85da
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.impl;
+
+import java.io.IOException;
+
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.inf.AaiMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import com.google.gson.Gson;
+
+@Component
+public class AaiMgmrInfImpl implements AaiMgmrInf{
+ private static final Logger logger = LoggerFactory.getLogger(AaiMgmrInfImpl.class);
+
+ @Autowired
+ private AdaptorEnv adaptorEnv;
+
+ @Autowired
+ private HttpClientBuilder httpClientBuilder;
+
+ private Gson gson = new Gson();
+ @Override
+ public AaiVnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException {
+ String httpPath = String.format(CommonConstants.RetrieveVnfmListPath, vnfmId);
+ RequestMethod method = RequestMethod.GET;
+
+ String responseStr = operateHttpTask(null, httpPath, method);
+
+ logger.info("AaiMgmrInfImpl->queryVnfm, the vnfmInfo is {}", responseStr);
+
+ AaiVnfmInfo response = gson.fromJson(responseStr, AaiVnfmInfo.class);
+
+ return response;
+ }
+
+ private String operateHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException {
+ String url=adaptorEnv.getAaiApiUriFront() + httpPath;
+ HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, method);
+ processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
+
+ processor.addPostEntity(gson.toJson(httpBodyObj));
+
+ String responseStr = processor.process(url);
+
+ return responseStr;
+ }
+
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java
new file mode 100644
index 00000000..c81496dc
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.inf;
+
+import java.io.IOException;
+
+import org.apache.http.client.ClientProtocolException;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo;
+
+public interface AaiMgmrInf {
+ public AaiVnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException;
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java
index 33d34d0f..b79104f9 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java
@@ -46,15 +46,7 @@ public class Cbam2DriverResponseConverter {
@Autowired
private VnfmJobExecutionRepository jobDbManager;
- public InstantiateVnfResponse createRspConvert(CBAMCreateVnfResponse cbamResponse) {
-
- VnfmJobExecutionInfo jobInfo = new VnfmJobExecutionInfo();
- jobInfo.setVnfInstanceId(cbamResponse.getId());
- jobInfo.setVnfmInterfceName(CommonConstants.NSLCM_OPERATION_INSTANTIATE);
- jobInfo.setStatus(CommonConstants.CBAM_OPERATION_STATUS_START);
-
- VnfmJobExecutionInfo jobInfo1 = (VnfmJobExecutionInfo) jobDbManager.save(jobInfo);
- Long jobId = jobInfo1.getJobId();
+ public InstantiateVnfResponse createRspConvert(CBAMCreateVnfResponse cbamResponse, Long jobId) {
InstantiateVnfResponse response = new InstantiateVnfResponse();
response.setJobId(jobId.longValue() + "");
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java
index 59fad026..10802c87 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java
@@ -16,9 +16,13 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor;
+import java.io.IOException;
+
import org.apache.http.HttpStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.http.client.ClientProtocolException;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.entity.EsrSystemInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.inf.AaiMgmrInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse;
@@ -29,11 +33,11 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository.VnfmJobExecutionRepository;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.VnfmInfo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfResponse;
@@ -45,10 +49,15 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfContinueProcessorInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfmDriverMgmrInf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.google.gson.Gson;
+
@Component
public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
@@ -70,28 +79,32 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
private NslcmMgmrInf nslcmMgmr;
@Autowired
+ private AaiMgmrInf aaiMgmr;
+
+ @Autowired
private VnfmJobExecutionRepository jobDbManager;
+ @Autowired
+ AdaptorEnv adaptorEnv;
+
+ @Autowired
+ private VnfContinueProcessorInf vnfContinueProcessorInf;
+
+ private Gson gson = new Gson();
+
public InstantiateVnfResponse instantiateVnf(InstantiateVnfRequest driverRequest, String vnfmId) throws VnfmDriverException {
InstantiateVnfResponse driverResponse;
try {
- //step 1: query vnfm info
- VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId);
-
- if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId()))
- {
- throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
- }
+ buildVnfmHttpPathById(vnfmId);
//step 3: create vnf
CBAMCreateVnfRequest cbamRequest = requestConverter.createReqConvert(driverRequest);
CBAMCreateVnfResponse cbamResponse = cbamMgmr.createVnf(cbamRequest);
- driverResponse = responseConverter.createRspConvert(cbamResponse);
-
- String vnfInstanceId = driverResponse.getVnfInstanceId();
- String jobId = driverResponse.getJobId();
- continueInstantiateVnf(driverRequest, vnfInstanceId, jobId);
+ String vnfInstanceId = cbamResponse.getId();
+ Long jobId = saveCreateVnfJob(vnfInstanceId);
+ driverResponse = responseConverter.createRspConvert(cbamResponse, jobId);
+ vnfContinueProcessorInf.continueInstantiateVnf(driverRequest, vnfInstanceId, jobId.toString(), nslcmMgmr, catalogMgmr, cbamMgmr, requestConverter, jobDbManager);
} catch (Exception e) {
throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
@@ -99,28 +112,25 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
return driverResponse;
}
+
+ private Long saveCreateVnfJob(String vnfInstanceId) {
+ VnfmJobExecutionInfo jobInfo = new VnfmJobExecutionInfo();
+ jobInfo.setVnfInstanceId(vnfInstanceId);
+ jobInfo.setVnfmInterfceName(CommonConstants.NSLCM_OPERATION_INSTANTIATE);
+ jobInfo.setStatus(CommonConstants.CBAM_OPERATION_STATUS_START);
- public void continueInstantiateVnf(InstantiateVnfRequest driverRequest, String vnfInstanceId, String jobId) {
- InstantiateVnfContinueRunnable runnable = new InstantiateVnfContinueRunnable(driverRequest, vnfInstanceId, jobId,
- nslcmMgmr, catalogMgmr, cbamMgmr, requestConverter, jobDbManager);
-
- Thread thread = new Thread(runnable);
-
- thread.run();
+ VnfmJobExecutionInfo jobInfo1 = (VnfmJobExecutionInfo) jobDbManager.save(jobInfo);
+ Long jobId = jobInfo1.getJobId();
+ return jobId;
}
public TerminateVnfResponse terminateVnf(TerminateVnfRequest driverRequest, String vnfmId, String vnfInstanceId) {
TerminateVnfResponse driverResponse;
try {
- VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId);
-
- if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId()))
- {
- throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
- }
+ buildVnfmHttpPathById(vnfmId);
driverResponse = generateTerminateVnfResponse(vnfInstanceId);
String jobId = driverResponse.getJobId();
- continueTerminateVnf(driverRequest, vnfInstanceId, jobId);
+ vnfContinueProcessorInf.continueTerminateVnf(driverRequest, vnfInstanceId, jobId, nslcmMgmr, cbamMgmr, requestConverter, jobDbManager);
} catch (Exception e) {
throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
@@ -143,26 +153,10 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
return response;
}
- public void continueTerminateVnf(TerminateVnfRequest driverRequest, String vnfInstanceId, String jobId) {
- TerminateVnfContinueRunnable runnable = new TerminateVnfContinueRunnable(driverRequest, vnfInstanceId, jobId,
- nslcmMgmr, cbamMgmr, requestConverter, jobDbManager);
-
- Thread thread = new Thread(runnable);
-
- thread.run();
- }
-
-
public QueryVnfResponse queryVnf(String vnfmId, String vnfInstanceId) {
QueryVnfResponse driverResponse;
try {
- nslcmMgmr.queryVnfm(vnfmId);
- VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId);
-
- if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId()))
- {
- throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
- }
+ buildVnfmHttpPathById(vnfmId);
CBAMQueryVnfResponse cbamResponse = cbamMgmr.queryVnf(vnfInstanceId);
driverResponse = responseConverter.queryRspConvert(cbamResponse);
} catch (Exception e) {
@@ -173,24 +167,14 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
}
public OperStatusVnfResponse getOperStatus(String vnfmId, String jobId) throws VnfmDriverException {
- VnfmInfo vnfmInfo;
- try {
- vnfmInfo = nslcmMgmr.queryVnfm(vnfmId);
- } catch (Exception e) {
- throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
- }
-
- if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId()))
- {
- throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
- }
-
- VnfmJobExecutionInfo jobInfo = jobDbManager.findOne(Long.getLong(jobId));
- String execId = jobInfo.getVnfmExecutionId();
CBAMQueryOperExecutionResponse cbamResponse;
try {
+ buildVnfmHttpPathById(vnfmId);
+
+ VnfmJobExecutionInfo jobInfo = jobDbManager.findOne(Long.getLong(jobId));
+ String execId = jobInfo.getVnfmExecutionId();
cbamResponse = cbamMgmr.queryOperExecution(execId);
} catch (Exception e) {
throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
@@ -204,12 +188,7 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
public ScaleVnfResponse scaleVnf(ScaleVnfRequest driverRequest, String vnfmId, String vnfInstanceId) throws VnfmDriverException {
ScaleVnfResponse driverResponse;
try {
- VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId);
-
- if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId()))
- {
- throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
- }
+ buildVnfmHttpPathById(vnfmId);
CBAMScaleVnfRequest cbamRequest = requestConverter.scaleReqconvert(driverRequest);
CBAMScaleVnfResponse cbamResponse = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId);
driverResponse = responseConverter.scaleRspConvert(cbamResponse);
@@ -223,12 +202,7 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
public HealVnfResponse healVnf(HealVnfRequest driverRequest, String vnfmId, String vnfInstanceId) throws VnfmDriverException {
HealVnfResponse driverResponse;
try {
- VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId);
-
- if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId()))
- {
- throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
- }
+ buildVnfmHttpPathById(vnfmId);
CBAMHealVnfRequest cbamRequest = requestConverter.healReqConvert(driverRequest);
CBAMHealVnfResponse cbamResponse = cbamMgmr.healVnf(cbamRequest, vnfInstanceId);
driverResponse = responseConverter.healRspConvert(cbamResponse);
@@ -239,4 +213,31 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
return driverResponse;
}
+ public String buildVnfmHttpPathById(String vnfmId) throws ClientProtocolException, IOException, VnfmDriverException {
+ AaiVnfmInfo vnfmInfo = aaiMgmr.queryVnfm(vnfmId);
+ logger.info("vnfmInfo in AAI is {}", gson.toJson(vnfmInfo));
+ if(isVnfmInfoValid(vnfmId, vnfmInfo))
+ {
+ throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
+ }
+
+ EsrSystemInfo systemInfo = vnfmInfo.getEsrSystemInfoList().get(0);
+
+ String urlHead = systemInfo.getProtocal() + "://" + systemInfo.getIp() + ":" + systemInfo.getPort();
+ adaptorEnv.setCbamApiUriFront(urlHead);
+ return urlHead;
+ }
+
+ private boolean isVnfmInfoValid(String vnfmId, AaiVnfmInfo vnfmInfo) {
+ return vnfmInfo == null || !vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId()) || vnfmInfo.getEsrSystemInfoList() == null || vnfmInfo.getEsrSystemInfoList().isEmpty();
+ }
+
+ public void setRequestConverter(Driver2CbamRequestConverter requestConverter) {
+ this.requestConverter = requestConverter;
+ }
+
+ public void setResponseConverter(Cbam2DriverResponseConverter responseConverter) {
+ this.responseConverter = responseConverter;
+ }
+
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java
index 1e2cecf7..2c88320e 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java
@@ -17,6 +17,7 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.impl;
import java.io.IOException;
+import java.util.HashMap;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.impl.client.HttpClientBuilder;
@@ -38,6 +39,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@@ -55,19 +57,18 @@ public class CbamMgmrImpl implements CbamMgmrInf {
private AdaptorEnv adaptorEnv;
@Autowired
- private HttpClientBuilder httpClientBuilder;// = HttpClientUtils.createHttpClientBuilder();
+ HttpClientProcessorInf httpClientProcessor;
private String retrieveToken() throws ClientProtocolException, IOException, JSONException {
String result = null;
String url= adaptorEnv.getCbamApiUriFront() + CommonConstants.RetrieveCbamTokenPath;
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.POST);
- processor.addHdeader(CommonConstants.ACCEPT, "*/*");
- processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put(CommonConstants.ACCEPT, "*/*");
+ map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
String bodyPostStr = String.format(CommonConstants.RetrieveCbamTokenPostStr, adaptorEnv.getGrantType(), adaptorEnv.getClientId(), adaptorEnv.getClientSecret());
- processor.addPostEntity(bodyPostStr);
- String responseStr = processor.process(url);
+ String responseStr = httpClientProcessor.process(url, RequestMethod.GET, map, bodyPostStr);
logger.info("CbamMgmrImpl -> retrieveToken, responseStr is " + responseStr);
@@ -175,13 +176,12 @@ public class CbamMgmrImpl implements CbamMgmrInf {
}
String url= adaptorEnv.getCbamApiUriFront() + httpPath;
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, method);
- processor.addHdeader(CommonConstants.AUTHORIZATION, "bearer " + token);
- processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
- processor.addPostEntity(gson.toJson(httpBodyObj));
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put(CommonConstants.AUTHORIZATION, "bearer " + token);
+ map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
- String responseStr = processor.process(url);
+ String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj));
return responseStr;
}
@@ -198,5 +198,9 @@ public class CbamMgmrImpl implements CbamMgmrInf {
return response;
}
+
+ public void setAdaptorEnv(AdaptorEnv adaptorEnv) {
+ this.adaptorEnv = adaptorEnv;
+ }
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java
index 343e517e..4a9570b5 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java
@@ -21,69 +21,195 @@ import org.springframework.stereotype.Component;
@Component
public class AdaptorEnv {
- @Value("${nslcmApiUriFront}")
- private String nslcmApiUriFront;
+ private String msbIp;
+ private int msbPort;
- @Value("${catalogApiUriFront}")
- private String catalogApiUriFront;
+ // service name and version of MSB services AAI/LCM/Catalog configured in application.properties
+ @Value("${aaiServiceNameInMsb}")
+ private String aaiServiceNameInMsb;
+
+ @Value("${aaiVersionInMsb}")
+ private String aaiVersionInMsb;
+
+ @Value("${lcmServiceNameInMsb}")
+ private String lcmServiceNameInMsb;
+
+ @Value("${lcmVersionInMsb}")
+ private String lcmVersionInMsb;
+
+ @Value("${catalogServiceNameInMsb}")
+ private String catalogServiceNameInMsb;
+
+ @Value("${catalogVersionInMsb}")
+ private String catalogVersionInMsb;
+
+ //Following uriFront is from msb query
- @Value("${cbamApiUriFront}")
- private String cbamApiUriFront;
+ private String aaiUrlInMsb;
+ private String aaiApiUriFront;
- @Value("${msbApiUriFront}")
- private String msbApiUriFront;
+ private String lcmUrlInMsb;
+ private String lcmApiUriFront;
+
+ private String catalogUrlInMsb;
+ private String catalogApiUriFront;
- //for retrieving token from CBAM
+ //cbamApiFront is from aai query
+ private String cbamApiUriFront;
+
+ // for retrieving token from CBAM, configured in application.properties
@Value("${grantType}")
private String grantType;
-
+
@Value("${clientId}")
private String clientId;
-
+
@Value("${clientSecret}")
private String clientSecret;
-
- public String getNslcmApiUriFront() {
- return nslcmApiUriFront;
+
+ public String getAaiServiceNameInMsb() {
+ return aaiServiceNameInMsb;
+ }
+
+ public void setAaiServiceNameInMsb(String aaiServiceNameInMsb) {
+ this.aaiServiceNameInMsb = aaiServiceNameInMsb;
+ }
+
+ public String getAaiVersionInMsb() {
+ return aaiVersionInMsb;
+ }
+
+ public void setAaiVersionInMsb(String aaiVersionInMsb) {
+ this.aaiVersionInMsb = aaiVersionInMsb;
+ }
+
+ public String getLcmServiceNameInMsb() {
+ return lcmServiceNameInMsb;
+ }
+
+ public void setLcmServiceNameInMsb(String lcmServiceNameInMsb) {
+ this.lcmServiceNameInMsb = lcmServiceNameInMsb;
+ }
+
+ public String getLcmVersionInMsb() {
+ return lcmVersionInMsb;
+ }
+
+ public void setLcmVersionInMsb(String lcmVersionInMsb) {
+ this.lcmVersionInMsb = lcmVersionInMsb;
+ }
+
+ public String getCatalogServiceNameInMsb() {
+ return catalogServiceNameInMsb;
+ }
+
+ public void setCatalogServiceNameInMsb(String catalogServiceNameInMsb) {
+ this.catalogServiceNameInMsb = catalogServiceNameInMsb;
+ }
+
+ public String getCatalogVersionInMsb() {
+ return catalogVersionInMsb;
+ }
+
+ public void setCatalogVersionInMsb(String catalogVersionInMsb) {
+ this.catalogVersionInMsb = catalogVersionInMsb;
}
- public void setNslcmApiUriFront(String nslcmApiUriFront) {
- this.nslcmApiUriFront = nslcmApiUriFront;
+
+ public String getAaiApiUriFront() {
+ return aaiApiUriFront;
}
+
+ public void setAaiApiUriFront(String aaiApiUriFront) {
+ this.aaiApiUriFront = aaiApiUriFront;
+ }
+
public String getCatalogApiUriFront() {
return catalogApiUriFront;
}
+
public void setCatalogApiUriFront(String catalogApiUriFront) {
this.catalogApiUriFront = catalogApiUriFront;
}
+
public String getCbamApiUriFront() {
return cbamApiUriFront;
}
+
public void setCbamApiUriFront(String cbamApiUriFront) {
this.cbamApiUriFront = cbamApiUriFront;
}
+
public String getGrantType() {
return grantType;
}
+
public void setGrantType(String grantType) {
this.grantType = grantType;
}
+
public String getClientId() {
return clientId;
}
+
public void setClientId(String clientId) {
this.clientId = clientId;
}
+
public String getClientSecret() {
return clientSecret;
}
+
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
- public String getMsbApiUriFront() {
- return msbApiUriFront;
+
+ public String getMsbIp() {
+ return msbIp;
+ }
+
+ public void setMsbIp(String msbIp) {
+ this.msbIp = msbIp;
}
- public void setMsbApiUriFront(String msbApiUriFront) {
- this.msbApiUriFront = msbApiUriFront;
+
+ public int getMsbPort() {
+ return msbPort;
}
-
+
+ public void setMsbPort(int msbPort) {
+ this.msbPort = msbPort;
+ }
+
+ public String getAaiUrlInMsb() {
+ return aaiUrlInMsb;
+ }
+
+ public void setAaiUrlInMsb(String aaiUrlInMsb) {
+ this.aaiUrlInMsb = aaiUrlInMsb;
+ }
+
+ public String getCatalogUrlInMsb() {
+ return catalogUrlInMsb;
+ }
+
+ public void setCatalogUrlInMsb(String catalogUrlInMsb) {
+ this.catalogUrlInMsb = catalogUrlInMsb;
+ }
+
+ public String getLcmUrlInMsb() {
+ return lcmUrlInMsb;
+ }
+
+ public void setLcmUrlInMsb(String lcmUrlInMsb) {
+ this.lcmUrlInMsb = lcmUrlInMsb;
+ }
+
+ public String getLcmApiUriFront() {
+ return lcmApiUriFront;
+ }
+
+ public void setLcmApiUriFront(String lcmApiUriFront) {
+ this.lcmApiUriFront = lcmApiUriFront;
+ }
+
+
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java
new file mode 100644
index 00000000..34530b51
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.common.util;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class CommonUtil {
+ private static final Logger logger = LoggerFactory.getLogger(CommonUtil.class);
+
+ public static String getJsonStrFromFile(String filePath) throws IOException {
+ InputStream ins = null;
+ BufferedInputStream bins = null;
+ String fileContent = "";
+ String fileName = getAppRoot() + filePath;
+
+ try {
+ ins = new FileInputStream(fileName);
+ bins = new BufferedInputStream(ins);
+
+ byte[] contentByte = new byte[ins.available()];
+ int num = bins.read(contentByte);
+
+ if(num > 0) {
+ fileContent = new String(contentByte);
+ }
+ } catch(FileNotFoundException e) {
+ logger.error(fileName + "is not found!", e);
+ } finally {
+ if(ins != null) {
+ ins.close();
+ }
+ if(bins != null) {
+ bins.close();
+ }
+ }
+ return fileContent;
+ }
+
+ private static String getAppRoot() {
+ String appRoot = System.getProperty("catalina.base");
+ if(appRoot != null) {
+ appRoot = getCanonicalPath(appRoot);
+ }
+ return appRoot;
+ }
+
+ private static String getCanonicalPath(final String inPath) {
+ String path = null;
+ try {
+ if(inPath != null) {
+ final File file = new File(inPath);
+ path = file.getCanonicalPath();
+ }
+ } catch(final IOException e) {
+ logger.error("file.getCanonicalPath() IOException:", e);
+ }
+ return path;
+ }
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java
index 22c06ef0..368e8a4e 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java
@@ -17,6 +17,8 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.constant;
public class CommonConstants {
+ public static final String SCHEMA_HTTP = "http";
+
public static final String HTTP_ERROR_DESC_500 = "Internal Server Error";
@@ -27,13 +29,16 @@ public class CommonConstants {
public static final String AUTHORIZATION = "Authorization";
public static final String UTF_8 = "utf-8";
+ //AAI path get vnfm
+ // /external-system/esr-vnfm-list/esr-vnfm/{vnfm-id}
+ public static final String RetrieveVnfmListPath = "/external-system/esr-vnfm-list/esr-vnfm/%s";
+
//Nslcm path
- public static final String RetrieveNvfmListPath = "/nslcm/vl/vnfms/%s";
- public static final String NslcmGrantPath = "/nslcm/v1/ns/grantvnf";
- public static final String NslcmNotifyPath = "/nslcm/v1/vnfs/%s/Notify";
+ public static final String NslcmGrantPath = "/ns/grantvnf";
+ public static final String NslcmNotifyPath = "/vnfs/%s/Notify";
//Catalog path
- public static final String RetrieveVnfPackagePath = "/catalog/v1/vnfpackages/%s";
+ public static final String RetrieveVnfPackagePath = "/vnfpackages/%s";
//CBAM -- Nokia VNFM path
public static final String CBAM_TOKEN_KEY = "access_token";
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java
new file mode 100644
index 00000000..9bebb1c9
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Component
+public class HttpClientProcessorImpl implements HttpClientProcessorInf{
+
+ @Autowired
+ private HttpClientBuilder httpClientBuilder;
+
+ public String process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException
+ {
+ HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, methodType);
+ if(headerMap != null && !headerMap.isEmpty())
+ {
+ for(String key : headerMap.keySet())
+ {
+ processor.addHdeader(key, headerMap.get(key));
+ }
+
+ if(null != bodyString && bodyString.length() > 0)
+ {
+ processor.addPostEntity(bodyString);
+ }
+
+ }
+ return processor.process(url);
+ }
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java
new file mode 100644
index 00000000..41b84d9b
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.http.client.ClientProtocolException;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public interface HttpClientProcessorInf {
+ public String process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException;
+
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java
new file mode 100644
index 00000000..30da37e3
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.init;
+
+import java.io.IOException;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.onap.msb.sdk.discovery.common.RouteException;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.util.CommonUtil;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf.IMsbMgmr;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+@Component
+public class EnvVariablesInitialization implements ApplicationRunner {
+ private static final Logger logger = LoggerFactory.getLogger(EnvVariablesInitialization.class);
+
+ @Autowired
+ AdaptorEnv adaptorEnv;
+
+ @Autowired
+ private IMsbMgmr msbMgmr;
+
+ @Override
+ public void run(ApplicationArguments args){
+ try {
+ getMsbIpAndPort();
+ } catch (Exception e) {
+ logger.error("getMsbIpAndPort error", e);
+ return;
+ }
+
+ try {
+ handleAaiMsbServiceInfo();
+ } catch (RouteException e) {
+ logger.error("handleAaiMsbServiceInfo error", e);
+ }
+
+ try {
+ handLcmMsbServiceInfo();
+ } catch (RouteException e) {
+ logger.error("handLcmMsbServiceInfo error", e);
+ }
+
+ try {
+ handCatalogMsbServiceInfo();
+ } catch (RouteException e) {
+ logger.error("handCatalogMsbServiceInfo error", e);
+ }
+
+ }
+
+ private void handleAaiMsbServiceInfo() throws RouteException {
+ String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(adaptorEnv.getAaiServiceNameInMsb(), adaptorEnv.getAaiVersionInMsb());
+ adaptorEnv.setAaiUrlInMsb(urlInMsb);
+ adaptorEnv.setAaiApiUriFront(generateApiUriFront(urlInMsb));
+ }
+
+ private String generateApiUriFront(String urlInMsb) {
+ return CommonConstants.SCHEMA_HTTP + "://" + adaptorEnv.getMsbIp() + ":" + adaptorEnv.getMsbPort() + urlInMsb;
+ }
+
+ private void handLcmMsbServiceInfo() throws RouteException {
+ String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(adaptorEnv.getLcmServiceNameInMsb(), adaptorEnv.getLcmVersionInMsb());
+ adaptorEnv.setLcmUrlInMsb(urlInMsb);
+ adaptorEnv.setLcmApiUriFront(generateApiUriFront(urlInMsb));
+ }
+
+ private void handCatalogMsbServiceInfo() throws RouteException {
+ String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(adaptorEnv.getCatalogServiceNameInMsb(), adaptorEnv.getCatalogVersionInMsb());
+ adaptorEnv.setCatalogUrlInMsb(urlInMsb);
+ adaptorEnv.setCatalogApiUriFront(generateApiUriFront(urlInMsb));
+ }
+
+ private void getMsbIpAndPort() throws IOException, JSONException {
+ String msbInfoJsonStr = readMsbInfoFromJsonFile();
+ JSONObject totalJsonObj = new JSONObject(msbInfoJsonStr);
+ JSONObject serverJsonObj = totalJsonObj.getJSONObject("defaultServer");
+ String msb_ip = serverJsonObj.getString("host");
+ int msb_port = serverJsonObj.getInt("port");
+
+ adaptorEnv.setMsbIp(msb_ip);
+ adaptorEnv.setMsbPort(msb_port);
+ }
+
+ private String readMsbInfoFromJsonFile() throws IOException {
+ String filePath = "/etc/conf/restclient.json";
+ String fileContent = CommonUtil.getJsonStrFromFile(filePath);
+
+ return fileContent;
+ }
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java
index cb93b0be..8f668c2f 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java
@@ -16,23 +16,19 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.impl;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.onap.msb.sdk.discovery.common.RouteException;
import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
import org.onap.msb.sdk.discovery.entity.RouteResult;
import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.util.CommonUtil;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf.IMsbMgmr;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.gson.Gson;
@@ -41,25 +37,18 @@ import com.google.gson.Gson;
public class MsbMgmrImpl implements IMsbMgmr {
private static final Logger logger = LoggerFactory.getLogger(MsbMgmrImpl.class);
- private Gson gson = new Gson();
-
- private String msb_ip;
+ @Autowired
+ AdaptorEnv adaptorEnv;
- private int msb_port;
+ private Gson gson = new Gson();
@Override
public void register() {
try {
- String msbInfoJsonStr = readMsbInfoFromJsonFile();
- JSONObject totalJsonObj = new JSONObject(msbInfoJsonStr);
- JSONObject serverJsonObj = totalJsonObj.getJSONObject("defaultServer");
- msb_ip = serverJsonObj.getString("host");
- msb_port = serverJsonObj.getInt("port");
-
String vfcAdaptorInfoJsonStr = readVfcAdaptorInfoFromJsonFile();
MicroServiceInfo msinfo = gson.fromJson(vfcAdaptorInfoJsonStr, MicroServiceInfo.class);
- MSBServiceClient msbClient = new MSBServiceClient(msb_ip, msb_port);
+ MSBServiceClient msbClient = new MSBServiceClient(adaptorEnv.getMsbIp(), adaptorEnv.getMsbPort());
MicroServiceFullInfo microServiceInfo = msbClient.registerMicroServiceInfo(msinfo);
logger.info("Registered service response info is " + microServiceInfo.toString());
@@ -67,62 +56,24 @@ public class MsbMgmrImpl implements IMsbMgmr {
logger.error("Failed to read vfcadaptor info! ", e);
} catch (RouteException e) {
logger.error("Failed to register nokia vnfm driver! ", e);
- } catch (JSONException e) {
- logger.error("Failed to retrieve json info! ", e);
}
}
- private String readMsbInfoFromJsonFile() throws IOException {
- String filePath = "/etc/conf/restclient.json";
- String fileContent = getJsonStrFromFile(filePath);
-
- return fileContent;
- }
-
private String readVfcAdaptorInfoFromJsonFile() throws IOException {
String filePath = "/etc/adapterInfo/vnfmadapterinfo.json";
- String fileContent = getJsonStrFromFile(filePath);
+ String fileContent = CommonUtil.getJsonStrFromFile(filePath);
return fileContent;
}
- public String getJsonStrFromFile(String filePath) throws IOException {
- InputStream ins = null;
- BufferedInputStream bins = null;
- String fileContent = "";
- String fileName = getAppRoot() + filePath;
-
- try {
- ins = new FileInputStream(fileName);
- bins = new BufferedInputStream(ins);
-
- byte[] contentByte = new byte[ins.available()];
- int num = bins.read(contentByte);
-
- if(num > 0) {
- fileContent = new String(contentByte);
- }
- } catch(FileNotFoundException e) {
- logger.error(fileName + "is not found!", e);
- } finally {
- if(ins != null) {
- ins.close();
- }
- if(bins != null) {
- bins.close();
- }
- }
- return fileContent;
- }
-
@Override
public void unregister() {
try {
String jsonStr = readVfcAdaptorInfoFromJsonFile();
MicroServiceInfo msinfo = gson.fromJson(jsonStr, MicroServiceInfo.class);
- MSBServiceClient msbClient = new MSBServiceClient(msb_ip, msb_port);
+ MSBServiceClient msbClient = new MSBServiceClient(adaptorEnv.getMsbIp(), adaptorEnv.getMsbPort());
RouteResult routeResult = msbClient.cancelMicroServiceInfo(msinfo.getServiceName(), msinfo.getVersion());
logger.info("unregistered service response info is " + routeResult.toString());
@@ -133,26 +84,24 @@ public class MsbMgmrImpl implements IMsbMgmr {
}
}
- public String getAppRoot() {
- String appRoot = null;
- appRoot = System.getProperty("catalina.base");
- if(appRoot != null) {
- appRoot = getCanonicalPath(appRoot);
- }
- return appRoot;
- }
+ public String getServiceUrlInMsbBySeriveNameAndPort(String serviceName, String version) throws RouteException
+ {
+ MSBServiceClient msbClient = new MSBServiceClient(adaptorEnv.getMsbIp(), adaptorEnv.getMsbPort());
+ MicroServiceFullInfo microServiceInfo = msbClient.queryMicroServiceInfo(serviceName, version);
+ if(null == microServiceInfo)
+ {
+ logger.error("There is no service in MSB for serviceName = {} and version = {}", serviceName, version);
+ }
+
+ String serviceUrl = microServiceInfo.getUrl();
+ logger.info("Service Url in MSB for serviceName = {} and version = {} is {}", serviceName, version, serviceUrl);
+
+ return serviceUrl;
+
+ }
- private String getCanonicalPath(final String inPath) {
- String path = null;
- try {
- if(inPath != null) {
- final File file = new File(inPath);
- path = file.getCanonicalPath();
- }
- } catch(final IOException e) {
- logger.error("file.getCanonicalPath() IOException:", e);
- }
- return path;
- }
+ public void setAdaptorEnv(AdaptorEnv env) {
+ this.adaptorEnv = env;
+ }
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java
index aaabc3f2..f63b5a56 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java
@@ -16,7 +16,10 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf;
+import org.onap.msb.sdk.discovery.common.RouteException;
+
public interface IMsbMgmr {
public void register();
public void unregister();
+ public String getServiceUrlInMsbBySeriveNameAndPort(String serviceName, String version) throws RouteException;
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java
index eb14023c..405c7365 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java
@@ -17,6 +17,7 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.impl;
import java.io.IOException;
+import java.util.HashMap;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.impl.client.HttpClientBuilder;
@@ -24,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse;
@@ -44,24 +46,25 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{
@Autowired
private AdaptorEnv adaptorEnv;
- @Autowired
- private HttpClientBuilder httpClientBuilder;
+ @Autowired
+ HttpClientProcessorInf httpClientProcessor;
private Gson gson = new Gson();
- public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException
- {
- String httpPath = String.format(CommonConstants.RetrieveNvfmListPath, vnfmId);
- RequestMethod method = RequestMethod.GET;
-
- String responseStr = operateNslcmHttpTask(null, httpPath, method);
-
- logger.info("NslcmMgmrImpl->queryVnfm, the vnfmInfo is {}", responseStr);
-
- VnfmInfo response = gson.fromJson(responseStr, VnfmInfo.class);
-
- return response;
- }
+// @Deprecated
+// public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException
+// {
+// String httpPath = String.format(CommonConstants.RetrieveVnfmListPath, vnfmId);
+// RequestMethod method = RequestMethod.GET;
+//
+// String responseStr = operateNslcmHttpTask(null, httpPath, method);
+//
+// logger.info("NslcmMgmrImpl->queryVnfm, the vnfmInfo is {}", responseStr);
+//
+// VnfmInfo response = gson.fromJson(responseStr, VnfmInfo.class);
+//
+// return response;
+// }
public NslcmGrantVnfResponse grantVnf(NslcmGrantVnfRequest driverRequest) throws ClientProtocolException, IOException {
String httpPath = CommonConstants.NslcmGrantPath;
@@ -83,16 +86,19 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{
operateNslcmHttpTask(driverRequest, httpPath, method);
}
- public String operateNslcmHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException {
- String url=adaptorEnv.getNslcmApiUriFront() + httpPath;
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, method);
- processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
+ private String operateNslcmHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException {
+ String url=adaptorEnv.getLcmApiUriFront() + httpPath;
- processor.addPostEntity(gson.toJson(httpBodyObj));
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
- String responseStr = processor.process(url);
+ String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj));
return responseStr;
}
+ public void setAdaptorEnv(AdaptorEnv env) {
+ this.adaptorEnv = env;
+ }
+
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java
index ca7fa449..d9c39dff 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java
@@ -25,7 +25,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmNotifyLCMEventsRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.VnfmInfo;
public interface NslcmMgmrInf {
- public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException;
+// public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException;
public NslcmGrantVnfResponse grantVnf(NslcmGrantVnfRequest driverRequest) throws ClientProtocolException, IOException;
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java
new file mode 100644
index 00000000..d5130893
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.impl;
+
+import java.util.concurrent.Executors;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.Cbam2DriverResponseConverter;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.Driver2CbamRequestConverter;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.InstantiateVnfContinueRunnable;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.TerminateVnfContinueRunnable;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository.VnfmJobExecutionRepository;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfContinueProcessorInf;
+
+public class VnfContinueProcessorImpl implements VnfContinueProcessorInf{
+
+ @Override
+ public void continueInstantiateVnf(InstantiateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CatalogMgmrInf catalogMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionRepository jobDbManager) {
+ InstantiateVnfContinueRunnable task = new InstantiateVnfContinueRunnable(driverRequest, vnfInstanceId, jobId,
+ nslcmMgmr, catalogMgmr, cbamMgmr, requestConverter, jobDbManager);
+
+ Executors.newSingleThreadExecutor().submit(task);
+ }
+
+ @Override
+ public void continueTerminateVnf(TerminateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionRepository jobDbManager) {
+ TerminateVnfContinueRunnable task = new TerminateVnfContinueRunnable(driverRequest, vnfInstanceId, jobId,
+ nslcmMgmr, cbamMgmr, requestConverter, jobDbManager);
+
+ Executors.newSingleThreadExecutor().submit(task);
+ }
+
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/inf/VnfContinueProcessorInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/inf/VnfContinueProcessorInf.java
new file mode 100644
index 00000000..3898a477
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/inf/VnfContinueProcessorInf.java
@@ -0,0 +1,30 @@
+/*
+* Copyright 2016-2017 Nokia Corporation
+*
+* 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.
+*/
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.Driver2CbamRequestConverter;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository.VnfmJobExecutionRepository;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest;
+
+public interface VnfContinueProcessorInf {
+ public void continueInstantiateVnf(InstantiateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CatalogMgmrInf catalogMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionRepository jobDbManager);
+ public void continueTerminateVnf(TerminateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionRepository jobDbManager);
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties
index f3d6c7fd..850e6cad 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties
@@ -30,17 +30,20 @@ spring.datasource.tomcat.test-on-borrow=true
com.fasterxml.jackson.core=jackson-databind
logging.file=${catalina.base}/logs/vfcadaptor.log
logging.level.org.springframework.web=DEBUG
-logging.level.org.hibernate=ERROR
+logging.level.org.hibernate=DEBUG
## for logging end ##
-## common configuration for connections begin ##
-nslcmApiHttpFront=http://1.2.3.4:88
-catalogApiUriFront=http://2.2.3.4:88
-cbamApiUriFront=https://3.2.3.4:88
-msbApiUriFront=http://4.2.3.4:88
-
-## for retrieving token from CBAM ##
+## configure service name and version of MSB services AAI/LCM/Catalog begin ##
+aaiServiceNameInMsb=aai-esr-server
+aaiVersionInMsb=v1
+lcmServiceNameInMsb=nslcm
+lcmVersionInMsb=v1
+catalogServiceNameInMsb=catalog
+catalogVersionInMsb=v1
+## configure service name and version of MSB services AAI/LCM/Catalog end ##
+
+## for retrieving token from CBAM begin ##
grantType=grantType1
clientId=clientId1
clientSecret=clientSecret1
-## common configuration for connections end ## \ No newline at end of file
+## for retrieving token from CBAM end ##
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java
new file mode 100644
index 00000000..aa24bf3c
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor;
+
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.client.ClientProtocolException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.entity.EsrSystemInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.inf.AaiMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryOperExecutionResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository.VnfmJobExecutionRepository;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.OperStatusVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.QueryVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfContinueProcessorInf;
+
+public class VnfmDriverMgmrImplTest {
+
+ @InjectMocks
+ private VnfmDriverMgmrImpl vnfmDriverMgmr = new VnfmDriverMgmrImpl();
+
+ @Mock
+ private CbamMgmrInf cbamMgmr;
+
+ @Mock
+ private CatalogMgmrInf catalogMgmr;
+
+ @Mock
+ private AaiMgmrInf aaiMgmr;
+
+ @Mock
+ private NslcmMgmrInf nslcmMgmr;;
+
+ @Mock
+ private VnfmJobExecutionRepository jobDbManager;
+
+ @Mock
+ private VnfContinueProcessorInf vnfContinueProcessorInf;
+
+ @Mock
+ AdaptorEnv adaptorEnv;
+
+ @Rule
+ public ExpectedException thrown= ExpectedException.none();
+
+ private String vnfmId = "vnfmId_001";
+ private String vnfInstanceId = "vnfInstanceId_001";
+
+ private String protocol = "https";
+ private String ip = "139.234.34.43";
+ private String port = "99";
+ private String cbamHttpHead;
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ cbamHttpHead = protocol + "://" + ip + ":" + port;
+
+ EsrSystemInfo esrSystemInfo = new EsrSystemInfo();
+ esrSystemInfo.setProtocal(protocol);
+ esrSystemInfo.setIp(ip);
+ esrSystemInfo.setPort(port);
+
+ List<EsrSystemInfo> esrSystemInfoList = new ArrayList<EsrSystemInfo>();
+ esrSystemInfoList.add(esrSystemInfo);
+ AaiVnfmInfo mockVnfmInfo = new AaiVnfmInfo();
+ mockVnfmInfo.setVnfmId(vnfmId);
+ mockVnfmInfo.setEsrSystemInfoList(esrSystemInfoList);
+
+ Driver2CbamRequestConverter reqConverter = new Driver2CbamRequestConverter();
+ Cbam2DriverResponseConverter rspConverter = new Cbam2DriverResponseConverter();
+ vnfmDriverMgmr.setRequestConverter(reqConverter);
+ vnfmDriverMgmr.setResponseConverter(rspConverter);
+
+ when(aaiMgmr.queryVnfm(vnfmId)).thenReturn(mockVnfmInfo);
+
+ VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo();
+ execInfo.setJobId(100L);
+ execInfo.setVnfmExecutionId("executionId_001");
+ execInfo.setVnfInstanceId(vnfInstanceId);
+
+ when(jobDbManager.save(Mockito.any(VnfmJobExecutionInfo.class))).thenReturn(execInfo);
+ }
+
+ @Test
+ public void testBuildVnfmHttpPathById() throws ClientProtocolException, IOException {
+ String vnfmHttpPathHead = vnfmDriverMgmr.buildVnfmHttpPathById(vnfmId);
+ Assert.assertEquals("result is ", cbamHttpHead, vnfmHttpPathHead);
+ }
+
+ @Test(expected = VnfmDriverException.class)
+ public void testBuildVnfmHttpPathByIdException() throws ClientProtocolException, IOException{
+ vnfmDriverMgmr.buildVnfmHttpPathById(vnfmId + "001");
+ }
+
+ @Test
+ public void testInstantiateVnf() throws ClientProtocolException, IOException {
+ CBAMCreateVnfResponse mockCbamResponse = new CBAMCreateVnfResponse();
+ mockCbamResponse.setId("executionId_001");
+
+ when(cbamMgmr.createVnf(Mockito.any(CBAMCreateVnfRequest.class))).thenReturn(mockCbamResponse);
+ InstantiateVnfRequest driverRequest = new InstantiateVnfRequest();
+ InstantiateVnfResponse response = vnfmDriverMgmr.instantiateVnf(driverRequest, vnfmId);
+ }
+
+ @Test
+ public void testTerminateVnf() throws ClientProtocolException, IOException {
+ TerminateVnfRequest driverRequest = new TerminateVnfRequest();
+ TerminateVnfResponse response = vnfmDriverMgmr.terminateVnf(driverRequest, vnfmId, vnfInstanceId);
+ }
+
+ @Test
+ public void testHealVnf() throws ClientProtocolException, IOException {
+ CBAMHealVnfResponse mockCbamResponse = new CBAMHealVnfResponse();
+ mockCbamResponse.setId("executionId_001");
+ when(cbamMgmr.healVnf(Mockito.any(CBAMHealVnfRequest.class), Mockito.anyString())).thenReturn(mockCbamResponse);
+ HealVnfRequest request = new HealVnfRequest();
+ HealVnfResponse response = vnfmDriverMgmr.healVnf(request, vnfmId, vnfInstanceId);
+ }
+
+ @Test
+ public void testScaleVnf() throws ClientProtocolException, IOException {
+ CBAMScaleVnfResponse mockCbamResponse = new CBAMScaleVnfResponse();
+ mockCbamResponse.setId("executionId_001");
+ when(cbamMgmr.scaleVnf(Mockito.any(CBAMScaleVnfRequest.class), Mockito.anyString())).thenReturn(mockCbamResponse);
+ ScaleVnfRequest request = new ScaleVnfRequest();
+ request.setType(CommonEnum.ScaleType.SCALE_IN);
+ ScaleVnfResponse response = vnfmDriverMgmr.scaleVnf(request, vnfmId, vnfInstanceId);
+ }
+
+ @Test
+ public void testQueryVnf() throws ClientProtocolException, IOException {
+ CBAMQueryVnfResponse mockCbamResponse = new CBAMQueryVnfResponse();
+ mockCbamResponse.setId("executionId_001");
+
+ when(cbamMgmr.queryVnf(Mockito.anyString())).thenReturn(mockCbamResponse);
+ ScaleVnfRequest request = new ScaleVnfRequest();
+ request.setType(CommonEnum.ScaleType.SCALE_IN);
+ QueryVnfResponse response = vnfmDriverMgmr.queryVnf(vnfmId, vnfInstanceId);
+ }
+
+ @Test
+ public void testGetOperStatus() throws ClientProtocolException, IOException
+ {
+ VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo();
+ execInfo.setJobId(1L);
+ execInfo.setVnfmExecutionId("executionId_001");
+ when(jobDbManager.findOne(Mockito.anyLong())).thenReturn(execInfo);
+
+ CBAMQueryOperExecutionResponse cbamResponse = new CBAMQueryOperExecutionResponse();
+ cbamResponse.setId("executionId_001");
+ cbamResponse.setStatus(CommonEnum.OperationStatus.STARTED);
+ cbamResponse.setGrantId("001002001");
+
+ when(cbamMgmr.queryOperExecution(Mockito.anyString())).thenReturn(cbamResponse);
+ ScaleVnfRequest request = new ScaleVnfRequest();
+ OperStatusVnfResponse response = vnfmDriverMgmr.getOperStatus(vnfmId, "1");
+ }
+
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java
new file mode 100644
index 00000000..7fac27b0
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class CatalogMgmrImplTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void test() {
+// fail("Not yet implemented");
+ }
+
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java
new file mode 100644
index 00000000..b4cabfbe
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.impl;
+
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.http.client.ClientProtocolException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public class CbamMgmrImplTest {
+ @InjectMocks
+ private CbamMgmrImpl cbamMgmr;
+
+ @Mock
+ private HttpClientProcessorInf httpClientProcessor;
+
+ private String vnfInstanceId = "vnfInstanceId_001";
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ AdaptorEnv env = new AdaptorEnv();
+ cbamMgmr.setAdaptorEnv(env);
+ MockitoAnnotations.initMocks(this);
+
+ String json = "{\"access_token\":\"1234567\"}";
+
+ when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(json);
+ }
+
+ @Test
+ public void testCreateVnf() throws ClientProtocolException, IOException
+ {
+ CBAMCreateVnfRequest cbamRequest = new CBAMCreateVnfRequest();
+ CBAMCreateVnfResponse response = cbamMgmr.createVnf(cbamRequest);
+ }
+
+ @Test
+ public void testInstantiateVnf() throws ClientProtocolException, IOException
+ {
+ CBAMInstantiateVnfRequest cbamRequest = new CBAMInstantiateVnfRequest();
+ CBAMInstantiateVnfResponse response = cbamMgmr.instantiateVnf(cbamRequest, vnfInstanceId);
+ }
+
+ @Test
+ public void testTerminateVnf() throws ClientProtocolException, IOException
+ {
+ CBAMTerminateVnfRequest cbamRequest = new CBAMTerminateVnfRequest();
+ CBAMTerminateVnfResponse response = cbamMgmr.terminateVnf(cbamRequest, vnfInstanceId);
+ }
+
+ @Test
+ public void testDeleteVnf() throws ClientProtocolException, IOException
+ {
+ cbamMgmr.deleteVnf(vnfInstanceId);
+ }
+
+ @Test
+ public void testScaleVnf() throws ClientProtocolException, IOException
+ {
+ CBAMScaleVnfRequest cbamRequest = new CBAMScaleVnfRequest();
+ CBAMScaleVnfResponse response = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId);
+ }
+
+ @Test
+ public void testHealVnf() throws ClientProtocolException, IOException
+ {
+ CBAMHealVnfRequest cbamRequest = new CBAMHealVnfRequest();
+ CBAMHealVnfResponse response = cbamMgmr.healVnf(cbamRequest, vnfInstanceId);
+ }
+
+ @Test
+ public void testQueryVnf() throws ClientProtocolException, IOException
+ {
+ CBAMQueryVnfResponse response = cbamMgmr.queryVnf(vnfInstanceId);
+ }
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java
new file mode 100644
index 00000000..08587109
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.impl;
+
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.http.client.ClientProtocolException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.impl.NslcmMgmrImpl;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public class MsbMgmrImplTest {
+ @InjectMocks
+ private MsbMgmrImpl msbMgmr;
+
+ @Mock
+ private HttpClientProcessorInf httpClientProcessor;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ AdaptorEnv env = new AdaptorEnv();
+ msbMgmr.setAdaptorEnv(env);
+ MockitoAnnotations.initMocks(this);
+
+ String json = "{\"access_token\":\"1234567\"}";
+
+ when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(json);
+ }
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java
new file mode 100644
index 00000000..d445212a
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.impl;
+
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.http.client.ClientProtocolException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmNotifyLCMEventsRequest;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public class NslcmMgmrImplTest {
+ @InjectMocks
+ private NslcmMgmrImpl nslcmMgmr;
+
+ @Mock
+ private HttpClientProcessorInf httpClientProcessor;
+
+ private String vnfInstanceId = "vnfInstanceId_001";
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ AdaptorEnv env = new AdaptorEnv();
+ nslcmMgmr.setAdaptorEnv(env);
+ MockitoAnnotations.initMocks(this);
+
+ String json = "{\"access_token\":\"1234567\"}";
+
+ when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(json);
+ }
+
+ @Test
+ public void testGrantVnf() throws ClientProtocolException, IOException
+ {
+ NslcmGrantVnfRequest cbamRequest = new NslcmGrantVnfRequest();
+ NslcmGrantVnfResponse response = nslcmMgmr.grantVnf(cbamRequest);
+ }
+
+ @Test
+ public void testNotifyVnf() throws ClientProtocolException, IOException
+ {
+ NslcmNotifyLCMEventsRequest cbamRequest = new NslcmNotifyLCMEventsRequest();
+ nslcmMgmr.notifyVnf(cbamRequest, vnfInstanceId);
+ }
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vfcadaptor/VfcadaptorApplicationTests.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vfcadaptor/VfcadaptorApplicationTests.java
index 288770f5..ecf77fc3 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vfcadaptor/VfcadaptorApplicationTests.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vfcadaptor/VfcadaptorApplicationTests.java
@@ -21,12 +21,15 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
+import static org.assertj.core.api.Assertions.assertThat;
+
@RunWith(SpringRunner.class)
-@SpringBootTest
+//@SpringBootTest
public class VfcadaptorApplicationTests {
@Test
- public void contextLoads() {
+ public void aapTest() {
+ assertThat("kcom").isEqualTo("kcom");
}
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverControllerTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverControllerTest.java
new file mode 100644
index 00000000..82e06dfe
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverControllerTest.java
@@ -0,0 +1,283 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.controller;
+
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import org.apache.http.HttpStatus;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository.VnfmJobExecutionRepository;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.OperStatusVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.QueryVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfmDriverMgmrInf;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+public class VnfmDriverControllerTest {
+ @Mock
+ private VnfmDriverMgmrInf vnfmDriverMgmr;
+
+ @InjectMocks
+ private VnfmDriverController controller;
+
+ private MockMvc mockMvc;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mockMvc = MockMvcBuilders.standaloneSetup(controller).build();
+ }
+
+ @Test
+ public void testInstantiateVnf() throws Exception {
+ InstantiateVnfResponse mockResponse = new InstantiateVnfResponse();
+ mockResponse.setJobId("job_001");
+ mockResponse.setVnfInstanceId("vnfInstanceId_001");
+ String jsonString = "{\"vnfInstanceName\":\"vnfInstanceName_001\",\"vnfPackageId\":\"1\"}";
+
+ when(vnfmDriverMgmr.instantiateVnf(Mockito.any(InstantiateVnfRequest.class), Mockito.anyString())).thenReturn(mockResponse);
+
+ String responseString = mockMvc.perform(
+ post("/api/nokiavnfmdriver/v1/vnfmId_001/vnfs").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON).
+ content(jsonString))
+ .andDo(print())
+ .andExpect(status().isCreated())
+ .andReturn().getResponse().getContentAsString();
+
+ JSONObject jsonObj = new JSONObject(responseString);
+ Assert.assertEquals("jobId is ", mockResponse.getJobId(), jsonObj.get("jobId"));
+ Assert.assertEquals("vnfInstanceId is ", mockResponse.getVnfInstanceId(), jsonObj.get("vnfInstanceId"));
+ }
+
+ @Test
+ public void testTerminateVnf() throws Exception {
+ TerminateVnfResponse mockResponse = new TerminateVnfResponse();
+ mockResponse.setJobId("job_002");
+ String jsonString = "{\"vnfInstanceName\":\"vnfInstanceName_001\",\"vnfPackageId\":\"1\"}";
+
+ when(vnfmDriverMgmr.terminateVnf(Mockito.any(TerminateVnfRequest.class), Mockito.anyString(), Mockito.anyString())).thenReturn(mockResponse);
+
+ String responseString = mockMvc.perform(
+ post("/api/nokiavnfmdriver/v1/vnfmId_002/vnfs/vnfInstanceId_002/terminate").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON).
+ content(jsonString))
+ .andDo(print())
+ .andExpect(status().isCreated())
+ .andReturn().getResponse().getContentAsString();
+
+ JSONObject jsonObj = new JSONObject(responseString);
+ Assert.assertEquals("jobId is ", mockResponse.getJobId(), jsonObj.get("jobId"));
+ }
+
+ @Test
+ public void testTerminateVnfException() throws Exception {
+ String jsonString = "{\"vnfInstanceName\":\"vnfInstanceName_001\",\"vnfPackageId\":\"1\"}";
+ VnfmDriverException exception = new VnfmDriverException(HttpStatus.SC_BAD_REQUEST, "vnfInstanceId is wrong");
+ when(vnfmDriverMgmr.terminateVnf(Mockito.any(TerminateVnfRequest.class), Mockito.anyString(), Mockito.anyString())).thenThrow(exception);
+
+ String erroMsg = mockMvc.perform(
+ post("/api/nokiavnfmdriver/v1/vnfmId_002/vnfs/vnfInstanceId_002/terminate").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON).
+ content(jsonString))
+ .andDo(print())
+ .andExpect(status().isBadRequest())
+ .andReturn().getResponse().getErrorMessage();
+
+ Assert.assertEquals("Error Message is ", exception.getMessage(), erroMsg);
+ }
+
+ @Test
+ public void testGetOperStatus() throws Exception {
+ OperStatusVnfResponse mockResponse = new OperStatusVnfResponse();
+ mockResponse.setJobId("jobId_003");
+ when(vnfmDriverMgmr.getOperStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(mockResponse);
+
+ String responseString = mockMvc.perform(
+ get("/api/nokiavnfmdriver/v1/vnfmId_002/jobs/jobId_001").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated())
+ .andReturn().getResponse().getContentAsString();
+
+ JSONObject jsonObj = new JSONObject(responseString);
+ Assert.assertEquals("jobId is ", mockResponse.getJobId(), jsonObj.get("jobId"));
+ }
+
+ @Test
+ public void testGetOperStatusException() throws Exception {
+ VnfmDriverException exception = new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
+ when(vnfmDriverMgmr.getOperStatus( Mockito.anyString(), Mockito.anyString())).thenThrow(exception);
+
+ String erroMsg = mockMvc.perform(
+ get("/api/nokiavnfmdriver/v1/vnfmId_002/jobs/jobId_002").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON))
+ .andDo(print())
+ .andExpect(status().isInternalServerError())
+ .andReturn().getResponse().getErrorMessage();
+
+ Assert.assertEquals("Error Message is ", exception.getMessage(), erroMsg);
+ }
+
+ @Test
+ public void testQueryVnf() throws Exception {
+ QueryVnfResponse mockResponse = new QueryVnfResponse();
+ mockResponse.setVnfdId("vnfdId_001");
+ when(vnfmDriverMgmr.queryVnf(Mockito.anyString(), Mockito.anyString())).thenReturn(mockResponse);
+
+ String responseString = mockMvc.perform(
+ get("/api/nokiavnfmdriver/v1/vnfmId_002/vnfs/vnfInstanceId_001").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated())
+ .andReturn().getResponse().getContentAsString();
+
+ JSONObject jsonObj = new JSONObject(responseString);
+ Assert.assertEquals("VnfdId is ", mockResponse.getVnfdId(), jsonObj.get("vnfdId"));
+ }
+
+ @Test
+ public void testQueryVnfException() throws Exception {
+ VnfmDriverException exception = new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
+ when(vnfmDriverMgmr.queryVnf( Mockito.anyString(), Mockito.anyString())).thenThrow(exception);
+
+ String erroMsg = mockMvc.perform(
+ get("/api/nokiavnfmdriver/v1/vnfmId_002/vnfs/vnfInstanceId_001").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON))
+ .andDo(print())
+ .andExpect(status().isInternalServerError())
+ .andReturn().getResponse().getErrorMessage();
+
+ Assert.assertEquals("Error Message is ", exception.getMessage(), erroMsg);
+ }
+
+ @Test
+ public void testScaleVnf() throws Exception {
+ ScaleVnfResponse mockResponse = new ScaleVnfResponse();
+ mockResponse.setJobId("job_002");
+ String jsonString = "{\"vnfInstanceId\":\"vnfInstanceId_003\",\"vnfPackageId\":\"1\"}";
+
+ when(vnfmDriverMgmr.scaleVnf(Mockito.any(ScaleVnfRequest.class), Mockito.anyString(), Mockito.anyString())).thenReturn(mockResponse);
+
+ String responseString = mockMvc.perform(
+ post("/api/nokiavnfmdriver/v1/vnfmId_002/vnfs/vnfInstanceId_003/scale").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON).
+ content(jsonString))
+ .andDo(print())
+ .andExpect(status().isCreated())
+ .andReturn().getResponse().getContentAsString();
+
+ JSONObject jsonObj = new JSONObject(responseString);
+ Assert.assertEquals("jobId is ", mockResponse.getJobId(), jsonObj.get("jobId"));
+ }
+
+ @Test
+ public void testScaleVnfException() throws Exception {
+ String jsonString = "{\"vnfInstanceName\":\"vnfInstanceName_001\",\"vnfPackageId\":\"1\"}";
+ VnfmDriverException exception = new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
+ when(vnfmDriverMgmr.scaleVnf(Mockito.any(ScaleVnfRequest.class), Mockito.anyString(), Mockito.anyString())).thenThrow(exception);
+
+ String erroMsg = mockMvc.perform(
+ post("/api/nokiavnfmdriver/v1/vnfmId_002/vnfs/vnfInstanceId_002/scale").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON).
+ content(jsonString))
+ .andDo(print())
+ .andExpect(status().isInternalServerError())
+ .andReturn().getResponse().getErrorMessage();
+
+ Assert.assertEquals("Error Message is ", exception.getMessage(), erroMsg);
+ }
+ @Test
+ public void testHealVnf() throws Exception {
+ HealVnfResponse mockResponse = new HealVnfResponse();
+ mockResponse.setJobId("job_002");
+ String jsonString = "{\"vnfInstanceId\":\"vnfInstanceId_003\",\"vnfPackageId\":\"1\"}";
+
+ when(vnfmDriverMgmr.healVnf(Mockito.any(HealVnfRequest.class), Mockito.anyString(), Mockito.anyString())).thenReturn(mockResponse);
+
+ String responseString = mockMvc.perform(
+ post("/api/nokiavnfmdriver/v1/vnfmId_002/vnfs/vnfInstanceId_003/heal").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON).
+ content(jsonString))
+ .andDo(print())
+ .andExpect(status().isCreated())
+ .andReturn().getResponse().getContentAsString();
+
+ JSONObject jsonObj = new JSONObject(responseString);
+ Assert.assertEquals("jobId is ", mockResponse.getJobId(), jsonObj.get("jobId"));
+ }
+
+ @Test
+ public void testHealVnfException() throws Exception {
+ String jsonString = "{\"vnfInstanceName\":\"vnfInstanceName_001\",\"vnfPackageId\":\"1\"}";
+ VnfmDriverException exception = new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
+ when(vnfmDriverMgmr.healVnf(Mockito.any(HealVnfRequest.class), Mockito.anyString(), Mockito.anyString())).thenThrow(exception);
+
+ String erroMsg = mockMvc.perform(
+ post("/api/nokiavnfmdriver/v1/vnfmId_002/vnfs/vnfInstanceId_002/heal").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON).
+ content(jsonString))
+ .andDo(print())
+ .andExpect(status().isInternalServerError())
+ .andReturn().getResponse().getErrorMessage();
+
+ Assert.assertEquals("Error Message is ", exception.getMessage(), erroMsg);
+ }
+
+}