Dependency inject Retrofit client for SDCCatalogService 82/140182/1
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 11 Feb 2025 08:38:25 +0000 (09:38 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 11 Feb 2025 08:38:25 +0000 (09:38 +0100)
- same as the rest of this service
- define *ClientProperties to have autocompletion and
  property validation in application.properties

Issue-ID: USECASEUI-862
Change-Id: Ie8c58470ca5977d82ad9e0468b3cfbedc32e6e63
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
server/src/main/java/org/onap/usecaseui/server/config/AAIClientProperties.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/config/SDCClientConfig.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/config/SDCClientProperties.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/config/SOClientProperties.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/csmf/config/SlicingProperties.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
server/src/main/resources/application.properties
server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java
server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceIntegrationTest.java [new file with mode: 0644]
server/src/test/resources/__files/serviceTemplateResponse.json [new file with mode: 0644]

diff --git a/server/src/main/java/org/onap/usecaseui/server/config/AAIClientProperties.java b/server/src/main/java/org/onap/usecaseui/server/config/AAIClientProperties.java
new file mode 100644 (file)
index 0000000..1867c0c
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2025 Deutsche Telekom.
+ *
+ * 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.usecaseui.server.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import lombok.Data;
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "uui-server.client.aai")
+public class AAIClientProperties {
+  String baseUrl;
+  String username;
+  String password;
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/config/SDCClientConfig.java b/server/src/main/java/org/onap/usecaseui/server/config/SDCClientConfig.java
new file mode 100644 (file)
index 0000000..4588521
--- /dev/null
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2025 Deutsche Telekom.
+ *
+ * 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.usecaseui.server.config;
+
+import java.io.IOException;
+
+import org.onap.usecaseui.server.service.intent.IntentSoService;
+import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
+import org.onap.usecaseui.server.service.lcm.domain.so.SOService;
+import org.onap.usecaseui.server.service.slicingdomain.so.SOSliceService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+
+import okhttp3.Credentials;
+import okhttp3.Interceptor;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import retrofit2.Retrofit;
+import retrofit2.converter.jackson.JacksonConverterFactory;
+
+@Configuration
+public class SDCClientConfig {
+
+    @Value("${uui-server.client.sdc.baseUrl}")
+    String baseUrl;
+    @Value("${uui-server.client.sdc.username}")
+    String username;
+    @Value("${uui-server.client.sdc.password}")
+    String password;
+
+    OkHttpClient okHttpClient() {
+        return new OkHttpClient().newBuilder().addInterceptor(new Interceptor() {
+            @Override
+            public okhttp3.Response intercept(Chain chain) throws IOException {
+                Request originalRequest = chain.request();
+                Request.Builder builder = originalRequest.newBuilder()
+                    .header("Authorization", Credentials.basic(username, password))
+                    .header(HttpHeaders.ACCEPT, "application/json")
+                    .header("X-ECOMP-InstanceID", "777");
+                Request newRequest = builder.build();
+                return chain.proceed(newRequest);
+            }
+        }).build();
+    }
+
+    Retrofit retrofit() {
+        return new Retrofit.Builder()
+            .baseUrl(baseUrl)
+            .addConverterFactory(JacksonConverterFactory.create())
+            .client(okHttpClient())
+            .build();
+    }
+
+    @Bean
+    SDCCatalogService sdcCatalogService() {
+        return retrofit().create(SDCCatalogService.class);
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/config/SDCClientProperties.java b/server/src/main/java/org/onap/usecaseui/server/config/SDCClientProperties.java
new file mode 100644 (file)
index 0000000..e5f7081
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2025 Deutsche Telekom.
+ *
+ * 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.usecaseui.server.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import lombok.Data;
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "uui-server.client.sdc")
+public class SDCClientProperties {
+  String username;
+  String password;
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/config/SOClientProperties.java b/server/src/main/java/org/onap/usecaseui/server/config/SOClientProperties.java
new file mode 100644 (file)
index 0000000..8769e0e
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2025 Deutsche Telekom.
+ *
+ * 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.usecaseui.server.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import lombok.Data;
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "uui-server.client.so")
+public class SOClientProperties {
+  String baseUrl;
+  String username;
+  String password;
+}
index 47ad089..6d5abd0 100644 (file)
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2025 Deutsche Telekom.
+ *
+ * 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.usecaseui.server.service.csmf.config;
 
 import org.springframework.boot.context.properties.ConfigurationProperties;
index ead2ef5..f52640d 100644 (file)
@@ -1,6 +1,9 @@
 /**
  * Copyright 2016-2017 ZTE Corporation.
  *
+ * ================================================================================
+ * Modifications Copyright (C) 2025 Deutsche Telekom.
+ * ================================================================================
  * 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
@@ -29,6 +32,8 @@ import java.util.List;
 
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletRequest;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 
 import org.onap.usecaseui.server.bean.ServiceBean;
 import org.onap.usecaseui.server.bean.lcm.VfNsPackageInfo;
@@ -57,40 +62,22 @@ import okhttp3.RequestBody;
 import okhttp3.ResponseBody;
 import retrofit2.Response;
 
+@Slf4j
+@RequiredArgsConstructor
 @Service("PackageDistributionService")
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
 public class DefaultPackageDistributionService implements PackageDistributionService {
 
-    private static final Logger logger = LoggerFactory.getLogger(DefaultPackageDistributionService.class);
+    private final SDCCatalogService sdcCatalogService;
+    private final VfcService vfcService;
+    private final ServiceLcmService serviceLcmService;
 
-    private SDCCatalogService sdcCatalogService;
-
-    private VfcService vfcService;
-    
-    @Resource(name="ServiceLcmService")
-    private ServiceLcmService serviceLcmService;
-
-    public DefaultPackageDistributionService() {
-        this(create(SDCCatalogService.class), create(VfcService.class));
-    }
-
-    public DefaultPackageDistributionService(SDCCatalogService sdcCatalogService, VfcService vfcService) {
-        this.sdcCatalogService = sdcCatalogService;
-        this.vfcService = vfcService;
-    }
-
-    public void setServiceLcmService(ServiceLcmService serviceLcmService) {
-        this.serviceLcmService = serviceLcmService;
-    }
-    
     @Override
     public VfNsPackageInfo retrievePackageInfo() {
-            List<SDCServiceTemplate> nsTemplate = sdcNsPackageInfo();
-            List<Vnf> vnf = sdcVfPackageInfo();
-            return new VfNsPackageInfo(nsTemplate, vnf);
+        List<SDCServiceTemplate> nsTemplate = sdcNsPackageInfo();
+        List<Vnf> vnf = sdcVfPackageInfo();
+        return new VfNsPackageInfo(nsTemplate, vnf);
     }
-    
+
     @Override
     public List<Vnf> sdcVfPackageInfo() {
         try {
@@ -98,15 +85,15 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
             if (response.isSuccessful()) {
                 return response.body();
             } else {
-                logger.info(String.format("Can not get VF resources[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get VF resources[code=%s, message=%s]", response.code(), response.message()));
                 return Collections.emptyList();
             }
         } catch (IOException e) {
-            logger.error("sdcVfPackageInfo occur exception.Details:"+e.getMessage());
+            log.error("sdcVfPackageInfo occur exception.Details:"+e.getMessage());
         }
         return null;
     }
-    
+
     @Override
     public List<SDCServiceTemplate> sdcNsPackageInfo() {
         try {
@@ -114,15 +101,15 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
             if (response.isSuccessful()) {
                 return response.body();
             } else {
-                logger.info(String.format("Can not get NS services[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get NS services[code=%s, message=%s]", response.code(), response.message()));
                 return Collections.emptyList();
             }
         } catch (IOException e) {
-            logger.error("sdcNsPackageInfo occur exception.Details:"+e.getMessage());
+            log.error("sdcNsPackageInfo occur exception.Details:"+e.getMessage());
         }
         return null;
     }
-    
+
     @Override
     public DistributionResult postNsPackage(Csar csar) {
         try {
@@ -130,7 +117,7 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
             if (response.isSuccessful()) {
                 return response.body();
             } else {
-                logger.info(String.format("Can not post NS packages[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not post NS packages[code=%s, message=%s]", response.code(), response.message()));
                 throw new VfcException("VFC service is not available!");
             }
         } catch (IOException e) {
@@ -145,7 +132,7 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
             if (response.isSuccessful()) {
                 return response.body();
             } else {
-                logger.info(String.format("Can not get VF packages[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get VF packages[code=%s, message=%s]", response.code(), response.message()));
                 throw new VfcException("VFC service is not available!");
             }
         } catch (IOException e) {
@@ -160,27 +147,27 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
             if (response.isSuccessful()) {
                 return response.body();
             } else {
-                logger.info(String.format("Can not get Job status[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get Job status[code=%s, message=%s]", response.code(), response.message()));
                 throw new VfcException("VFC service is not available!");
             }
         } catch (IOException e) {
             throw new VfcException("VFC service is not available!", e);
         }
     }
-    
+
     @Override
     public JobStatus getNsLcmJobStatus(String serviceInstanceId,String jobId, String responseId,String operationType) {        try {
         Response<JobStatus> response = vfcService.getNsLcmJobStatus(jobId, responseId).execute();
         if (response.isSuccessful()) {
             return response.body();
         } else {
-            logger.info(String.format("Can not get Job status[code=%s, message=%s]", response.code(), response.message()));
+            log.info(String.format("Can not get Job status[code=%s, message=%s]", response.code(), response.message()));
             throw new VfcException("VFC service getNsLcmJobStatus is not available!");
         }
     } catch (IOException e) {
         throw new VfcException("VFC service getNsLcmJobStatus is not available!", e);
     }}
-    
+
     @Override
     public DistributionResult deleteNsPackage(String csarId) {
         try {
@@ -188,7 +175,7 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
             if (response.isSuccessful()) {
                 return response.body();
             } else {
-                logger.info(String.format("Can not delete NS packages[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not delete NS packages[code=%s, message=%s]", response.code(), response.message()));
                 throw new VfcException("VFC service is not available!");
             }
         } catch (IOException e) {
@@ -203,7 +190,7 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
             if (response.isSuccessful()) {
                 return response.body();
             } else {
-                logger.info(String.format("Can not delete VF packages[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not delete VF packages[code=%s, message=%s]", response.code(), response.message()));
                 throw new VfcException("VFC service is not available!");
             }
         } catch (IOException e) {
@@ -215,17 +202,17 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
     public String getVnfPackages() {
         String result="";
         try {
-            logger.info("vfc getVnfPackages is starting!");
+            log.info("vfc getVnfPackages is starting!");
             Response<ResponseBody> response = this.vfcService.getVnfPackages().execute();
-            logger.info("vfc getVnfPackages has finished!");
+            log.info("vfc getVnfPackages has finished!");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
-                logger.info(String.format("Can not get getVnfPackages[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get getVnfPackages[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("getVnfPackages occur exception:"+e);
+            log.error("getVnfPackages occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
@@ -236,21 +223,21 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc getNetworkServicePackages is starting!");
+            log.info("vfc getNetworkServicePackages is starting!");
             Response<ResponseBody> response = this.vfcService.getNetworkServicePackages().execute();
-            logger.info("vfc getNetworkServicePackages has finished!");
+            log.info("vfc getNetworkServicePackages has finished!");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
-                logger.info(String.format("Can not get getNetworkServicePackages[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get getNetworkServicePackages[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("getNetworkServicePackages occur exception:"+e);
+            log.error("getNetworkServicePackages occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -258,21 +245,21 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc getPnfPackages is starting!");
+            log.info("vfc getPnfPackages is starting!");
             Response<ResponseBody> response = this.vfcService.getPnfPackages().execute();
-            logger.info("vfc getPnfPackages has finished!");
+            log.info("vfc getPnfPackages has finished!");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
-                logger.info(String.format("Can not get getPnfPackages[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get getPnfPackages[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("getPnfPackages occur exception:"+e);
+            log.error("getPnfPackages occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -280,21 +267,21 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc downLoadNsPackage is starting!");
+            log.info("vfc downLoadNsPackage is starting!");
             Response<ResponseBody> response = this.vfcService.downLoadNsPackage(nsdInfoId).execute();
-            logger.info("vfc downLoadNsPackage has finished!");
+            log.info("vfc downLoadNsPackage has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get downLoadNsPackage[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get downLoadNsPackage[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("downLoadNsPackage occur exception:"+e);
+            log.error("downLoadNsPackage occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -302,21 +289,21 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc downLoadPnfPackage is starting!");
+            log.info("vfc downLoadPnfPackage is starting!");
             Response<ResponseBody> response = this.vfcService.downLoadNsPackage(pnfdInfoId).execute();
-            logger.info("vfc downLoadPnfPackage has finished!");
+            log.info("vfc downLoadPnfPackage has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get downLoadPnfPackage[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get downLoadPnfPackage[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("downLoadPnfPackage occur exception:"+e);
+            log.error("downLoadPnfPackage occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -324,21 +311,21 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc downLoadVnfPackage is starting!");
+            log.info("vfc downLoadVnfPackage is starting!");
             Response<ResponseBody> response = this.vfcService.downLoadNsPackage(vnfPkgId).execute();
-            logger.info("vfc downLoadVnfPackage has finished!");
+            log.info("vfc downLoadVnfPackage has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get downLoadVnfPackage[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get downLoadVnfPackage[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("downLoadVnfPackage occur exception:"+e);
+            log.error("downLoadVnfPackage occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -346,24 +333,24 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
         Response<ResponseBody> response=null;
         String result="";
         try {
-            logger.info("vfc deleteNsdPackage is starting!");
+            log.info("vfc deleteNsdPackage is starting!");
             response = this.vfcService.deleteNsdPackage(nsdInfoId).execute();
-            logger.info("vfc deleteNsdPackage has finished!");
+            log.info("vfc deleteNsdPackage has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get deleteNsdPackage[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get deleteNsdPackage[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
             if(e.getMessage().contains("204")){
                 return CommonConstant.CONSTANT_SUCCESS;
             }
-            logger.error("deleteNsdPackage occur exception:"+e);
+            log.error("deleteNsdPackage occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -371,24 +358,24 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
         Response<ResponseBody> response=null;
         String result="";
         try {
-            logger.info("vfc deleteVnfPackage is starting!");
+            log.info("vfc deleteVnfPackage is starting!");
             response = this.vfcService.deleteVnfdPackage(vnfPkgId).execute();
-            logger.info("vfc deleteVnfPackage has finished!");
+            log.info("vfc deleteVnfPackage has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get deleteNsdPackage[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get deleteNsdPackage[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
             if(e.getMessage().contains("204")){
                 return CommonConstant.CONSTANT_SUCCESS;
             }
-            logger.error("deleteVnfPackage occur exception:"+e);
+            log.error("deleteVnfPackage occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -396,33 +383,33 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
         Response<ResponseBody> response=null;
         String result="";
         try {
-            logger.info("vfc deletePnfPackage is starting!");
+            log.info("vfc deletePnfPackage is starting!");
             response = this.vfcService.deletePnfdPackage(pnfdInfoId).execute();
-            logger.info("vfc deletePnfPackage has finished!");
+            log.info("vfc deletePnfPackage has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get deletePnfPackage[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get deletePnfPackage[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
             if(e.getMessage().contains("204")){
                 return CommonConstant.CONSTANT_SUCCESS;
             }
-            logger.error("deletePnfPackage occur exception:"+e);
+            log.error("deletePnfPackage occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
     public List<String> getNetworkServiceInfo() {
         List<String> result = new ArrayList<>();
         try {
-            logger.info("vfc getNetworkServiceInfo is starting!");
+            log.info("vfc getNetworkServiceInfo is starting!");
             Response<nsServiceRsp> response = this.vfcService.getNetworkServiceInfo().execute();
-            logger.info("vfc getNetworkServiceInfo has finished!");
+            log.info("vfc getNetworkServiceInfo has finished!");
             if (response.isSuccessful()) {
                 List<String> nsServices = response.body().nsServices;
                 if(nsServices.size()>0){
@@ -437,33 +424,33 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
                 }
                 return result;
             } else {
-                logger.info(String.format("Can not get getNetworkServiceInfo[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get getNetworkServiceInfo[code=%s, message=%s]", response.code(), response.message()));
                 return Collections.emptyList();
             }
         } catch (IOException e) {
-            logger.error("getNetworkServiceInfo occur exception:"+e);
+            log.error("getNetworkServiceInfo occur exception:"+e);
             return Collections.emptyList();
         }
-    
+
     }
 
     @Override
     public String createNetworkServiceInstance(HttpServletRequest request) {
         String result = "";
         try {
-            logger.info("aai createNetworkServiceInstance is starting");
+            log.info("aai createNetworkServiceInstance is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.createNetworkServiceInstance(requestBody).execute();
-            logger.info("aai createNetworkServiceInstance has finished");
+            log.info("aai createNetworkServiceInstance has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not createNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not createNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("createNetworkServiceInstance occur exception:"+e);
+            log.error("createNetworkServiceInstance occur exception:"+e);
         }
         return result;
     }
@@ -473,43 +460,43 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
         Response response = null;
         String result="";
         try {
-            logger.info("vfc deleteNetworkServiceInstance is starting!");
+            log.info("vfc deleteNetworkServiceInstance is starting!");
             response = this.vfcService.deleteNetworkServiceInstance(nsInstanceId).execute();
-            logger.info("vfc deleteNetworkServiceInstance has finished!");
+            log.info("vfc deleteNetworkServiceInstance has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get deleteNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get deleteNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
             if(e.getMessage().contains("204")){
                 return CommonConstant.CONSTANT_SUCCESS;
             }
-            logger.error("deleteNetworkServiceInstance occur exception:"+e);
+            log.error("deleteNetworkServiceInstance occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;
         }
         return result;
-    
+
     }
 
     @Override
     public String terminateNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId) {
         String result = "";
         try {
-            logger.info("aai terminateNetworkServiceInstance is starting");
+            log.info("aai terminateNetworkServiceInstance is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.terminateNetworkServiceInstance(networkServiceInstanceId,requestBody).execute();
-            logger.info("aai terminateNetworkServiceInstance has finished");
+            log.info("aai terminateNetworkServiceInstance has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not terminateNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not terminateNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("terminateNetworkServiceInstance occur exception:"+e);
+            log.error("terminateNetworkServiceInstance occur exception:"+e);
         }
         return result;
     }
@@ -518,19 +505,19 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
     public String healNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId) {
         String result = "";
         try {
-            logger.info("aai healNetworkServiceInstance is starting");
+            log.info("aai healNetworkServiceInstance is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.healNetworkServiceInstance(networkServiceInstanceId,requestBody).execute();
-            logger.info("aai healNetworkServiceInstance has finished");
+            log.info("aai healNetworkServiceInstance has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not healNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not healNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("healNetworkServiceInstance occur exception:"+e);
+            log.error("healNetworkServiceInstance occur exception:"+e);
         }
         return result;
     }
@@ -539,19 +526,19 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
     public String scaleNetworkServiceInstance(HttpServletRequest request,String networkServiceInstanceId) {
         String result = "";
         try {
-            logger.info("aai scaleNetworkServiceInstance is starting");
+            log.info("aai scaleNetworkServiceInstance is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.scaleNetworkServiceInstance(networkServiceInstanceId,requestBody).execute();
-            logger.info("aai scaleNetworkServiceInstance has finished");
+            log.info("aai scaleNetworkServiceInstance has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not scaleNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not scaleNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("scaleNetworkServiceInstance occur exception:"+e);
+            log.error("scaleNetworkServiceInstance occur exception:"+e);
         }
         return result;
     }
@@ -560,19 +547,19 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
     public String createNetworkServiceData(HttpServletRequest request) {
         String result = "";
         try {
-            logger.info("aai createNetworkServiceData is starting");
+            log.info("aai createNetworkServiceData is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.createNetworkServiceData(requestBody).execute();
-            logger.info("aai createNetworkServiceData has finished");
+            log.info("aai createNetworkServiceData has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not createNetworkServiceData[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not createNetworkServiceData[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("createNetworkServiceData occur exception:"+e);
+            log.error("createNetworkServiceData occur exception:"+e);
         }
         return result;
     }
@@ -581,19 +568,19 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
     public String createVnfData(HttpServletRequest request) {
         String result = "";
         try {
-            logger.info("aai createVnfData is starting");
+            log.info("aai createVnfData is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.createVnfData(requestBody).execute();
-            logger.info("aai createVnfData has finished");
+            log.info("aai createVnfData has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not createVnfData[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not createVnfData[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("createVnfData occur exception:"+e);
+            log.error("createVnfData occur exception:"+e);
         }
         return result;
     }
@@ -602,19 +589,19 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
     public String createPnfData(HttpServletRequest request) {
         String result = "";
         try {
-            logger.info("aai createPnfData is starting");
+            log.info("aai createPnfData is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.createPnfData(requestBody).execute();
-            logger.info("aai createPnfData has finished");
+            log.info("aai createPnfData has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not createPnfData[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not createPnfData[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("createPnfData occur exception:"+e);
+            log.error("createPnfData occur exception:"+e);
         }
         return result;
     }
@@ -624,21 +611,21 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc getNsdInfo is starting!");
+            log.info("vfc getNsdInfo is starting!");
             Response<ResponseBody> response = this.vfcService.getNsdInfo(nsdInfoId).execute();
-            logger.info("vfc getNsdInfo has finished!");
+            log.info("vfc getNsdInfo has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get getNsdInfo[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get getNsdInfo[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("getNsdInfo occur exception:"+e);
+            log.error("getNsdInfo occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -646,21 +633,21 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc getVnfInfo is starting!");
+            log.info("vfc getVnfInfo is starting!");
             Response<ResponseBody> response = this.vfcService.getVnfInfo(vnfPkgId).execute();
-            logger.info("vfc getVnfInfo has finished!");
+            log.info("vfc getVnfInfo has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get getVnfInfo[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get getVnfInfo[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("getVnfInfo occur exception:"+e);
+            log.error("getVnfInfo occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -668,21 +655,21 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc getPnfInfo is starting!");
+            log.info("vfc getPnfInfo is starting!");
             Response<ResponseBody> response = this.vfcService.getPnfInfo(pnfdInfoId).execute();
-            logger.info("vfc getPnfInfo has finished!");
+            log.info("vfc getPnfInfo has finished!");
             if (response.isSuccessful()) {
                 result= CommonConstant.CONSTANT_SUCCESS;
             } else {
-                logger.info(String.format("Can not get getPnfInfo[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get getPnfInfo[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("getPnfInfo occur exception:"+e);
+            log.error("getPnfInfo occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
@@ -690,44 +677,44 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc listNsTemplates is starting!");
+            log.info("vfc listNsTemplates is starting!");
             Response<ResponseBody> response = this.vfcService.listNsTemplates().execute();
-            logger.info("vfc listNsTemplates has finished!");
+            log.info("vfc listNsTemplates has finished!");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
-                logger.info(String.format("Can not get listNsTemplates[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get listNsTemplates[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("listNsTemplates occur exception:"+e);
+            log.error("listNsTemplates occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 
     @Override
     public String fetchNsTemplateData(HttpServletRequest request) {
         String result = "";
         try {
-            logger.info("aai fetchNsTemplateData is starting");
+            log.info("aai fetchNsTemplateData is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.fetchNsTemplateData(requestBody).execute();
-            logger.info("aai fetchNsTemplateData has finished");
+            log.info("aai fetchNsTemplateData has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not fetchNsTemplateData[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not fetchNsTemplateData[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("fetchNsTemplateData occur exception:"+e);
+            log.error("fetchNsTemplateData occur exception:"+e);
         }
         return result;
     }
-    
+
     @Override
     public JSONObject fetchCCVPNTemplateData(HttpServletRequest request, String csarId) {
         JSONObject result = new JSONObject();
@@ -738,37 +725,37 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
             if (getResponse.isSuccessful()) {
                 // call vfc template parser
-                logger.info("calling ccvpn template file parser is starting");
+                log.info("calling ccvpn template file parser is starting");
                 Response<ResponseBody> response = vfcService.fetchTemplateInfo(requestBody).execute();
-                logger.info("calling ccvpn template file parser has finished");
+                log.info("calling ccvpn template file parser has finished");
                 if (response.isSuccessful()) {
                     result.put("status", CommonConstant.CONSTANT_SUCCESS);
                     result.put("result", JSONObject.parseObject(new String(response.body().bytes())));
                 } else {
                     result.put("status", CommonConstant.CONSTANT_FAILED);
                     result.put("error", String.format("Can not parse ccvpn template file. Detail Info [code=%s, message=%s]", response.code(), response.message()));
-                    logger.error(String.format("Can not parse ccvpn template file. Detail Info [code=%s, message=%s]", response.code(), response.message()));
+                    log.error(String.format("Can not parse ccvpn template file. Detail Info [code=%s, message=%s]", response.code(), response.message()));
                }
             } else {
                 // distribute template files to vfc catalog
                 Response<ResponseBody> postResponse = this.vfcService.servicePackages(requestBody).execute();
                 if (postResponse.isSuccessful()) {
                     // call vfc template parser
-                    logger.info("calling ccvpn template file parser is starting");
+                    log.info("calling ccvpn template file parser is starting");
                     Response<ResponseBody> response = vfcService.fetchTemplateInfo(requestBody).execute();
-                    logger.info("calling ccvpn template file parser has finished");
+                    log.info("calling ccvpn template file parser has finished");
                     if (response.isSuccessful()) {
                         result.put("status", CommonConstant.CONSTANT_SUCCESS);
                         result.put("result",JSONObject.parseObject(new String(response.body().bytes())));
                     } else {
                         result.put("status", CommonConstant.CONSTANT_FAILED);
                         result.put("error",String.format("Can not parse ccvpn template file. Detail Info [code=%s, message=%s]", response.code(), response.message()));
-                        logger.error(String.format("Can not parse ccvpn template file. Detail Info [code=%s, message=%s]", response.code(), response.message()));
+                        log.error(String.format("Can not parse ccvpn template file. Detail Info [code=%s, message=%s]", response.code(), response.message()));
                     }
                 } else {
                     result.put("status", CommonConstant.CONSTANT_FAILED);
                     result.put("error",String.format("Can not distribute ccvpn template file. Detail Info [code=%s, message=%s]", postResponse.code(), postResponse.message()));
-                    logger.error(String.format("Can not distribute ccvpn template file. Detail Info [code=%s, message=%s]", postResponse.code(), postResponse.message()));
+                    log.error(String.format("Can not distribute ccvpn template file. Detail Info [code=%s, message=%s]", postResponse.code(), postResponse.message()));
                }
             }
         } catch (Exception e) {
@@ -777,24 +764,24 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
         }
         return result;
     }
-    
+
     @Override
     public String instantiateNetworkServiceInstance(HttpServletRequest request, String serviceInstanceId) {
         String result = "";
         try {
-            logger.info("aai instantiateNetworkServiceInstance is starting");
+            log.info("aai instantiateNetworkServiceInstance is starting");
             RequestBody requestBody = extractBody(request);
             Response<ResponseBody> response = vfcService.instantiateNetworkServiceInstance(requestBody,serviceInstanceId).execute();
-            logger.info("aai instantiateNetworkServiceInstance has finished");
+            log.info("aai instantiateNetworkServiceInstance has finished");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
                 result= CommonConstant.CONSTANT_FAILED;
-                logger.error(String.format("Can not instantiateNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
+                log.error(String.format("Can not instantiateNetworkServiceInstance[code=%s, message=%s]", response.code(), response.message()));
             }
         } catch (Exception e) {
             result= CommonConstant.CONSTANT_FAILED;
-            logger.error("instantiateNetworkServiceInstance occur exception:"+e);
+            log.error("instantiateNetworkServiceInstance occur exception:"+e);
         }
         return result;
     }
@@ -804,20 +791,20 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
 
         String result="";
         try {
-            logger.info("vfc getVnfInfoById is starting!");
+            log.info("vfc getVnfInfoById is starting!");
             Response<ResponseBody> response = this.vfcService.getVnfInfoById(vnfinstid).execute();
-            logger.info("vfc getVnfInfoById has finished!");
+            log.info("vfc getVnfInfoById has finished!");
             if (response.isSuccessful()) {
                 result=new String(response.body().bytes());
             } else {
-                logger.info(String.format("Can not get getVnfInfoById[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get getVnfInfoById[code=%s, message=%s]", response.code(), response.message()));
                 result= CommonConstant.CONSTANT_FAILED;;
             }
         } catch (IOException e) {
-            logger.error("getVnfInfoById occur exception:"+e);
+            log.error("getVnfInfoById occur exception:"+e);
             result= CommonConstant.CONSTANT_FAILED;;
         }
         return result;
-    
+
     }
 }
index af60202..59d534f 100644 (file)
@@ -16,6 +16,9 @@
 package org.onap.usecaseui.server.service.lcm.impl;
 
 import com.google.common.io.Files;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import okhttp3.ResponseBody;
 import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
 import org.onap.usecaseui.server.bean.lcm.TemplateInput;
@@ -50,25 +53,13 @@ import java.util.*;
 import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.CATEGORY_E2E_SERVICE;
 import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.DISTRIBUTION_STATUS_DISTRIBUTED;
 
+@Slf4j
+@RequiredArgsConstructor
 @Service("ServiceTemplateService")
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
 public class DefaultServiceTemplateService implements ServiceTemplateService {
 
-    private static final Logger logger = LoggerFactory.getLogger(DefaultServiceTemplateService.class);
-
-    private SDCCatalogService sdcCatalog;
-
-    private AAIService aaiService;
-
-    public DefaultServiceTemplateService() {
-        this(RestfulServices.create(SDCCatalogService.class), RestfulServices.create(AAIService.class));
-    }
-
-    public DefaultServiceTemplateService(SDCCatalogService sdcCatalog, AAIService aaiService) {
-        this.sdcCatalog = sdcCatalog;
-        this.aaiService = aaiService;
-    }
+    private final SDCCatalogService sdcCatalog;
+    private final AAIService aaiService;
 
     @Override
     public List<SDCServiceTemplate> listDistributedServiceTemplate() {
@@ -77,11 +68,11 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
             if (response.isSuccessful()) {
                 return response.body();
             } else {
-                logger.info(String.format("Can not get distributed e2e service templates[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get distributed e2e service templates[code=%s, message=%s]", response.code(), response.message()));
                 return Collections.emptyList();
             }
         } catch (IOException e) {
-            logger.error("Visit SDC Catalog occur exception");
+            log.error("Visit SDC Catalog occur exception");
             throw new SDCCatalogException("SDC Catalog is not available.", e);
         }
     }
@@ -110,11 +101,11 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
         try {
             String msbUrl = RestfulServices.getMsbAddress();
             String templateUrl = String.format("https://%s%s", msbUrl, toscaModelPath);
-            logger.info("download Csar File Url is:"+templateUrl);
+            log.info("download Csar File Url is:"+templateUrl);
             ResponseBody body = sdcCatalog.downloadCsar(templateUrl).execute().body();
             Files.write(body.bytes(),new File(toPath));
         } catch (IOException e) {
-            logger.error(String.format("Download %s failed!", toscaModelPath));
+            log.error(String.format("Download %s failed!", toscaModelPath));
             throw e;
         }
     }
@@ -145,7 +136,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
         }
         return serviceTemplateInput;
     }
-    
+
     private void appendLocationParameters(ServiceTemplateInput serviceTemplateInput, ToscaTemplate tosca) {
         for (NodeTemplate nodeTemplate : tosca.getNodeTemplates()) {
             String type = nodeTemplate.getMetaData().getValue("type");
@@ -274,7 +265,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
             SDCServiceTemplate template = response.body();
             return template.getToscaModelURL();
         } else {
-            logger.info(String.format("Cannot get tosca model for node template[%s]", nodeUUID));
+            log.info(String.format("Cannot get tosca model for node template[%s]", nodeUUID));
             return null;
         }
     }
@@ -353,11 +344,11 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
             if (response.isSuccessful()) {
                 return response.body().getCloudRegion();
             } else {
-                logger.info(String.format("Can not get vim info[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get vim info[code=%s, message=%s]", response.code(), response.message()));
                 return Collections.emptyList();
             }
         } catch (IOException e) {
-            logger.error("Visit AAI occur exception");
+            log.error("Visit AAI occur exception");
             throw new AAIException("AAI is not available.", e);
         }
     }
@@ -369,11 +360,11 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
             if (response.isSuccessful()) {
                 return response.body().getEsrThirdpartySdncList();
             } else {
-                logger.info(String.format("Can not get sdnc controllers[code=%s, message=%s]", response.code(), response.message()));
+                log.info(String.format("Can not get sdnc controllers[code=%s, message=%s]", response.code(), response.message()));
                 return Collections.emptyList();
             }
         } catch (IOException e) {
-            logger.error("Visit AAI occur exception");
+            log.error("Visit AAI occur exception");
             throw new AAIException("AAI is not available.", e);
         }
     }
index e489c96..61671ec 100644 (file)
@@ -62,6 +62,8 @@ uui-server.client.aai.password=AAI
 uui-server.client.so.baseUrl=http://so.onap:8080
 uui-server.client.so.username=InfraPortalClient
 uui-server.client.so.password=password1
+uui-server.client.sdc.username=aai
+uui-server.client.sdc.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
 uui-server.slicing.service-invariant-uuid=defaultServiceInvariantUuid
 uui-server.slicing.service-uuid=defaultServiceUuid
 uui-server.slicing.global-subscriber-id=defaultGlobalSubscriberId
index 68dd91c..fb93f08 100644 (file)
@@ -35,7 +35,6 @@ import org.onap.usecaseui.server.service.lcm.domain.aai.bean.nsServiceRsp;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.Vnf;
-import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException;
 import org.onap.usecaseui.server.service.lcm.domain.vfc.VfcService;
 import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.Csar;
 import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.DistributionResult;
@@ -136,7 +135,7 @@ public class DefaultPackageDistributionServiceTest {
         List<VimInfo> vim = Collections.singletonList(new VimInfo("owner", "regionId"));
         AAIService aaiService = newAAIService(vim);
 
-        PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null);
+        PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null, null);
 
         Assert.assertThat(service.retrievePackageInfo(), equalTo(new VfNsPackageInfo(serviceTemplate, vnf)));
     }
@@ -172,7 +171,7 @@ public class DefaultPackageDistributionServiceTest {
         List<VimInfo> vim = Collections.singletonList(new VimInfo("owner", "regionId"));
         AAIService aaiService = newAAIService(vim);
 
-        PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null);
+        PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null, null);
         service.retrievePackageInfo();
     }
 
@@ -185,7 +184,7 @@ public class DefaultPackageDistributionServiceTest {
         Call<List<Vnf>> resourceCall = emptyBodyCall();
         when(sdcService.listResources(RESOURCETYPE_VF)).thenReturn(resourceCall);
 
-        PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null);
+        PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null, null);
         VfNsPackageInfo vfNsPackageInfo = service.retrievePackageInfo();
 
         Assert.assertTrue("ns should be empty!", vfNsPackageInfo.getNsPackage().isEmpty());
@@ -201,7 +200,7 @@ public class DefaultPackageDistributionServiceTest {
         result.setStatusDescription("description");
         result.setErrorCode("errorcode");
         when(vfcService.distributeNsPackage(csar)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame(result, service.postNsPackage(csar));
     }
@@ -211,7 +210,7 @@ public class DefaultPackageDistributionServiceTest {
         VfcService vfcService = mock(VfcService.class);
         Csar csar = new Csar();
         when(vfcService.distributeNsPackage(csar)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.postNsPackage(csar);
     }
 
@@ -220,7 +219,7 @@ public class DefaultPackageDistributionServiceTest {
         VfcService vfcService = mock(VfcService.class);
         Csar csar = new Csar();
         when(vfcService.distributeNsPackage(csar)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.postNsPackage(csar);
     }
 
@@ -230,7 +229,7 @@ public class DefaultPackageDistributionServiceTest {
         Csar csar = new Csar();
         Job job = new Job();
         when(vfcService.distributeVnfPackage(csar)).thenReturn(successfulCall(job));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame(job, service.postVfPackage(csar));
     }
@@ -240,7 +239,7 @@ public class DefaultPackageDistributionServiceTest {
         VfcService vfcService = mock(VfcService.class);
         Csar csar = new Csar();
         when(vfcService.distributeVnfPackage(csar)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.postVfPackage(csar);
     }
 
@@ -249,7 +248,7 @@ public class DefaultPackageDistributionServiceTest {
         VfcService vfcService = mock(VfcService.class);
         Csar csar = new Csar();
         when(vfcService.distributeVnfPackage(csar)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.postVfPackage(csar);
     }
 
@@ -260,7 +259,7 @@ public class DefaultPackageDistributionServiceTest {
         String responseId = "1";
         JobStatus jobStatus = new JobStatus();
         when(vfcService.getJobStatus(jobId, responseId)).thenReturn(successfulCall(jobStatus));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame(jobStatus, service.getJobStatus(jobId, responseId));
     }
@@ -271,7 +270,7 @@ public class DefaultPackageDistributionServiceTest {
         String jobId = "1";
         String responseId = "1";
         when(vfcService.getJobStatus(jobId, responseId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getJobStatus(jobId, responseId);
     }
 
@@ -281,7 +280,7 @@ public class DefaultPackageDistributionServiceTest {
         String jobId = "1";
         String responseId = "1";
         when(vfcService.getJobStatus(jobId, responseId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getJobStatus(jobId, responseId);
     }
 
@@ -294,7 +293,7 @@ public class DefaultPackageDistributionServiceTest {
         String operationType= "1";
         JobStatus jobStatus = new JobStatus();
         when(vfcService.getNsLcmJobStatus(jobId, responseId)).thenReturn(successfulCall(jobStatus));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame(jobStatus, service.getNsLcmJobStatus(serviceId,jobId, responseId,operationType));
     }
@@ -307,7 +306,7 @@ public class DefaultPackageDistributionServiceTest {
         String serviceId= "1";
         String operationType= "1";
         when(vfcService.getNsLcmJobStatus(jobId, responseId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getNsLcmJobStatus(serviceId,jobId, responseId,operationType);
     }
 
@@ -319,7 +318,7 @@ public class DefaultPackageDistributionServiceTest {
         String serviceId= "1";
         String operationType= "1";
         when(vfcService.getNsLcmJobStatus(jobId, responseId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getNsLcmJobStatus(serviceId,jobId, responseId,operationType);
     }
 
@@ -329,7 +328,7 @@ public class DefaultPackageDistributionServiceTest {
         DistributionResult result = new DistributionResult();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNsPackage(csarId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame(result, service.deleteNsPackage(csarId));
     }
@@ -339,7 +338,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNsPackage(csarId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteNsPackage(csarId);
     }
 
@@ -348,7 +347,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNsPackage(csarId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteNsPackage(csarId);
     }
 
@@ -357,7 +356,7 @@ public class DefaultPackageDistributionServiceTest {
        //ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getVnfPackages()).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
        // Assert.assertSame(result, service.getVnfPackages());
         Assert.assertNotNull(service.getVnfPackages());
@@ -368,7 +367,7 @@ public class DefaultPackageDistributionServiceTest {
 
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.getVnfPackages ()).thenReturn(emptyBodyCall());
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.getVnfPackages();
     }
 
@@ -376,7 +375,7 @@ public class DefaultPackageDistributionServiceTest {
     public void getVnfPackagesThrowException(){
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.getVnfPackages ()).thenReturn(failedCall("VFC is not available!"));
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.getVnfPackages();
     }
 
@@ -386,7 +385,7 @@ public class DefaultPackageDistributionServiceTest {
         Job job = new Job();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteVnfPackage(csarId)).thenReturn(successfulCall(job));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame(job, service.deleteVfPackage(csarId));
     }
@@ -396,7 +395,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteVnfdPackage(csarId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         Assert.assertSame("{\"status\":\"FAILED\"}",service.deleteVnfPackage(csarId));
     }
 
@@ -405,7 +404,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteVnfdPackage(csarId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteVnfPackage(csarId);
     }
 
@@ -413,7 +412,7 @@ public class DefaultPackageDistributionServiceTest {
     public void itCanGetNetworkServicePackages() {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNetworkServicePackages()).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         Assert.assertNotNull(service.getNetworkServicePackages());
     }
 
@@ -421,7 +420,7 @@ public class DefaultPackageDistributionServiceTest {
     public void getNetworkServicePackagesWillThrowExceptionWhenVFCIsNotAvailable() {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNetworkServicePackages()).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getNetworkServicePackages();
     }
 
@@ -429,7 +428,7 @@ public class DefaultPackageDistributionServiceTest {
     public void getNetworkServicePackagesWillThrowExceptionWhenVFCResponseError() {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNetworkServicePackages()).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getNetworkServicePackages();
     }
 
@@ -437,7 +436,7 @@ public class DefaultPackageDistributionServiceTest {
     public void itCanGetPnfPackages(){
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getPnfPackages()).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertNotNull(service.getPnfPackages());
     }
@@ -447,7 +446,7 @@ public class DefaultPackageDistributionServiceTest {
 
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.getPnfPackages ()).thenReturn(emptyBodyCall());
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.getPnfPackages();
     }
 
@@ -455,7 +454,7 @@ public class DefaultPackageDistributionServiceTest {
     public void getPnfPackagesThrowException(){
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.getPnfPackages ()).thenReturn(failedCall("VFC is not available!"));
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.getPnfPackages();
     }
 
@@ -465,7 +464,7 @@ public class DefaultPackageDistributionServiceTest {
        ResponseBody successResponse=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.downLoadNsPackage(nsdInfoId)).thenReturn(successfulCall(successResponse));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         String result = service.downLoadNsPackage(nsdInfoId);
         assertNotNull(result);
@@ -477,7 +476,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdInfoId="1";
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.downLoadNsPackage (nsdInfoId)).thenReturn(emptyBodyCall());
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.downLoadNsPackage(nsdInfoId);
     }
 
@@ -486,7 +485,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdInfoId="1";
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.downLoadNsPackage (nsdInfoId)).thenReturn(failedCall("VFC is not available!"));
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.downLoadNsPackage(nsdInfoId);
     }
 
@@ -495,7 +494,7 @@ public class DefaultPackageDistributionServiceTest {
        String pnfInfoId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.downLoadNsPackage(pnfInfoId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.downLoadPnfPackage(pnfInfoId));
     }
@@ -505,7 +504,7 @@ public class DefaultPackageDistributionServiceTest {
        String pnfInfoId="1";
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.downLoadNsPackage (pnfInfoId)).thenReturn(emptyBodyCall());
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.downLoadPnfPackage(pnfInfoId);
     }
 
@@ -514,7 +513,7 @@ public class DefaultPackageDistributionServiceTest {
        String pnfInfoId="1";
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.downLoadNsPackage (pnfInfoId)).thenReturn(failedCall("VFC is not available!"));
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.downLoadPnfPackage(pnfInfoId);
     }
 
@@ -523,7 +522,7 @@ public class DefaultPackageDistributionServiceTest {
        String vnfInfoId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.downLoadNsPackage(vnfInfoId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.downLoadVnfPackage(vnfInfoId));
     }
@@ -533,7 +532,7 @@ public class DefaultPackageDistributionServiceTest {
        String vnfInfoId="1";
        VfcService vfcService = mock(VfcService.class);
         when(vfcService.downLoadNsPackage (vnfInfoId)).thenReturn(failedCall("VFC is not available!"));
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.downLoadVnfPackage(vnfInfoId);
     }
 
@@ -542,7 +541,7 @@ public class DefaultPackageDistributionServiceTest {
        String vnfInfoId="1";
        VfcService vfcService = mock(VfcService.class);
        when(vfcService.downLoadNsPackage (vnfInfoId)).thenReturn(failedCall("VFC is not available!"));
-       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+       PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
        service.downLoadVnfPackage(vnfInfoId);
     }
 
@@ -552,7 +551,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNsdPackage(csarId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.deleteNsdPackage(csarId));
     }
@@ -562,7 +561,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNsdPackage(csarId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteNsdPackage(csarId);
     }
 
@@ -571,7 +570,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNsdPackage(csarId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteNsdPackage(csarId);
     }
 
@@ -580,7 +579,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteVnfdPackage(csarId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertNotNull(service.deleteVnfPackage(csarId));
     }
@@ -590,7 +589,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteVnfdPackage(csarId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteVnfPackage(csarId);
     }
 
@@ -599,7 +598,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteVnfdPackage(csarId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteVnfPackage(csarId);
         Assert.assertSame("{\"status\":\"FAILED\"}", service.deleteVnfPackage(csarId));
     }
@@ -611,7 +610,7 @@ public class DefaultPackageDistributionServiceTest {
         Job job = new Job();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deletePnfdPackage(csarId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.deletePnfPackage(csarId));
     }
@@ -621,7 +620,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deletePnfdPackage(csarId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deletePnfPackage(csarId);
     }
 
@@ -630,7 +629,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deletePnfdPackage(csarId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deletePnfPackage(csarId);
     }
 
@@ -641,7 +640,7 @@ public class DefaultPackageDistributionServiceTest {
         Job job = new Job();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNetworkServiceInstance(csarId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.deleteNetworkServiceInstance(csarId));
     }
@@ -651,7 +650,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNetworkServiceInstance(csarId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteNetworkServiceInstance(csarId);
     }
 
@@ -660,7 +659,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.deleteNetworkServiceInstance(csarId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.deleteNetworkServiceInstance(csarId);
     }
 
@@ -670,7 +669,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createNetworkServiceInstance(Mockito.any())).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"FAILED\"}", service.createNetworkServiceInstance(request));
     }
@@ -680,7 +679,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createNetworkServiceInstance(Mockito.any())).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.createNetworkServiceInstance(request);
     }
 
@@ -689,7 +688,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createNetworkServiceInstance(Mockito.any())).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.createNetworkServiceInstance(request);
     }
 
@@ -703,8 +702,7 @@ public class DefaultPackageDistributionServiceTest {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNetworkServiceInfo()).thenReturn(successfulCall(ns));
         ServiceLcmService serviceLcmService = mock(ServiceLcmService.class);
-        DefaultPackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
-        service.setServiceLcmService(serviceLcmService);
+        DefaultPackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, serviceLcmService);
         when(serviceLcmService.getServiceBeanByServiceInStanceId("nsInstanceId")).thenReturn(new ServiceBean());
         Assert.assertNotNull( service.getNetworkServiceInfo());
     }
@@ -713,7 +711,7 @@ public class DefaultPackageDistributionServiceTest {
     public void getNetworkServiceInfoWillThrowExceptionWhenVFCIsNotAvailable() throws IOException {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNetworkServiceInfo()).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getNetworkServiceInfo();
     }
 
@@ -721,7 +719,7 @@ public class DefaultPackageDistributionServiceTest {
     public void getNetworkServiceInfoWillThrowExceptionWhenVFCResponseError() throws IOException {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNetworkServiceInfo()).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getNetworkServiceInfo();
     }
 
@@ -734,7 +732,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         //when(vfcService.healNetworkServiceInstance(csarId,anyObject())).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         //Assert.assertSame(result, service.healNetworkServiceInstance(request,csarId));
         service.healNetworkServiceInstance(request,csarId);
@@ -746,7 +744,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.healNetworkServiceInstance(eq(csarId),Mockito.any())).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.healNetworkServiceInstance(request,csarId);
     }
 
@@ -756,7 +754,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.healNetworkServiceInstance(eq(csarId),Mockito.any())).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.healNetworkServiceInstance(request,csarId);
     }
 
@@ -765,7 +763,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         String result = service.scaleNetworkServiceInstance(request,csarId);
         assertNotNull(result);
@@ -778,7 +776,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.scaleNetworkServiceInstance(eq(csarId),Mockito.any())).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.scaleNetworkServiceInstance(request,csarId);
     }
 
@@ -788,7 +786,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.scaleNetworkServiceInstance(eq(csarId),Mockito.any())).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.scaleNetworkServiceInstance(request,csarId);
     }
 
@@ -800,7 +798,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         //when(vfcService.instantiateNetworkServiceInstance(anyObject(),serviceInstanceId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         service.instantiateNetworkServiceInstance(request,serviceInstanceId);
     }
@@ -811,7 +809,7 @@ public class DefaultPackageDistributionServiceTest {
        String serviceInstanceId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.instantiateNetworkServiceInstance(Mockito.any(),eq(serviceInstanceId))).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.instantiateNetworkServiceInstance(request,serviceInstanceId);
     }
 
@@ -821,7 +819,7 @@ public class DefaultPackageDistributionServiceTest {
        String serviceInstanceId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.instantiateNetworkServiceInstance(Mockito.any(),eq(serviceInstanceId))).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.instantiateNetworkServiceInstance(request,serviceInstanceId);
     }
 
@@ -834,7 +832,7 @@ public class DefaultPackageDistributionServiceTest {
         Job job = new Job();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.terminateNetworkServiceInstance(eq(csarId),Mockito.any())).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         service.terminateNetworkServiceInstance(request,csarId);
     }
@@ -845,7 +843,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         //when(vfcService.terminateNetworkServiceInstance(csarId,anyObject())).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.terminateNetworkServiceInstance(request,csarId);
     }
 
@@ -855,7 +853,7 @@ public class DefaultPackageDistributionServiceTest {
         String csarId = "1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.terminateNetworkServiceInstance(eq(csarId),Mockito.any())).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.terminateNetworkServiceInstance(request,csarId);
     }
 
@@ -865,7 +863,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody responseBody = null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createNetworkServiceData(Mockito.any())).thenReturn(successfulCall(responseBody));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         String result = service.createNetworkServiceData(request);
         assertNotNull(result);
@@ -877,7 +875,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createNetworkServiceData(Mockito.any())).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.createNetworkServiceData(request);
     }
 
@@ -886,7 +884,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createNetworkServiceData(Mockito.any())).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.createNetworkServiceData(request);
     }
 
@@ -896,7 +894,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createVnfData(Mockito.any())).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"FAILED\"}", service.createVnfData(request));
     }
@@ -906,7 +904,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createVnfData(Mockito.any())).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.createVnfData(request);
     }
 
@@ -915,7 +913,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createVnfData(Mockito.any())).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.createVnfData(request);
     }
 
@@ -925,7 +923,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createPnfData(Mockito.any())).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"FAILED\"}", service.createPnfData(request));
     }
@@ -935,7 +933,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createPnfData(Mockito.any())).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.createPnfData(request);
     }
 
@@ -944,7 +942,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.createPnfData(Mockito.any())).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.createPnfData(request);
     }
 
@@ -954,7 +952,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNsdInfo(nsdId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.getNsdInfo(nsdId));
     }
@@ -964,7 +962,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNsdInfo(nsdId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getNsdInfo(nsdId);
     }
 
@@ -973,7 +971,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getNsdInfo(nsdId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getNsdInfo(nsdId);
     }
 
@@ -983,7 +981,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getVnfInfo(nsdId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.getVnfInfo(nsdId));
     }
@@ -993,7 +991,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getVnfInfo(nsdId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getVnfInfo(nsdId);
     }
 
@@ -1002,7 +1000,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getVnfInfo(nsdId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getVnfInfo(nsdId);
     }
 
@@ -1012,7 +1010,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getPnfInfo(nsdId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"SUCCESS\"}", service.getPnfInfo(nsdId));
     }
@@ -1022,7 +1020,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getPnfInfo(nsdId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getPnfInfo(nsdId);
     }
 
@@ -1031,7 +1029,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getPnfInfo(nsdId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getPnfInfo(nsdId);
     }
 
@@ -1039,7 +1037,7 @@ public class DefaultPackageDistributionServiceTest {
     public void itCanListNsTemplates() throws IOException {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.listNsTemplates()).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertNotNull( service.listNsTemplates());
     }
@@ -1048,7 +1046,7 @@ public class DefaultPackageDistributionServiceTest {
     public void listNsTemplatesWillThrowExceptionWhenVFCIsNotAvailable() throws IOException {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.listNsTemplates()).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.listNsTemplates();
     }
 
@@ -1056,7 +1054,7 @@ public class DefaultPackageDistributionServiceTest {
     public void listNsTemplatesWillThrowExceptionWhenVFCResponseError() throws IOException {
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.listNsTemplates()).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.listNsTemplates();
     }
 
@@ -1065,7 +1063,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getVnfInfoById(nsdId)).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertNotNull(service.getVnfInfoById(nsdId));
     }
@@ -1075,7 +1073,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getVnfInfoById(nsdId)).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getVnfInfoById(nsdId);
     }
 
@@ -1084,7 +1082,7 @@ public class DefaultPackageDistributionServiceTest {
        String nsdId="1";
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.getVnfInfoById(nsdId)).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.getVnfInfoById(nsdId);
     }
 
@@ -1094,7 +1092,7 @@ public class DefaultPackageDistributionServiceTest {
         ResponseBody result=null;
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.fetchNsTemplateData(Mockito.any())).thenReturn(successfulCall(result));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
 
         Assert.assertSame("{\"status\":\"FAILED\"}", service.fetchNsTemplateData(request));
     }
@@ -1104,7 +1102,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.fetchNsTemplateData(Mockito.any())).thenReturn(failedCall("VFC is not available!"));
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.fetchNsTemplateData(request);
     }
 
@@ -1113,7 +1111,7 @@ public class DefaultPackageDistributionServiceTest {
        HttpServletRequest request = mockRequest();
         VfcService vfcService = mock(VfcService.class);
         when(vfcService.fetchNsTemplateData(Mockito.any())).thenReturn(emptyBodyCall());
-        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
+        PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService, null);
         service.fetchNsTemplateData(request);
     }
 
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceIntegrationTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceIntegrationTest.java
new file mode 100644 (file)
index 0000000..8897d03
--- /dev/null
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2025 Deutsche Telekom.
+ *
+ * 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.usecaseui.server.service.lcm.impl;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.util.List;
+import org.junit.jupiter.api.Test;
+import org.onap.usecaseui.server.config.AAIClientConfig;
+import org.onap.usecaseui.server.config.SDCClientConfig;
+import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.http.HttpHeaders;
+import org.wiremock.spring.EnableWireMock;
+
+import lombok.SneakyThrows;
+
+@EnableWireMock
+@SpringBootTest(
+    webEnvironment = WebEnvironment.RANDOM_PORT,
+    classes = {
+        AAIClientConfig.class, SDCClientConfig.class, DefaultServiceTemplateService.class
+    },
+    properties = {
+        "spring.main.web-application-type=none", // only temporary
+        "client.aai.baseUrl=${wiremock.server.baseUrl}",
+        "client.aai.username=AAI",
+        "client.aai.password=AAI",
+        "uui-server.client.sdc.baseUrl=${wiremock.server.baseUrl}",
+        "uui-server.client.sdc.username=someUser",
+        "uui-server.client.sdc.password=somePassword",
+    })
+public class DefaultServiceTemplateServiceIntegrationTest {
+
+    @Autowired
+    DefaultServiceTemplateService defaultServiceTemplateService;
+
+    @Value("${uui-server.client.sdc.username}")
+    String username;
+
+    @Value("${uui-server.client.sdc.password}")
+    String password;
+
+    @Test
+    @SneakyThrows
+    void thatSDCCatalogRequestsAreCorrect() {
+        stubFor(
+            get(urlPathEqualTo("/api/sdc/v1/catalog/services"))
+            .withQueryParam("category", equalTo("E2E Service"))
+            .withQueryParam("distributionStatus", equalTo("DISTRIBUTED"))
+            .withBasicAuth(username, password)
+            .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
+            .withHeader("X-ECOMP-InstanceID", equalTo("777"))
+            .willReturn(
+                aResponse().withBodyFile("serviceTemplateResponse.json")
+            ));
+        List<SDCServiceTemplate> serviceTemplates = defaultServiceTemplateService.listDistributedServiceTemplate();
+        assertNotNull(serviceTemplates);
+        assertEquals(1, serviceTemplates.size());
+        assertEquals("someCategory", serviceTemplates.get(0).getCategory());
+        assertEquals("someInvariantUuid", serviceTemplates.get(0).getInvariantUUID());
+        assertEquals("someName", serviceTemplates.get(0).getName());
+        assertEquals("/foo/bar", serviceTemplates.get(0).getToscaModelURL());
+        assertEquals("someUuid", serviceTemplates.get(0).getUuid());
+        assertEquals("someVersion", serviceTemplates.get(0).getVersion());
+    }
+}
diff --git a/server/src/test/resources/__files/serviceTemplateResponse.json b/server/src/test/resources/__files/serviceTemplateResponse.json
new file mode 100644 (file)
index 0000000..b8f21df
--- /dev/null
@@ -0,0 +1,10 @@
+[
+  {
+    "uuid": "someUuid",
+    "invariantUUID": "someInvariantUuid",
+    "name": "someName",
+    "version": "someVersion",
+    "toscaModelURL": "/foo/bar",
+    "category": "someCategory"
+  }
+]