aboutsummaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/java/org
diff options
context:
space:
mode:
authorKeguang He <hekeguang@chinamobile.com>2022-09-15 15:41:22 +0000
committerGerrit Code Review <gerrit@onap.org>2022-09-15 15:41:22 +0000
commit07c5b07f49e36fbd31074cdee3a80e3142a7335b (patch)
treebf50dd805c2b41f4c456f16285b98ff7bed3b4e5 /intentanalysis/src/main/java/org
parentd0b3048fe93a50fdaa2ad34a166794abdc902580 (diff)
parent95d2de5a5dd75626c69ab2f530f7a88f36ba30ac (diff)
Merge "Add UT for SO adapter"
Diffstat (limited to 'intentanalysis/src/main/java/org')
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java3
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java19
2 files changed, 17 insertions, 5 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java
index 4129b8e..7b56e17 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java
@@ -16,11 +16,12 @@
package org.onap.usecaseui.intentanalysis.adapters.so;
import org.onap.usecaseui.intentanalysis.bean.models.CCVPNInstance;
+import org.springframework.stereotype.Service;
public interface SOService {
int createCCVPNInstance(CCVPNInstance instance);
- void deleteIntentInstance(String instanceId);
+ int deleteIntentInstance(String instanceId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java
index e4e1f60..6f5cbcc 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java
@@ -21,7 +21,6 @@ import com.alibaba.fastjson.JSONObject;
import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAPICall;
import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAuthConfig;
import org.onap.usecaseui.intentanalysis.adapters.policy.apicall.PolicyAPICall;
-import org.onap.usecaseui.intentanalysis.adapters.policy.apicall.PolicyAuthConfig;
import org.onap.usecaseui.intentanalysis.adapters.so.SOService;
import org.onap.usecaseui.intentanalysis.adapters.so.apicall.SOAPICall;
import org.onap.usecaseui.intentanalysis.adapters.so.apicall.SOAuthConfig;
@@ -30,18 +29,19 @@ import org.onap.usecaseui.intentanalysis.util.RestfulServices;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
import retrofit2.Response;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+@Service
public class SOServiceImpl implements SOService {
private static final Logger logger = LoggerFactory.getLogger(SOServiceImpl.class);
-
private SOAPICall soapiCall;
private AAIAPICall aaiapiCall;
@@ -68,8 +68,16 @@ public class SOServiceImpl implements SOService {
return this.aaiapiCall;
}
+ public void setSoApiCall(SOAPICall soApiCall) {
+ this.soapiCall = soApiCall;
+ }
+
+ public void setAAIApiCall(AAIAPICall aaiApiCall) {
+ this.aaiapiCall = aaiApiCall;
+ }
+
@Override
- public int createCCVPNInstance(CCVPNInstance ccvpnInstance) {
+ public int createCCVPNInstance(CCVPNInstance ccvpnInstance) {
try{
if (null == ccvpnInstance){
logger.error("CCVPN instance is null!");
@@ -100,17 +108,20 @@ public class SOServiceImpl implements SOService {
}
@Override
- public void deleteIntentInstance(String serviceInstanceId) {
+ public int deleteIntentInstance(String serviceInstanceId) {
try {
deleteInstanceToSO(serviceInstanceId);
}catch (Exception e) {
logger.error("delete instance to SO error :" + e);
+ return 0;
}
+ return 1;
}
public String createIntentInstanceToSO(CCVPNInstance ccvpnInstance) throws IOException {
Map<String, Object> params = paramsSetUp(ccvpnInstance);
params.put("additionalProperties",additionalPropertiesSetUp(ccvpnInstance));
+ //make sure params are in conformity with format
okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params));
Response<JSONObject> response = getSoApiCall().createIntentInstance(requestBody).execute();
if (response.isSuccessful()) {