Dependency inject Retrofit client for IntentInstanceService 64/140164/3
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Fri, 7 Feb 2025 07:15:12 +0000 (08:15 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Fri, 7 Feb 2025 11:45:15 +0000 (12:45 +0100)
- split up IntantApiService into IntentAai- and IntentSoService to be able to
  configure their headers centrally (like it is done for the rest of the changes
  of this series)
- bump snapshot version to 15.0.1

Issue-ID: USECASEUI-861
Change-Id: I55662ff8dbb1e46f3fdd235852064268866a088f
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
17 files changed:
checkstyle/pom.xml
pom.xml
server/pom.xml
server/src/main/java/org/onap/usecaseui/server/config/AAIClientConfig.java
server/src/main/java/org/onap/usecaseui/server/config/SOClientConfig.java
server/src/main/java/org/onap/usecaseui/server/service/intent/IntentAaiService.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/intent/IntentApiService.java
server/src/main/java/org/onap/usecaseui/server/service/intent/IntentSoService.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/intent/config/IntentProperties.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImpl.java
server/src/main/resources/application.properties
server/src/test/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceImplTest.java
server/src/test/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceIntegrationTest.java [new file with mode: 0644]
server/src/test/resources/__files/createIntentResponse.json [new file with mode: 0644]
server/src/test/resources/__files/requests/createIntentRequest.json [new file with mode: 0644]
standalone/pom.xml
version.properties

index f60518f..e364e90 100644 (file)
@@ -17,4 +17,4 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/pom.xml b/pom.xml
index c2d3f52..37afd82 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
 
     <groupId>org.onap.usecase-ui.server</groupId>
     <artifactId>usecase-ui-server-parent</artifactId>
-    <version>15.0.0-SNAPSHOT</version>
+    <version>15.0.1-SNAPSHOT</version>
     <packaging>pom</packaging>
     <name>usecase-ui-server-parent</name>
     <description>parent project for usecase-ui server</description>
index b81bf27..5be2e75 100644 (file)
@@ -19,7 +19,7 @@
     <parent>
         <groupId>org.onap.usecase-ui.server</groupId>
         <artifactId>usecase-ui-server-parent</artifactId>
-        <version>15.0.0-SNAPSHOT</version>
+        <version>15.0.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>usecase-ui-server</artifactId>
index 148b907..d54d298 100644 (file)
@@ -18,6 +18,7 @@ package org.onap.usecaseui.server.config;
 
 import java.io.IOException;
 
+import org.onap.usecaseui.server.service.intent.IntentAaiService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
 import org.onap.usecaseui.server.service.slicingdomain.aai.AAISliceService;
 import org.springframework.beans.factory.annotation.Value;
@@ -77,4 +78,9 @@ public class AAIClientConfig {
     AAISliceService aaiSliceService(Retrofit retrofit) {
         return retrofit.create(AAISliceService.class);
     }
+
+    @Bean
+    IntentAaiService intentAaiService(Retrofit retrofit) {
+        return retrofit.create(IntentAaiService.class);
+    }
 }
index 3eca259..bff4361 100644 (file)
@@ -18,6 +18,7 @@ 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.so.SOService;
 import org.onap.usecaseui.server.service.slicingdomain.so.SOSliceService;
 import org.springframework.beans.factory.annotation.Value;
@@ -75,4 +76,9 @@ public class SOClientConfig {
     SOSliceService soSliceService() {
         return retrofit().create(SOSliceService.class);
     }
+
+    @Bean
+    IntentSoService intentSoService() {
+        return retrofit().create(IntentSoService.class);
+    }
 }
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentAaiService.java b/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentAaiService.java
new file mode 100644 (file)
index 0000000..2955142
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * 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.intent;
+
+import com.alibaba.fastjson.JSONObject;
+
+import okhttp3.RequestBody;
+import retrofit2.Call;
+import retrofit2.http.Body;
+import retrofit2.http.DELETE;
+import retrofit2.http.GET;
+import retrofit2.http.PUT;
+import retrofit2.http.Path;
+import retrofit2.http.Query;
+
+public interface IntentAaiService {
+    @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}?depth=all")
+    Call<JSONObject> getInstanceNetworkInfo(@Path("resource-service-id") String resourceServiceId);
+
+    @GET("/aai/v24/network/network-policies/network-policy/{networkPolicyId}?depth=all")
+    Call<JSONObject> getInstanceNetworkPolicyInfo(@Path("networkPolicyId") String networkPolicyId);
+
+    @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}/metadata")
+    Call<JSONObject> getInstanceBandwidth(@Path("resource-service-id") String resourceServiceId);
+
+    @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}")
+    Call<JSONObject> getInstanceInfo(@Path("resource-service-id") String resourceServiceId);
+
+    @PUT("/aai/v24/business/customers/customer/{globalCustomerId}")
+    Call<Void> addCustomer(@Path("globalCustomerId") String globalCustomerId,@Body RequestBody body);
+
+    @GET("/aai/v24/business/customers/customer/{globalCustomerId}")
+    Call<JSONObject> queryCustomer(@Path("globalCustomerId") String globalCustomerId);
+
+    @PUT("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}")
+    Call<Void> addSubscription(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType,@Body RequestBody body);
+
+    @GET("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}")
+    Call<JSONObject> querySubscription(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType);
+
+    @PUT("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}/service-instances/service-instance/{serviceInstanceId}")
+    Call<Void> saveServiceInstance(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType, @Path("serviceInstanceId") String serviceInstanceId, @Body RequestBody body);
+
+    @GET("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}/service-instances/service-instance/{serviceInstanceId}")
+    Call<JSONObject> queryServiceInstance(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType, @Path("serviceInstanceId") String serviceInstanceId);
+
+    @DELETE("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}/service-instances/service-instance/{serviceInstanceId}")
+    Call<Void> deleteServiceInstance(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType, @Path("serviceInstanceId") String serviceInstanceId, @Query("resource-version") String resourceVersion);
+
+    @GET("/aai/v24/network/network-routes")
+    Call<JSONObject> queryNetworkRoute();
+}
index 8202c98..a1e0815 100644 (file)
@@ -23,136 +23,9 @@ import retrofit2.http.*;
 
 public interface IntentApiService {
 
-    @Headers({
-            "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
-            "Accept: application/json"
-    })
-    @POST("/so/infra/serviceIntent/v1/create")
     Call<JSONObject> createIntentInstance(@Body RequestBody body);
-
-//    curl -X GET -H "content-type:application/json" http://so:8080/onap/so/infra/e2eServiceInstances/v3/cll-101/operations/0d698405-9109-49f2-9939-fd02ead31660 --user 'InfraPortalClient:password1$'
-
-    @Headers({
-            "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
-            "Accept: application/json"
-    })
-    @GET("/so/infra/e2eServiceInstances/v3/{serviceId}/operations/{operationId}")
     Call<JSONObject> queryOperationProgress(@Path("serviceId") String serviceId, @Path("operationId") String operationId);
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
-            "Accept: application/json"
-    })
-    @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}?depth=all")
-    Call<JSONObject> getInstanceNetworkInfo(@Path("resource-service-id") String resourceServiceId);
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
-            "Accept: application/json"
-    })
-    @GET("/aai/v24/network/network-policies/network-policy/{networkPolicyId}?depth=all")
-    Call<JSONObject> getInstanceNetworkPolicyInfo(@Path("networkPolicyId") String networkPolicyId);
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
-            "Accept: application/json"
-    })
-    @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}/metadata")
-    Call<JSONObject> getInstanceBandwidth(@Path("resource-service-id") String resourceServiceId);
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic QUFJOkFBSQ==",
-            "Accept: application/json"
-    })
-    @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}")
-    Call<JSONObject> getInstanceInfo(@Path("resource-service-id") String resourceServiceId);
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic QUFJOkFBSQ==",
-            "Accept: application/json"
-    })
-    @PUT("/aai/v24/business/customers/customer/{globalCustomerId}")
-    Call<Void> addCustomer(@Path("globalCustomerId") String globalCustomerId,@Body RequestBody body);
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic QUFJOkFBSQ==",
-            "Accept: application/json"
-    })
-    @GET("/aai/v24/business/customers/customer/{globalCustomerId}")
-    Call<JSONObject> queryCustomer(@Path("globalCustomerId") String globalCustomerId);
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic QUFJOkFBSQ==",
-            "Accept: application/json"
-    })
-    @PUT("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}")
-    Call<Void> addSubscription(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType,@Body RequestBody body);
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic QUFJOkFBSQ==",
-            "Accept: application/json"
-    })
-    @GET("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}")
-    Call<JSONObject> querySubscription(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType);
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic QUFJOkFBSQ==",
-            "Accept: application/json"
-    })
-    @PUT("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}/service-instances/service-instance/{serviceInstanceId}")
-    Call<Void> saveServiceInstance(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType, @Path("serviceInstanceId") String serviceInstanceId, @Body RequestBody body);
-
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic QUFJOkFBSQ==",
-            "Accept: application/json"
-    })
-    @GET("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}/service-instances/service-instance/{serviceInstanceId}")
-    Call<JSONObject> queryServiceInstance(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType, @Path("serviceInstanceId") String serviceInstanceId);
-
-
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic QUFJOkFBSQ==",
-            "Accept: application/json"
-    })
-    @DELETE("/aai/v24/business/customers/customer/{globalCustomerId}/service-subscriptions/service-subscription/{serviceType}/service-instances/service-instance/{serviceInstanceId}")
-    Call<Void> deleteServiceInstance(@Path("globalCustomerId") String globalCustomerId, @Path("serviceType") String serviceType, @Path("serviceInstanceId") String serviceInstanceId, @Query("resource-version") String resourceVersion);
-
-    @Headers({
-            "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
-            "Accept: application/json"
-    })
-    @HTTP(method="DELETE", path="/so/infra/serviceIntent/v1/delete", hasBody = true)
     Call<JSONObject> deleteIntentInstance(@Body RequestBody body);
 
-    @Headers({
-            "X-TransactionId: 9999",
-            "X-FromAppId: MSO",
-            "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==",
-            "Accept: application/json"
-    })
-    @GET("/aai/v24/network/network-routes")
-    Call<JSONObject> queryNetworkRoute();
 
 }
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentSoService.java b/server/src/main/java/org/onap/usecaseui/server/service/intent/IntentSoService.java
new file mode 100644 (file)
index 0000000..ec94999
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * 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.intent;
+
+import com.alibaba.fastjson.JSONObject;
+
+import okhttp3.RequestBody;
+import retrofit2.Call;
+import retrofit2.http.Body;
+import retrofit2.http.GET;
+import retrofit2.http.HTTP;
+import retrofit2.http.POST;
+import retrofit2.http.Path;
+
+public interface IntentSoService {
+
+    @POST("/so/infra/serviceIntent/v1/create")
+    Call<JSONObject> createIntentInstance(@Body RequestBody body);
+
+    @GET("/so/infra/e2eServiceInstances/v3/{serviceId}/operations/{operationId}")
+    Call<JSONObject> queryOperationProgress(@Path("serviceId") String serviceId, @Path("operationId") String operationId);
+
+    @HTTP(method="DELETE", path="/so/infra/serviceIntent/v1/delete", hasBody = true)
+    Call<JSONObject> deleteIntentInstance(@Body RequestBody body);
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/intent/config/IntentProperties.java b/server/src/main/java/org/onap/usecaseui/server/service/intent/config/IntentProperties.java
new file mode 100644 (file)
index 0000000..0f1f62e
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * 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.intent.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import lombok.Data;
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "uui-server.ccvpn")
+public class IntentProperties {
+  String globalCustomerId;
+  String serviceType;
+  String subscriberName;
+  String subscriberType;
+}
index bc0d05a..7b87af9 100644 (file)
@@ -1,6 +1,10 @@
 /*
  * Copyright (C) 2021 CTC, Inc. and others. All rights reserved.
  *
+ * ================================================================================
+ * 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
@@ -32,62 +36,66 @@ import org.onap.usecaseui.server.bean.intent.IntentInstance;
 import org.onap.usecaseui.server.bean.nsmf.common.ServiceResult;
 import org.onap.usecaseui.server.constant.IntentConstant;
 import org.onap.usecaseui.server.service.csmf.SlicingService;
-import org.onap.usecaseui.server.service.intent.IntentApiService;
+import org.onap.usecaseui.server.service.intent.IntentAaiService;
 import org.onap.usecaseui.server.service.intent.IntentInstanceService;
-import org.onap.usecaseui.server.service.lcm.domain.so.SOService;
+import org.onap.usecaseui.server.service.intent.IntentSoService;
+import org.onap.usecaseui.server.service.intent.config.IntentProperties;
 import org.onap.usecaseui.server.service.nsmf.ResourceMgtService;
 import org.onap.usecaseui.server.util.ExportUtil;
 import org.onap.usecaseui.server.util.Page;
-import org.onap.usecaseui.server.util.RestfulServices;
 import org.onap.usecaseui.server.util.UuiCommonUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
 import org.springframework.stereotype.Service;
-import retrofit2.Call;
 import retrofit2.Response;
 
-import jakarta.annotation.Resource;
 import jakarta.transaction.Transactional;
+
 import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-@Service("IntentInstanceService")
 @Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
+@Service("IntentInstanceService")
 public class IntentInstanceServiceImpl implements IntentInstanceService {
     private static final Logger logger = LoggerFactory.getLogger(IntentInstanceServiceImpl.class);
-
-    @Autowired
-    private SessionFactory sessionFactory;
-
-    @Resource(name = "ResourceMgtService")
-    private ResourceMgtService resourceMgtService;
-
-    @Resource(name = "SlicingService")
-    private SlicingService slicingService;
-
-    private IntentApiService intentApiService;
-
-    private SOService soService;
-
-    private final static int MAX_BANDWIDTH = 6000;
-    private final static int MIN_BANDWIDTH = 100;
-
-    private final static List<String> GB_COMPANY = Arrays.asList(new String[] {"gbps", "gb"});
-    private final static List<String> MB_COMPANY = Arrays.asList(new String[] {"mbps", "mb"});
-
-    public IntentInstanceServiceImpl() {
-        this(RestfulServices.create(IntentApiService.class),RestfulServices.create(SOService.class));
+    private static final List<String> GB_COMPANY = Arrays.asList(new String[] {"gbps", "gb"});
+    private static final List<String> MB_COMPANY = Arrays.asList(new String[] {"mbps", "mb"});
+    private static final int MAX_BANDWIDTH = 6000;
+    private static final int MIN_BANDWIDTH = 100;
+
+    private final SlicingService slicingService;
+    private final IntentAaiService intentAaiService;
+    private final IntentSoService intentSoService;
+    private final SessionFactory sessionFactory;
+    private final ResourceMgtService resourceMgtService;
+    private final IntentProperties intentProperties;
+
+    public IntentInstanceServiceImpl(SlicingService slicingService, IntentAaiService intentAaiService, IntentSoService intentSoService, SessionFactory sessionFactory, ResourceMgtService resourceMgtService, IntentProperties intentProperties) {
+        this.slicingService = slicingService;
+        this.intentAaiService = intentAaiService;
+        this.intentSoService = intentSoService;
+        this.sessionFactory = sessionFactory;
+        this.resourceMgtService = resourceMgtService;
+        this.intentProperties = defaultPropertiesFromFile(intentProperties);
     }
-    public IntentInstanceServiceImpl(IntentApiService intentApiService, SOService soService) {
-        this.intentApiService = intentApiService;
-        this.soService = soService;
+
+    private IntentProperties defaultPropertiesFromFile(IntentProperties intentProperties) {
+        try {
+            // kept for backwards-compatibility
+            // this should eventually be removed in favor of spring properties binding
+            Properties properties = getProperties();
+            IntentProperties intentPropertiesFromProps = new IntentProperties();
+            intentPropertiesFromProps.setGlobalCustomerId(properties.getProperty("ccvpn.globalCustomerId"));
+            intentPropertiesFromProps.setServiceType(properties.getProperty("ccvpn.serviceType"));
+            intentPropertiesFromProps.setSubscriberName(properties.getProperty("ccvpn.subscriberName"));
+            intentPropertiesFromProps.setSubscriberType(properties.getProperty("ccvpn.subscriberType"));
+            return intentPropertiesFromProps;
+        } catch (Exception e) {
+            return intentProperties;
+        }
     }
 
     private Session getSession() {
@@ -233,7 +241,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
         params.put("additionalProperties",additionalProperties);
 
         okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
-        Response<JSONObject> response = intentApiService.createIntentInstance(requestBody).execute();
+        Response<JSONObject> response = intentSoService.createIntentInstance(requestBody).execute();
         if (response.isSuccessful()) {
             return response.body().getString("jobId");
         }
@@ -307,7 +315,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
     }
 
     private int getProgressByJobId(CCVPNInstance instance) throws IOException {
-        Response<JSONObject> response = intentApiService.queryOperationProgress(instance.getResourceInstanceId(), instance.getJobId()).execute();
+        Response<JSONObject> response = intentSoService.queryOperationProgress(instance.getResourceInstanceId(), instance.getJobId()).execute();
         logger.debug(response.toString());
         if (response.isSuccessful()) {
             if (response.body().containsKey("operation")) {
@@ -321,7 +329,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
         if (instance == null || instance.getResourceInstanceId() == null) {
             return -1;
         }
-        Response<JSONObject> response = intentApiService.getInstanceInfo(instance.getResourceInstanceId()).execute();
+        Response<JSONObject> response = intentAaiService.getInstanceInfo(instance.getResourceInstanceId()).execute();
         logger.debug(response.toString());
         if (response.isSuccessful()) {
             String status = response.body().getString("orchestration-status");
@@ -375,7 +383,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
         List<CCVPNInstance> instanceList = getInstanceByFinishedFlag("1");
         for (CCVPNInstance instance : instanceList) {
             String serviceInstanceId = instance.getResourceInstanceId();
-            Response<JSONObject> response = intentApiService.getInstanceNetworkInfo(serviceInstanceId).execute();
+            Response<JSONObject> response = intentAaiService.getInstanceNetworkInfo(serviceInstanceId).execute();
             if (!response.isSuccessful()) {
                 logger.error("get Intent-Instance Bandwidth error:" + response.toString());
                 continue;
@@ -401,7 +409,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
                 continue;
             }
 
-            Response<JSONObject> networkPolicyInfoResponse = intentApiService.getInstanceNetworkPolicyInfo(networkPolicyId).execute();
+            Response<JSONObject> networkPolicyInfoResponse = intentAaiService.getInstanceNetworkPolicyInfo(networkPolicyId).execute();
             if (!networkPolicyInfoResponse.isSuccessful()) {
                 logger.error("get Intent-Instance networkPolicyInfo error:" + networkPolicyInfoResponse.toString());
                 continue;
@@ -414,7 +422,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
             instancePerformance.setJobId(instance.getJobId());
             instancePerformance.setDate(new Date());
 
-            Response<JSONObject> metadatumResponse = intentApiService.getInstanceBandwidth(serviceInstanceId).execute();
+            Response<JSONObject> metadatumResponse = intentAaiService.getInstanceBandwidth(serviceInstanceId).execute();
             if (!metadatumResponse.isSuccessful()) {
                 logger.error("get Intent-Instance metadatum error:" + metadatumResponse.toString());
                 continue;
@@ -487,7 +495,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
         additionalProperties.put("enableSdnc", "true");
         params.put("additionalProperties", additionalProperties);
         okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
-        intentApiService.deleteIntentInstance(requestBody).execute();
+        intentSoService.deleteIntentInstance(requestBody).execute();
     }
     private String deleteInstance(CCVPNInstance instance) {
         Transaction tx = null;
@@ -622,7 +630,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
         Map<String, Object> result = new HashMap<>();
         List<String> accessNodeList = new ArrayList<>();
         List<String> cloudAccessNodeList = new ArrayList<>();
-        Response<JSONObject> response = intentApiService.queryNetworkRoute().execute();
+        Response<JSONObject> response = intentAaiService.queryNetworkRoute().execute();
         if (!response.isSuccessful()) {
             logger.error(response.toString());
             throw new RuntimeException("Query Access Node Info Error");
@@ -723,20 +731,19 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
     }
 
     public void addCustomer() throws IOException {
-        Properties environment = getProperties();
-        String globalCustomerId = environment.getProperty("ccvpn.globalCustomerId");
-        Response<JSONObject> queryCustomerResponse = intentApiService.queryCustomer(globalCustomerId).execute();
+        String globalCustomerId = intentProperties.getGlobalCustomerId();
+        Response<JSONObject> queryCustomerResponse = intentAaiService.queryCustomer(globalCustomerId).execute();
         if (queryCustomerResponse.isSuccessful()) {
             return;
         }
-        String subscriberName = environment.getProperty("ccvpn.subscriberName");
-        String subscriberType = environment.getProperty("ccvpn.subscriberType");
+        String subscriberName = intentProperties.getSubscriberName();
+        String subscriberType = intentProperties.getSubscriberType();
         Map<String, Object> params = new HashMap<>();
         params.put("global-customer-id", globalCustomerId);
         params.put("subscriber-name", subscriberName);
         params.put("subscriber-type", subscriberType);
         okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
-        intentApiService.addCustomer(globalCustomerId, requestBody).execute();
+        intentAaiService.addCustomer(globalCustomerId, requestBody).execute();
     }
 
     @Override
@@ -928,23 +935,22 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
     }
 
     public void addSubscription() throws IOException {
-        Properties environment = getProperties();
-        String globalCustomerId = environment.getProperty("ccvpn.globalCustomerId");
-        String serviceType = environment.getProperty("ccvpn.serviceType");
-        Response<JSONObject> querySubscription = intentApiService.querySubscription(globalCustomerId, serviceType).execute();
+        String globalCustomerId = intentProperties.getGlobalCustomerId();
+        String serviceType = intentProperties.getServiceType();
+        Response<JSONObject> querySubscription = intentAaiService.querySubscription(globalCustomerId, serviceType).execute();
         if (querySubscription.isSuccessful()) {
             return;
         }
         Map<String, Object> params = new HashMap<>();
         params.put("service-type", serviceType);
         okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
-        intentApiService.addSubscription(globalCustomerId, serviceType, requestBody).execute();
+        intentAaiService.addSubscription(globalCustomerId, serviceType, requestBody).execute();
     }
 
     public Properties getProperties() throws IOException {
         String slicingPath = System.getProperty("user.dir") + File.separator + "config" + File.separator + "ccvpn.properties";
-        InputStream inputStream = new FileInputStream(new File(slicingPath));
         Properties environment = new Properties();
+        InputStream inputStream = new FileInputStream(new File(slicingPath));
         environment.load(inputStream);
         return environment;
     }
@@ -953,12 +959,11 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
     public void saveIntentInstanceToAAI(String serviceInstanceId, CCVPNInstance instance) throws IOException {
         addCustomer();
         addSubscription();
-        Properties environment = getProperties();
-        String globalCustomerId = environment.getProperty("ccvpn.globalCustomerId");
-        String serviceType = environment.getProperty("ccvpn.serviceType");
+        String globalCustomerId = intentProperties.getGlobalCustomerId();
+        String serviceType = intentProperties.getServiceType();
         String resourceVersion = null;
         if (serviceInstanceId != null) {
-            Response<JSONObject> queryServiceInstance = intentApiService.queryServiceInstance(globalCustomerId, serviceType, serviceInstanceId).execute();
+            Response<JSONObject> queryServiceInstance = intentAaiService.queryServiceInstance(globalCustomerId, serviceType, serviceInstanceId).execute();
             if (queryServiceInstance.isSuccessful()) {
                 JSONObject body = queryServiceInstance.body();
                 resourceVersion  = body.getString("resource-version");
@@ -981,23 +986,22 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
             params.put("resource-version",resourceVersion);
         }
         okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
-        intentApiService.saveServiceInstance(globalCustomerId,serviceType,serviceInstanceId,requestBody).execute();
+        intentAaiService.saveServiceInstance(globalCustomerId,serviceType,serviceInstanceId,requestBody).execute();
 
     }
     public void deleteIntentInstanceToAAI(String serviceInstanceId) throws IOException {
         addCustomer();
         addSubscription();
-        Properties environment = getProperties();
-        String globalCustomerId = environment.getProperty("ccvpn.globalCustomerId");
-        String serviceType = environment.getProperty("ccvpn.serviceType");
+        String globalCustomerId = intentProperties.getGlobalCustomerId();
+        String serviceType = intentProperties.getServiceType();
         if (serviceInstanceId == null) {
             return;
         }
-        Response<JSONObject> queryServiceInstance = intentApiService.queryServiceInstance(globalCustomerId, serviceType, serviceInstanceId).execute();
+        Response<JSONObject> queryServiceInstance = intentAaiService.queryServiceInstance(globalCustomerId, serviceType, serviceInstanceId).execute();
         if (queryServiceInstance.isSuccessful()) {
             JSONObject body = queryServiceInstance.body();
             String resourceVersion  = body.getString("resource-version");
-            intentApiService.deleteServiceInstance(globalCustomerId,serviceType,serviceInstanceId,resourceVersion).execute();
+            intentAaiService.deleteServiceInstance(globalCustomerId,serviceType,serviceInstanceId,resourceVersion).execute();
         }
     }
 
@@ -1005,9 +1009,8 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
     public void saveSlicingServiceToAAI(String serviceId, String operationId, SlicingOrder slicingOrder) throws IOException {
         addCustomer();
         addSubscription();
-        Properties environment = getProperties();
-        String globalCustomerId = environment.getProperty("ccvpn.globalCustomerId");
-        String serviceType = environment.getProperty("ccvpn.serviceType");
+        String globalCustomerId = intentProperties.getGlobalCustomerId();
+        String serviceType = intentProperties.getServiceType();
         SlicingOrderDetail slicingOrderInfo = slicingOrder.getSlicing_order_info();
         JSONObject environmentContext = JSONObject.parseObject(JSONObject.toJSONString(slicingOrderInfo));
 
@@ -1025,7 +1028,7 @@ public class IntentInstanceServiceImpl implements IntentInstanceService {
         params.put("resource-sharing-level", slicingOrderInfo.getResourceSharingLevel());
         params.put("data-owner", IntentConstant.INTENT_INSTANCE_DATA_OWNER);
         okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
-        intentApiService.saveServiceInstance(globalCustomerId,serviceType,serviceId,requestBody).execute();
+        intentAaiService.saveServiceInstance(globalCustomerId,serviceType,serviceId,requestBody).execute();
     }
 
     @Override
index cd97f3b..e489c96 100644 (file)
@@ -66,3 +66,7 @@ uui-server.slicing.service-invariant-uuid=defaultServiceInvariantUuid
 uui-server.slicing.service-uuid=defaultServiceUuid
 uui-server.slicing.global-subscriber-id=defaultGlobalSubscriberId
 uui-server.slicing.service-type=defaultServiceType
+uui-server.ccvpn.globalCustomerId=defaultGlobalCustomerId
+uui-server.ccvpn.serviceType=defaultServiceType
+uui-server.ccvpn.subscriberName=defaultSubscriberName
+uui-server.ccvpn.subscriberType=defaultSubscriberType
index b6d0f4d..a10e73e 100644 (file)
@@ -46,8 +46,9 @@ import org.onap.usecaseui.server.bean.intent.IntentModel;
 import org.onap.usecaseui.server.bean.nsmf.common.ServiceResult;
 import org.onap.usecaseui.server.constant.IntentConstant;
 import org.onap.usecaseui.server.service.csmf.SlicingService;
-import org.onap.usecaseui.server.service.intent.IntentApiService;
-import org.onap.usecaseui.server.service.lcm.domain.so.SOService;
+import org.onap.usecaseui.server.service.intent.IntentAaiService;
+import org.onap.usecaseui.server.service.intent.IntentSoService;
+import org.onap.usecaseui.server.service.intent.config.IntentProperties;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgress;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation;
 import org.onap.usecaseui.server.service.nsmf.ResourceMgtService;
@@ -76,10 +77,13 @@ public class IntentInstanceServiceImplTest {
     private IntentInstanceServiceImpl intentInstanceService;
 
     @Mock
-    private IntentApiService intentApiService;
+    private IntentAaiService intentAaiService;
 
     @Mock
-    private SOService soService;
+    private IntentSoService intentSoService;
+
+    @Mock
+    private IntentProperties intentProperties;
 
     @Mock
     @Resource(name = "ResourceMgtService")
@@ -100,8 +104,14 @@ public class IntentInstanceServiceImplTest {
         MemberModifier.field(IntentInstanceServiceImpl.class, "sessionFactory").set(intentInstanceService , sessionFactory);
         MemberModifier.field(IntentInstanceServiceImpl.class, "resourceMgtService").set(intentInstanceService , resourceMgtService);
         MemberModifier.field(IntentInstanceServiceImpl.class, "slicingService").set(intentInstanceService , slicingService);
-        MemberModifier.field(IntentInstanceServiceImpl.class, "intentApiService").set(intentInstanceService , intentApiService);
+        MemberModifier.field(IntentInstanceServiceImpl.class, "intentAaiService").set(intentInstanceService , intentAaiService);
+        MemberModifier.field(IntentInstanceServiceImpl.class, "intentSoService").set(intentInstanceService , intentSoService);
         when(sessionFactory.openSession()).thenReturn(session);
+
+        when(intentProperties.getGlobalCustomerId()).thenReturn("someCustomer");
+        when(intentProperties.getSubscriberName()).thenReturn("someSubscriber");
+        when(intentProperties.getSubscriberType()).thenReturn("someSubscriberType");
+
     }
 
     @Test
@@ -155,7 +165,7 @@ public class IntentInstanceServiceImplTest {
         Call mockCall = PowerMockito.mock(Call.class);
         JSONObject body = JSONObject.parseObject("{\"jobId\":\"123\"}");
         Response<JSONObject> response = Response.success(body);
-        Mockito.when(intentApiService.createIntentInstance(any())).thenReturn(mockCall);
+        Mockito.when(intentSoService.createIntentInstance(any())).thenReturn(mockCall);
         Mockito.when(mockCall.execute()).thenReturn(response);
 
         IntentInstanceServiceImpl spy = PowerMockito.spy(intentInstanceService);
@@ -180,7 +190,7 @@ public class IntentInstanceServiceImplTest {
         Call mockCall = PowerMockito.mock(Call.class);
         JSONObject body = JSONObject.parseObject("{\"jobId\":\"123\"}");
         Response<JSONObject> response = Response.success(body);
-        Mockito.when(intentApiService.createIntentInstance(any())).thenReturn(mockCall);
+        Mockito.when(intentSoService.createIntentInstance(any())).thenReturn(mockCall);
         Mockito.when(mockCall.execute()).thenReturn(response);
 
         IntentInstanceServiceImpl spy = PowerMockito.spy(intentInstanceService);
@@ -227,7 +237,7 @@ public class IntentInstanceServiceImplTest {
         jsonObject.put("operation", operation);
         Call mockCall = PowerMockito.mock(Call.class);
         Response<JSONObject> response = Response.success(jsonObject);
-        Mockito.when(intentApiService.queryOperationProgress(anyString(),anyString())).thenReturn(mockCall);
+        Mockito.when(intentSoService.queryOperationProgress(anyString(),anyString())).thenReturn(mockCall);
         Mockito.when(mockCall.execute()).thenReturn(response);
 
         IntentInstanceServiceImpl spy = PowerMockito.spy(intentInstanceService);
@@ -263,7 +273,7 @@ public class IntentInstanceServiceImplTest {
         jsonObject.put("orchestration-status", "created");
         Call mockCall = PowerMockito.mock(Call.class);
         Response<JSONObject> response = Response.success(jsonObject);
-        Mockito.when(intentApiService.getInstanceInfo(anyString())).thenReturn(mockCall);
+        Mockito.when(intentAaiService.getInstanceInfo(anyString())).thenReturn(mockCall);
         Mockito.when(mockCall.execute()).thenReturn(response);
 
         IntentInstanceServiceImpl spy = PowerMockito.spy(intentInstanceService);
@@ -352,7 +362,7 @@ public class IntentInstanceServiceImplTest {
                 "    }\n" +
                 "}");
         Response<JSONObject> response = Response.success(jsonObject);
-        Mockito.when(intentApiService.getInstanceNetworkInfo(any())).thenReturn(mockCall);
+        Mockito.when(intentAaiService.getInstanceNetworkInfo(any())).thenReturn(mockCall);
         Mockito.when(mockCall.execute()).thenReturn(response);
 
         Call mockCall1 = PowerMockito.mock(Call.class);
@@ -402,7 +412,7 @@ public class IntentInstanceServiceImplTest {
                 "    }\n" +
                 "}");
         Response<JSONObject> response1 = Response.success(jsonObject1);
-        Mockito.when(intentApiService.getInstanceNetworkPolicyInfo(any())).thenReturn(mockCall1);
+        Mockito.when(intentAaiService.getInstanceNetworkPolicyInfo(any())).thenReturn(mockCall1);
         Mockito.when(mockCall1.execute()).thenReturn(response1);
 
         Call mockCall2 = PowerMockito.mock(Call.class);
@@ -421,7 +431,7 @@ public class IntentInstanceServiceImplTest {
                 "    ]\n" +
                 "}");
         Response<JSONObject> response2 = Response.success(jsonObject2);
-        Mockito.when(intentApiService.getInstanceBandwidth(any())).thenReturn(mockCall2);
+        Mockito.when(intentAaiService.getInstanceBandwidth(any())).thenReturn(mockCall2);
         Mockito.when(mockCall2.execute()).thenReturn(response2);
 
         Transaction tx = Mockito.mock(Transaction.class);
@@ -444,7 +454,7 @@ public class IntentInstanceServiceImplTest {
         when(query.uniqueResult()).thenReturn(instance);
 
         Call mockCall = PowerMockito.mock(Call.class);
-        when(intentApiService.deleteIntentInstance(any())).thenReturn(mockCall);
+        when(intentSoService.deleteIntentInstance(any())).thenReturn(mockCall);
         when(mockCall.execute()).thenReturn(null);
 
         Transaction tx = PowerMockito.mock(Transaction.class);
@@ -471,7 +481,7 @@ public class IntentInstanceServiceImplTest {
         when(query.uniqueResult()).thenReturn(instance);
 
         Call mockCall = PowerMockito.mock(Call.class);
-        when(intentApiService.deleteIntentInstance(any())).thenReturn(mockCall);
+        when(intentSoService.deleteIntentInstance(any())).thenReturn(mockCall);
         when(mockCall.execute()).thenReturn(null);
 
         Transaction tx = PowerMockito.mock(Transaction.class);
@@ -526,7 +536,7 @@ public class IntentInstanceServiceImplTest {
         Call mockCall = PowerMockito.mock(Call.class);
         JSONObject body = JSONObject.parseObject("{\"jobId\":\"123\"}");
         Response<JSONObject> response = Response.success(body);
-        Mockito.when(intentApiService.createIntentInstance(any())).thenReturn(mockCall);
+        Mockito.when(intentSoService.createIntentInstance(any())).thenReturn(mockCall);
         Mockito.when(mockCall.execute()).thenReturn(response);
 
         Transaction tx = Mockito.mock(Transaction.class);
@@ -592,7 +602,7 @@ public class IntentInstanceServiceImplTest {
                 "    ]\n" +
                 "}");
         Response<JSONObject> response = Response.success(body);
-        Mockito.when(intentApiService.queryNetworkRoute()).thenReturn(mockCall);
+        Mockito.when(intentAaiService.queryNetworkRoute()).thenReturn(mockCall);
         Mockito.when(mockCall.execute()).thenReturn(response);
         Map<String, Object> result = (Map<String, Object>) intentInstanceService.queryAccessNodeInfo();
         assertEquals(((List)result.get("accessNodeList")).size(), 3);
@@ -664,7 +674,9 @@ public class IntentInstanceServiceImplTest {
                 return null;
             }
         });
-        when(intentApiService.queryCustomer(anyString())).thenReturn(mockCall);
+
+        when(intentAaiService.queryCustomer(anyString())).thenReturn(mockCall);
+        when(intentAaiService.addCustomer(anyString(), any())).thenReturn(mockCall);
         when(mockCall.execute()).thenReturn(response);
 
         Properties properties = new Properties();
@@ -673,13 +685,10 @@ public class IntentInstanceServiceImplTest {
         properties.put("ccvpn.subscriberType", "INFRA");
         properties.put("ccvpn.serviceType", "IBN");
         IntentInstanceServiceImpl spy = spy(intentInstanceService);
-        doReturn(properties).when(spy).getProperties();
-
-        Call mockCall2 = PowerMockito.mock(Call.class);
-        when(intentApiService.addCustomer(anyString(),any())).thenReturn(mockCall2);
+        // doReturn(properties).when(spy).getProperties();
 
         spy.addCustomer();
-        Mockito.verify(intentApiService,Mockito.times(1)).addCustomer(anyString(),any());
+        Mockito.verify(intentAaiService,Mockito.times(1)).addCustomer(anyString(),any());
     }
 
 
@@ -704,42 +713,31 @@ public class IntentInstanceServiceImplTest {
                 return null;
             }
         });
-        when(intentApiService.querySubscription(anyString(),anyString())).thenReturn(mockCall);
+        when(intentProperties.getServiceType()).thenReturn("someServiceType");
+        when(intentAaiService.querySubscription(anyString(),anyString())).thenReturn(mockCall);
         when(mockCall.execute()).thenReturn(response);
 
-        Properties properties = new Properties();
-        properties.put("ccvpn.globalCustomerId", "IBNCustomer");
-        properties.put("ccvpn.subscriberName", "IBNCustomer");
-        properties.put("ccvpn.subscriberType", "INFRA");
-        properties.put("ccvpn.serviceType", "IBN");
         IntentInstanceServiceImpl spy = spy(intentInstanceService);
-        doReturn(properties).when(spy).getProperties();
 
         Call mockCall2 = PowerMockito.mock(Call.class);
-        when(intentApiService.addSubscription(anyString(),anyString(),any())).thenReturn(mockCall2);
+        when(intentAaiService.addSubscription(anyString(),anyString(),any())).thenReturn(mockCall2);
 
         spy.addSubscription();
-        Mockito.verify(intentApiService,Mockito.times(1)).addSubscription(anyString(),anyString(),any());
+        Mockito.verify(intentAaiService,Mockito.times(1)).addSubscription(anyString(),anyString(),any());
     }
 
     @Test
     public void saveIntentInstanceToAAITest() throws IOException {
+        when(intentProperties.getServiceType()).thenReturn("someServiceType");
         IntentInstanceServiceImpl spy = spy(intentInstanceService);
         doNothing().when(spy).addCustomer();
         doNothing().when(spy).addSubscription();
 
-        Properties properties = new Properties();
-        properties.put("ccvpn.globalCustomerId", "IBNCustomer");
-        properties.put("ccvpn.subscriberName", "IBNCustomer");
-        properties.put("ccvpn.subscriberType", "INFRA");
-        properties.put("ccvpn.serviceType", "IBN");
-        doReturn(properties).when(spy).getProperties();
-
         JSONObject body = new JSONObject();
         body.put("resource-version",123);
         Call mockCall = PowerMockito.mock(Call.class);
         Response<JSONObject> response = Response.success(body);
-        when(intentApiService.queryServiceInstance(anyString(),anyString(),anyString())).thenReturn(mockCall);
+        when(intentAaiService.queryServiceInstance(anyString(),anyString(),anyString())).thenReturn(mockCall);
         when(mockCall.execute()).thenReturn(response);
 
         CCVPNInstance instance = new CCVPNInstance();
@@ -748,40 +746,34 @@ public class IntentInstanceServiceImplTest {
 
         Call mockCall2 = PowerMockito.mock(Call.class);
         Response<JSONObject> response2 = Response.success(body);
-        when(intentApiService.saveServiceInstance(anyString(),anyString(),anyString(),any())).thenReturn(mockCall2);
+        when(intentAaiService.saveServiceInstance(anyString(),anyString(),anyString(),any())).thenReturn(mockCall2);
         when(mockCall2.execute()).thenReturn(response2);
 
         spy.saveIntentInstanceToAAI("CCVPN-id",instance);
-        Mockito.verify(intentApiService, Mockito.times(1)).saveServiceInstance(anyString(),anyString(),anyString(),any());
+        Mockito.verify(intentAaiService, Mockito.times(1)).saveServiceInstance(anyString(),anyString(),anyString(),any());
 
     }
     @Test
     public void deleteIntentInstanceToAAITest() throws IOException {
+        when(intentProperties.getServiceType()).thenReturn("someServiceType");
         IntentInstanceServiceImpl spy = spy(intentInstanceService);
         doNothing().when(spy).addCustomer();
         doNothing().when(spy).addSubscription();
 
-        Properties properties = new Properties();
-        properties.put("ccvpn.globalCustomerId", "IBNCustomer");
-        properties.put("ccvpn.subscriberName", "IBNCustomer");
-        properties.put("ccvpn.subscriberType", "INFRA");
-        properties.put("ccvpn.serviceType", "IBN");
-        doReturn(properties).when(spy).getProperties();
-
         JSONObject body = new JSONObject();
         body.put("resource-version",123);
         Call mockCall = PowerMockito.mock(Call.class);
         Response<JSONObject> response = Response.success(body);
-        when(intentApiService.queryServiceInstance(anyString(),anyString(),anyString())).thenReturn(mockCall);
+        when(intentAaiService.queryServiceInstance(anyString(),anyString(),anyString())).thenReturn(mockCall);
         when(mockCall.execute()).thenReturn(response);
 
         Call mockCall2 = PowerMockito.mock(Call.class);
         Response<JSONObject> response2 = Response.success(body);
-        when(intentApiService.deleteServiceInstance(anyString(),anyString(),anyString(),anyString())).thenReturn(mockCall2);
+        when(intentAaiService.deleteServiceInstance(anyString(),anyString(),anyString(),anyString())).thenReturn(mockCall2);
         when(mockCall2.execute()).thenReturn(response2);
 
         spy.deleteIntentInstanceToAAI("CCVPN-id");
-        Mockito.verify(intentApiService, Mockito.times(1)).deleteServiceInstance(anyString(),anyString(),anyString(),any());
+        Mockito.verify(intentAaiService, Mockito.times(1)).deleteServiceInstance(anyString(),anyString(),anyString(),any());
 
     }
     @Test
@@ -997,4 +989,4 @@ public class IntentInstanceServiceImplTest {
 
         assertEquals(spy.updateCCVPNInstance(instance), 1);
     }
-}
\ No newline at end of file
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceIntegrationTest.java b/server/src/test/java/org/onap/usecaseui/server/service/intent/impl/IntentInstanceServiceIntegrationTest.java
new file mode 100644 (file)
index 0000000..5bbe874
--- /dev/null
@@ -0,0 +1,183 @@
+/**
+ * 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.intent.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.equalToJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.onap.usecaseui.server.bean.intent.CCVPNInstance;
+import org.onap.usecaseui.server.config.AAIClientConfig;
+import org.onap.usecaseui.server.config.SOClientConfig;
+import org.onap.usecaseui.server.service.csmf.SlicingService;
+import org.onap.usecaseui.server.service.csmf.config.SlicingProperties;
+import org.onap.usecaseui.server.service.csmf.impl.SlicingServiceImpl;
+import org.onap.usecaseui.server.service.intent.IntentAaiService;
+import org.onap.usecaseui.server.service.intent.IntentSoService;
+import org.onap.usecaseui.server.service.intent.config.IntentProperties;
+import org.onap.usecaseui.server.service.lcm.impl.DefaultServiceLcmService;
+import org.onap.usecaseui.server.service.nsmf.impl.ResourceMgtServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.HttpHeaders;
+import org.wiremock.spring.EnableWireMock;
+
+import lombok.SneakyThrows;
+
+@EnableWireMock
+@SpringBootTest(
+  classes = {
+        AAIClientConfig.class,
+        SOClientConfig.class,
+        SlicingServiceImpl.class,
+        SlicingProperties.class,
+        IntentProperties.class
+  },
+  properties = {
+    "uui-server.client.aai.baseUrl=${wiremock.server.baseUrl}",
+    "uui-server.client.aai.username=AAI",
+    "uui-server.client.aai.password=AAI",
+    "uui-server.client.so.baseUrl=${wiremock.server.baseUrl}",
+    "uui-server.client.so.username=InfraPortalClient",
+    "uui-server.client.so.password=password1",
+    "uui-server.slicing.service-invariant-uuid=someServiceInvariantUuid",
+    "uui-server.slicing.service-uuid=someServiceUuid",
+    "uui-server.slicing.global-subscriber-id=someGlobalSubscriberId",
+    "uui-server.slicing.service-type=someServiceType",
+    "uui-server.ccvpn.globalCustomerId=defaultGlobalCustomerId"
+  }
+)
+@EnableConfigurationProperties
+public class IntentInstanceServiceIntegrationTest {
+
+  @Value("${uui-server.client.so.username}")
+  String soUsername;
+
+  @Value("${uui-server.client.so.password}")
+  String soPassword;
+
+  @Value("${uui-server.client.aai.username}")
+  String aaiUsername;
+
+  @Value("${uui-server.client.aai.password}")
+  String aaiPassword;
+
+  @Mock
+  ResourceMgtServiceImpl resourceMgtServiceImpl;
+
+  @MockBean
+  DefaultServiceLcmService lcmService;
+
+  @Autowired
+  SlicingService slicingService;
+
+  @Autowired
+  IntentAaiService intentAaiService;
+
+  @Autowired
+  IntentSoService intentSoService;
+
+  @Autowired
+  IntentProperties intentProperties;
+
+  @Mock
+  Session session;
+
+  @BeforeEach
+  void setup() {
+    SessionFactory sessionFactory = mock(SessionFactory.class);
+    Transaction transaction = mock(Transaction.class);
+    when(sessionFactory.openSession()).thenReturn(session);
+    when(session.beginTransaction()).thenReturn(transaction);
+    this.intentService = new IntentInstanceServiceImpl(slicingService, intentAaiService, intentSoService, sessionFactory, resourceMgtServiceImpl, intentProperties);
+  }
+
+  IntentInstanceServiceImpl intentService;
+
+  @Test
+  @SneakyThrows
+  void thatCCVPNInstanceCanBeCreated() {
+    byte[] requestBytes = Files.readAllBytes(Paths.get("src/test/resources/__files/requests/createIntentRequest.json"));
+    String expectedRequestBody = new String(requestBytes, StandardCharsets.UTF_8);
+    stubFor(
+      post("/so/infra/serviceIntent/v1/create")
+        .withBasicAuth(soUsername, soPassword)
+        .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
+        .withHeader("X-TransactionId", equalTo("9999"))
+        .withHeader("X-FromAppId", equalTo("onap-cli"))
+        .withRequestBody(equalToJson(expectedRequestBody))
+        .willReturn(
+            aResponse().withBodyFile("createIntentResponse.json")
+        ));
+
+    stubFor(
+        get("/aai/v24/business/customers/customer/defaultGlobalCustomerId")
+        .withBasicAuth(aaiUsername, aaiPassword)
+        .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
+        .withHeader("X-TransactionId", equalTo("7777"))
+        .withHeader("X-FromAppId", equalTo("uui"))
+        .willReturn(
+            aResponse().withBodyFile("customersResponse.json")
+        ));
+
+    stubFor(
+        get("/aai/v24/business/customers/customer/defaultGlobalCustomerId/service-subscriptions/service-subscription/defaultServiceType")
+        .withBasicAuth(aaiUsername, aaiPassword)
+        .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
+        .withHeader("X-TransactionId", equalTo("7777"))
+        .withHeader("X-FromAppId", equalTo("uui"))
+        .willReturn(
+            aResponse().withBodyFile("customersResponse.json")
+        ));
+
+    stubFor(
+        put("/aai/v24/business/customers/customer/defaultGlobalCustomerId/service-subscriptions/service-subscription/defaultServiceType/service-instances/service-instance/IBN-someInstanceId")
+        .withBasicAuth(aaiUsername, aaiPassword)
+        .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
+        .withHeader("X-TransactionId", equalTo("7777"))
+        .withHeader("X-FromAppId", equalTo("uui"))
+        .willReturn(
+            aResponse().withBodyFile("customersResponse.json")
+        ));
+
+    CCVPNInstance ccVpnInstance = new CCVPNInstance();
+    ccVpnInstance.setInstanceId("someInstanceId");
+    ccVpnInstance.setAccessPointOneName("accessPointOneName");
+    int result = intentService.createCCVPNInstance(ccVpnInstance);
+    assertEquals(1, result);
+  }
+
+}
diff --git a/server/src/test/resources/__files/createIntentResponse.json b/server/src/test/resources/__files/createIntentResponse.json
new file mode 100644 (file)
index 0000000..1635f05
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  "jobId": "someJob"
+}
diff --git a/server/src/test/resources/__files/requests/createIntentRequest.json b/server/src/test/resources/__files/requests/createIntentRequest.json
new file mode 100644 (file)
index 0000000..215ae21
--- /dev/null
@@ -0,0 +1,26 @@
+{
+  "modelInvariantUuid": "6790ab0e-034f-11eb-adc1-0242ac120002",
+  "serviceType": "CLL",
+  "subscriptionServiceType": "IBN",
+  "globalSubscriberId": "IBNCustomer",
+  "additionalProperties": {
+    "transportNetworks": [
+      {
+        "connectionLinks": [
+          {
+            "transportEndpointA": "accessPointOneName",
+            "name": ""
+          }
+        ],
+        "sla": {
+          "maxBandwidth": 0,
+          "latency": "2"
+        },
+        "id": ""
+      }
+    ],
+    "serviceInstanceID": "cll-someInstanceId",
+    "enableSdnc": "true"
+  },
+  "modelUuid": "6790ab0e-034f-11eb-adc1-0242ac120002"
+}
index ef187a7..ab2457b 100644 (file)
@@ -19,7 +19,7 @@
     <parent>
         <groupId>org.onap.usecase-ui.server</groupId>
         <artifactId>usecase-ui-server-parent</artifactId>
-        <version>15.0.0-SNAPSHOT</version>
+        <version>15.0.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>usecase-ui-server-standalone</artifactId>
@@ -28,7 +28,7 @@
     <description>distribute binary files and docker image for usecase-ui server</description>
 
     <properties>
-        <usecaseui.version>15.0.0</usecaseui.version>
+        <usecaseui.version>15.0.1</usecaseui.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
@@ -40,7 +40,7 @@
         <finalName>usecse-ui-server</finalName>
         <plugins>
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId> 
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-resources-plugin</artifactId>
                 <executions>
                     <execution>
index dd5418f..6481e8b 100644 (file)
@@ -4,7 +4,7 @@
 
 major=15
 minor=0
-patch=0
+patch=1
 
 base_version=${major}.${minor}.${patch}