summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaixiliu <liukaixi@chinamobile.com>2023-06-13 16:24:29 +0800
committerkaixiliu <liukaixi@chinamobile.com>2023-06-13 16:24:47 +0800
commit6e2dc3e031d258c2a447d6a175ce100bb3956993 (patch)
tree29cfa19f956ef2454c033ab6efe442c1a29d9d1e
parent09cd2f9f50b3ecde778e7d5ba4e243bbad74eef2 (diff)
Layered Analysis FulfillmentInfo
Issue-ID: USECASEUI-812 Signed-off-by: kaixiliu <liukaixi@chinamobile.com> Change-Id: I79a06db33444a153708cd1804789a5d719551b9f
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/NotFulfilledReason.java40
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java14
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java26
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java22
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java30
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java5
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java17
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java7
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfillmentInfoService.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java3
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java23
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java82
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfillmentInfoServiceImpl.java13
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java33
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java56
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/HttpUtil.java97
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ObjectInstanceMapper.xml12
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java5
20 files changed, 411 insertions, 84 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/NotFulfilledReason.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/NotFulfilledReason.java
new file mode 100644
index 0000000..29a6bc7
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/NotFulfilledReason.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.bean.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum NotFulfilledReason {
+ INSUFFICIENT_BAND_WITH(0, "Insufficient bandwidth resources", "Insufficient bandwidth resources", "Insufficient bandwidth resources"),
+ SERVICE_DOWNTIME(1, "Service downtime", "Service downtime", "Service downtime");
+
+ private int index;
+
+ private String reason;
+
+ private String businessReason;
+
+ private String formatReason;
+
+ NotFulfilledReason(int index, String reason, String businessReason, String formatReason) {
+ this.index = index;
+ this.reason = reason;
+ this.businessReason = businessReason;
+ this.formatReason = formatReason;
+ }
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java
index 084f74d..2ca3352 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java
@@ -15,17 +15,18 @@
*/
package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt;
-
import lombok.Data;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentEventRecord;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.exception.CommonException;
+import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentEventRecord.IntentEventRecordService;
@@ -80,6 +81,9 @@ public class CLLBusinessIntentManagementFunction extends IntentManagementFunctio
@Autowired
IntentEventRecordService intentEventRecordService;
+ @Autowired
+ private FormatIntentInputManagementFunction formatIntentInputManagementFunction;
+
@Resource(name = "intentTaskExecutor")
ThreadPoolTaskExecutor executor;
@@ -120,6 +124,14 @@ public class CLLBusinessIntentManagementFunction extends IntentManagementFunctio
}
}
+ @Override
+ public void createReport(String intentId, FulfillmentInfo fulfillmentInfo) {
+ String parentIntentId = intentService.findParentByIntentId(intentId);
+ intentInterfaceService.reportInterface(formatIntentInputManagementFunction, parentIntentId, fulfillmentInfo);
+
+ saveFulfillmentAndObjectInstance(intentId, fulfillmentInfo);
+ }
+
public IntentGoalBean detection(IntentGoalBean intentGoalBean) {
Intent originIntent = intentGoalBean.getIntent();
IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java
index d47e67b..e2865bf 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java
@@ -18,12 +18,17 @@ package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.Thread.CreateCallable;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
+import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
+import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -57,6 +62,15 @@ public class CLLAssuranceIntentManagementFunction extends IntentManagementFuncti
@Resource(name = "intentTaskExecutor")
ThreadPoolTaskExecutor executor;
+ @Autowired
+ private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
+
+ @Autowired
+ private IntentInterfaceService intentInterfaceService;
+
+ @Autowired
+ private IntentService intentService;
+
@Override
public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) {
}
@@ -77,4 +91,16 @@ public class CLLAssuranceIntentManagementFunction extends IntentManagementFuncti
}
+ @Override
+ public void createReport(String intentId, FulfillmentInfo fulfillmentInfo) {
+ //get parent intentId
+ String parentIntentId = intentService.findParentByIntentId(intentId);
+ // todo
+ FulfillmentInfo newInfo = new FulfillmentInfo();
+ BeanUtils.copyProperties(fulfillmentInfo, newInfo);
+
+ intentInterfaceService.reportInterface(cllBusinessIntentManagementFunction, parentIntentId, newInfo);
+
+ saveFulfillmentAndObjectInstance(intentId, fulfillmentInfo);
+ }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java
index d4e3c80..1c5f7af 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java
@@ -16,14 +16,19 @@
package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt;
import lombok.Data;
+import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.Thread.CreateCallable;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
+import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
+import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -57,6 +62,15 @@ public class CLLDeliveryIntentManagementFunction extends IntentManagementFunctio
@Resource(name = "intentTaskExecutor")
ThreadPoolTaskExecutor executor;
+ @Autowired
+ private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
+
+ @Autowired
+ private IntentInterfaceService intentInterfaceService;
+
+ @Autowired
+ private IntentService intentService;
+
@Override
public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) {
}
@@ -74,4 +88,12 @@ public class CLLDeliveryIntentManagementFunction extends IntentManagementFunctio
log.error("exception is {}", ex.getMessage());
}
}
+
+ @Override
+ public void createReport(String intentId, FulfillmentInfo fulfillmentInfo) {
+ String parentIntentId = intentService.findParentByIntentId(intentId);
+ intentInterfaceService.reportInterface(cllBusinessIntentManagementFunction, parentIntentId, fulfillmentInfo);
+
+ saveFulfillmentAndObjectInstance(intentId, fulfillmentInfo);
+ }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java
index dc63ba5..8e1223b 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java
@@ -15,6 +15,9 @@
*/
package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.clldeliverymodule;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.adapters.so.SOService;
@@ -27,9 +30,11 @@ import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
import org.onap.usecaseui.intentanalysis.service.ExpectationService;
import org.onap.usecaseui.intentanalysis.service.FulfillmentInfoService;
import org.onap.usecaseui.intentanalysis.service.IntentService;
+import org.onap.usecaseui.intentanalysis.util.HttpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,6 +43,9 @@ import java.util.UUID;
@Component
@Slf4j
public class CLLDeliveryActuationModule extends ActuationModule {
+ public final static String NLP_HOST = "http://uui-nlp";
+ public final static String NLP_ONLINE_URL_BASE = NLP_HOST + ":43011";
+ public final static String PREDICT_URL = NLP_ONLINE_URL_BASE + "/api/online/predict";
@Autowired
private SOService soService;
@@ -71,12 +79,13 @@ public class CLLDeliveryActuationModule extends ActuationModule {
for (ExpectationTarget target : targetList) {
String conditionName = target.getTargetConditions().get(0).getConditionName();
String conditionValue = target.getTargetConditions().get(0).getConditionValue();
+ String value = getPredictValue(conditionName, conditionValue);
if (StringUtils.containsIgnoreCase(conditionName, "source")) {
- accessPointOne.put("name", conditionValue);
+ accessPointOne.put("name", value);
} else if (StringUtils.containsIgnoreCase(conditionName, "destination")) {
- params.put("cloudPointName", conditionValue);
+ params.put("cloudPointName", value);
} else if (StringUtils.containsIgnoreCase(conditionName, "bandwidth")) {
- accessPointOne.put("bandwidth", conditionValue);
+ accessPointOne.put("bandwidth", value);
}
}
params.put("accessPointOne", accessPointOne);
@@ -135,6 +144,21 @@ public class CLLDeliveryActuationModule extends ActuationModule {
public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
this.directOperation(intentGoalBean);
}
+
+ private String getPredictValue(String name, String value) {
+ String text = "expectationName is cloud leased line Delivery Expectation, " +
+ "firstName is " + name + ",firstValue is " + value;
+ String[] questions = {"expectationName", "Name", "Value"};
+ String bodyStr = "{\"title\": \"predict\", \"text\": \"" + text
+ + "\", \"questions\":" + new JSONArray().toJSONString(Arrays.asList(questions)) + "}";
+ HashMap<String, String> headers = new HashMap<>();
+ String result = HttpUtil.sendPostRequestByJson(PREDICT_URL, headers, bodyStr);
+ if("failed".equals(result)){
+ return value;
+ }
+ JSONObject jsonObject = JSON.parseObject(result);
+ return jsonObject.getString("Value");
+ }
public String getInstanceId() {
int random = (int) (Math.random() * 9 + 1);
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java
index 59b1741..0552dbc 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java
@@ -58,4 +58,9 @@ public final class ResponseConsts {
* empty param
*/
public static final int EMPTY_PARAM = 10006;
+
+ /**
+ * utf-8
+ */
+ public static final String ENCODING_UTF8="utf-8";
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java
index d893734..cfa7df2 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java
@@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGenerateType;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
@@ -81,6 +82,11 @@ public class FormatIntentInputManagementFunction extends IntentManagementFunctio
public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
}
+ @Override
+ public void createReport(String intentId, FulfillmentInfo fulfillmentInfo) {
+ saveFulfillmentAndObjectInstance(intentId, fulfillmentInfo);
+ }
+
public IntentGoalBean detection(IntentGoalBean intentGoalBean) {
Intent originIntent = intentGoalBean.getIntent();
IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
index 453a1cd..7c01c81 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
@@ -17,11 +17,15 @@ package org.onap.usecaseui.intentanalysis.intentBaseService;
import lombok.Data;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
+import org.onap.usecaseui.intentanalysis.service.FulfillmentInfoService;
+import org.onap.usecaseui.intentanalysis.service.ObjectInstanceService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@@ -33,6 +37,19 @@ public class IntentManagementFunction {
protected DecisionModule decisionModule;
protected KnowledgeModule knowledgeModule;
+ @Autowired
+ private FulfillmentInfoService fulfillmentInfoService;
+
+ @Autowired
+ private ObjectInstanceService objectInstanceService;
+
public void receiveIntentAsOwner(IntentGoalBean intentGoalBean){};
public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler){};
+ public void createReport(String intentId, FulfillmentInfo fulfillmentInfo){};
+
+ protected void saveFulfillmentAndObjectInstance(String intentId, FulfillmentInfo fulfillmentInfo) {
+ // save fulfillmentInfo and objectInstance
+ fulfillmentInfoService.saveFulfillmentInfo(intentId, fulfillmentInfo);
+ objectInstanceService.saveObjectInstances(intentId, fulfillmentInfo);
+ }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java
index bbeb12e..8b7dfd0 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java
@@ -15,6 +15,7 @@
*/
package org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
@@ -26,4 +27,5 @@ public interface IntentInterfaceService {
public boolean deleteInterface(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction imf);
+ public boolean reportInterface(IntentManagementFunction imf, String intentId, FulfillmentInfo fulfillmentInfo);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java
index b142b5a..a075a9a 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java
@@ -15,6 +15,7 @@
*/
package org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.impl;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
@@ -57,4 +58,10 @@ public class IntentInterfaceServiceImpl implements IntentInterfaceService {
}
return true;
}
+
+ @Override
+ public boolean reportInterface(IntentManagementFunction imf, String intentId, FulfillmentInfo fulfillmentInfo) {
+ imf.createReport(intentId, fulfillmentInfo);
+ return true;
+ }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfillmentInfoService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfillmentInfoService.java
index 5532c6c..df86219 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfillmentInfoService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfillmentInfoService.java
@@ -27,4 +27,6 @@ public interface FulfillmentInfoService {
void updateFulfillmentInfo(FulfillmentInfo fulfillmentInfo, String parentId);
FulfillmentInfo getFulfillmentInfo(String parentId);
+
+ void saveFulfillmentInfo(String intentId, FulfillmentInfo eventModel);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java
index 2dc69da..1c49402 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java
@@ -16,7 +16,6 @@
package org.onap.usecaseui.intentanalysis.service;
-
import java.util.List;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
@@ -37,4 +36,6 @@ public interface IntentService {
List<String> getSubIntentList(Intent intent);
List<Intent> getIntentListByUserInput(String intentGenerateType);
+
+ String findParentByIntentId(String intentId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java
new file mode 100644
index 0000000..5925c2d
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2023 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.service;
+
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
+
+public interface ObjectInstanceService {
+ void saveObjectInstances(String intentId, FulfillmentInfo eventModel);
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java
index 608423e..c9de92a 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java
@@ -19,19 +19,22 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
import org.onap.usecaseui.intentanalysis.bean.models.*;
+import org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.CLLAssuranceIntentManagementFunction;
+import org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.CLLDeliveryIntentManagementFunction;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.CommonException;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
+import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
+import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
import org.onap.usecaseui.intentanalysis.mapper.*;
import org.onap.usecaseui.intentanalysis.service.ComponentNotificationService;
-import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
-import java.util.stream.Collectors;
@Slf4j
@Service
@@ -44,16 +47,10 @@ public class ComponentNotificationServiceImpl implements ComponentNotificationSe
private ExpectationMapper expectationMapper;
@Autowired
- private ContextMapper contextMapper;
+ private ApplicationContext applicationContext;
@Autowired
- private ConditionMapper conditionMapper;
-
- @Autowired
- private FulfillmentInfoMapper fulfillmentInfoMapper;
-
- @Autowired
- private ObjectInstanceMapper objectInstanceMapper;
+ private IntentInterfaceService intentInterfaceService;
/**
* Generate a new FulfillmentInfo based on third-party FulfillmentOperation
@@ -83,8 +80,8 @@ public class ComponentNotificationServiceImpl implements ComponentNotificationSe
}
log.info("ExpectationId is {}", expectationIds);
String intentId = null;
+ ExpectationType expectationType = getExpectationType(operation);
for (String expectationId : expectationIds) {
- ExpectationType expectationType = getExpectationType(operation);
intentId = expectationMapper.getIntentIdByExpectationId(expectationId, expectationType);
if (StringUtils.isNotEmpty(intentId)) {
break;
@@ -97,64 +94,13 @@ public class ComponentNotificationServiceImpl implements ComponentNotificationSe
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
- String parentByIntentId = findParentByIntentId(findParentByIntentId(intentId));
- log.info("The parentByIntentId is {}", parentByIntentId);
-
- saveFulfillmentInfo(parentByIntentId, eventModel);
- }
-
- private void saveFulfillmentInfo(String intentId, FulfillmentOperation eventModel) {
- FulfillmentInfo fulfillmentInfo = fulfillmentInfoMapper.selectFulfillmentInfo(intentId);
- if (fulfillmentInfo != null) {
- fulfillmentInfoMapper.deleteFulfillmentInfo(intentId);
- }
- FulfillmentInfo newInfo = new FulfillmentInfo();
- BeanUtils.copyProperties(eventModel, newInfo);
- int num = fulfillmentInfoMapper.insertFulfillmentInfo(newInfo, intentId);
- if (num < 1) {
- String msg = "Failed to insert fulfillmentInfo to database.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
- }
- List<String> instances = eventModel.getObjectInstances();
- List<String> objectInstancesDb = objectInstanceMapper.getObjectInstances(intentId);
- if (!CollectionUtils.isEmpty(objectInstancesDb)) {
- instances.removeAll(objectInstancesDb);
- if (CollectionUtils.isEmpty(instances)) {
- log.info("The objectInstances already exist in the database");
- return;
- }
- }
- int objectInstanceNum = objectInstanceMapper.insertObjectInstanceList(instances, intentId);
- if (objectInstanceNum < 1) {
- String msg = "Failed to insert objectInstances to database.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
- }
- }
-
- public String findParentByIntentId(String intentId) {
- List<Context> contexts = contextMapper.selectContextList(intentId);
- if (CollectionUtils.isEmpty(contexts)) {
- log.error("Get context is empty,intentId is {}", intentId);
- String msg = "Get Contexts is empty from database";
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- List<Context> collect = contexts.stream()
- .filter(context -> "parentIntent info".equalsIgnoreCase(context.getContextName()))
- .collect(Collectors.toList());
- if (CollectionUtils.isEmpty(collect) || collect.size() != 1) {
- log.error("This intent has not parent intent,intentId is {}", intentId);
- String msg = "Get Context is empty from database";
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- Context context = collect.get(0);
- List<Condition> conditions = conditionMapper.selectConditionList(context.getContextId());
- if (CollectionUtils.isEmpty(conditions) || StringUtils.isEmpty(conditions.get(0).getConditionValue())) {
- String msg = "Get conditions is empty from database";
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ IntentManagementFunction function;
+ if (expectationType == ExpectationType.ASSURANCE) {
+ function = (IntentManagementFunction) applicationContext.getBean(CLLAssuranceIntentManagementFunction.class.getSimpleName());
+ } else {
+ function = (IntentManagementFunction) applicationContext.getBean(CLLDeliveryIntentManagementFunction.class.getSimpleName());
}
- return conditions.get(0).getConditionValue();
+ intentInterfaceService.reportInterface(function, intentId, eventModel);
}
private ExpectationType getExpectationType(String operation) {
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfillmentInfoServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfillmentInfoServiceImpl.java
index 6a72aea..9cd112f 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfillmentInfoServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfillmentInfoServiceImpl.java
@@ -16,11 +16,8 @@
package org.onap.usecaseui.intentanalysis.service.impl;
-
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
@@ -28,7 +25,6 @@ import org.onap.usecaseui.intentanalysis.mapper.FulfillmentInfoMapper;
import org.onap.usecaseui.intentanalysis.service.FulfillmentInfoService;
import lombok.extern.slf4j.Slf4j;
-
@Service
@Slf4j
public class FulfillmentInfoServiceImpl implements FulfillmentInfoService {
@@ -89,4 +85,13 @@ public class FulfillmentInfoServiceImpl implements FulfillmentInfoService {
}
return fulfillmentInfo;
}
+
+ @Override
+ public void saveFulfillmentInfo(String intentId, FulfillmentInfo eventModel) {
+ FulfillmentInfo fulfillmentInfo = fulfillmentInfoService.getFulfillmentInfo(intentId);
+ if (fulfillmentInfo != null) {
+ fulfillmentInfoService.deleteFulfillmentInfo(intentId);
+ }
+ fulfillmentInfoService.createFulfillmentInfo(eventModel, intentId);
+ }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
index 66d3f02..a04f909 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
@@ -26,6 +26,8 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.bean.models.Condition;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
+import org.onap.usecaseui.intentanalysis.mapper.ConditionMapper;
+import org.onap.usecaseui.intentanalysis.mapper.ContextMapper;
import org.onap.usecaseui.intentanalysis.mapper.ObjectInstanceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -65,6 +67,12 @@ public class IntentServiceImpl implements IntentService {
@Autowired
private ObjectInstanceMapper objectInstanceMapper;
+ @Autowired
+ private ContextMapper contextMapper;
+
+ @Autowired
+ private ConditionMapper conditionMapper;
+
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Intent createIntent(Intent intent) {
@@ -191,4 +199,29 @@ public class IntentServiceImpl implements IntentService {
}
return intentList;
}
+
+ @Override
+ public String findParentByIntentId(String intentId) {
+ List<Context> contexts = contextMapper.selectContextList(intentId);
+ if (org.springframework.util.CollectionUtils.isEmpty(contexts)) {
+ log.error("Get context is empty,intentId is {}", intentId);
+ String msg = "Get Contexts is empty from database";
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ List<Context> collect = contexts.stream()
+ .filter(context -> "parentIntent info".equalsIgnoreCase(context.getContextName()))
+ .collect(Collectors.toList());
+ if (org.springframework.util.CollectionUtils.isEmpty(collect) || collect.size() != 1) {
+ log.error("This intent has not parent intent,intentId is {}", intentId);
+ String msg = "Get Context is empty from database";
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ Context context = collect.get(0);
+ List<Condition> conditions = conditionMapper.selectConditionList(context.getContextId());
+ if (org.springframework.util.CollectionUtils.isEmpty(conditions) || StringUtils.isEmpty(conditions.get(0).getConditionValue())) {
+ String msg = "Get conditions is empty from database";
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ return conditions.get(0).getConditionValue();
+ }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java
new file mode 100644
index 0000000..1d60ca5
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2023 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.service.impl;
+
+import lombok.extern.slf4j.Slf4j;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
+import org.onap.usecaseui.intentanalysis.mapper.ObjectInstanceMapper;
+import org.onap.usecaseui.intentanalysis.service.ObjectInstanceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Slf4j
+@Service
+public class ObjectInstanceServiceImpl implements ObjectInstanceService {
+ @Autowired
+ private ObjectInstanceMapper objectInstanceMapper;
+
+ @Override
+ public void saveObjectInstances(String intentId, FulfillmentInfo eventModel) {
+ List<String> instances = new ArrayList<>(eventModel.getObjectInstances());
+ List<String> objectInstancesDb = objectInstanceMapper.getObjectInstances(intentId);
+ if (!CollectionUtils.isEmpty(objectInstancesDb)) {
+ instances.removeAll(objectInstancesDb);
+ if (CollectionUtils.isEmpty(instances)) {
+ log.info("The objectInstances already exist in the database");
+ return;
+ }
+ }
+ int objectInstanceNum = objectInstanceMapper.insertObjectInstanceList(instances, intentId);
+ if (objectInstanceNum < 1) {
+ String msg = "Failed to insert objectInstances to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ }
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/HttpUtil.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/HttpUtil.java
new file mode 100644
index 0000000..5fc93c6
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/HttpUtil.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2023 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+
+import static org.onap.usecaseui.intentanalysis.common.ResponseConsts.ENCODING_UTF8;
+
+@Slf4j
+public class HttpUtil {
+ private static final String LOG_FORMATTER = "[ {} ] {} ";
+ private static final String CLIENT_PRTOCOL_EXCEPTION = "Client protocol exception";
+ private static final String IO_EXCEPTION = "IO Exception occured";
+ private static final String EXCEPTION = "Exception occured";
+ private static final String FAILED = "failed";
+
+ public static String sendPostRequestByJson(String url, Map<String, String> headerMap, String requestBodyJson) {
+ log.info(LOG_FORMATTER ,url , " API POST calling is starting......");
+ RequestConfig defaultRequestConfig = RequestConfig.custom()
+ .setConnectTimeout(50000)
+ .setConnectionRequestTimeout(50000)
+ .setSocketTimeout(50000)
+ .build();
+
+ try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+ // set request url and header for API calling
+ HttpPost httpPost = new HttpPost(url);
+ httpPost.setConfig(defaultRequestConfig);
+ setHeader(httpPost, headerMap);
+ // set request body for API calling
+ httpPost.setEntity(setBodyByJson(requestBodyJson));
+
+ // execute API calling and return response
+ try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (HttpStatus.SC_OK == statusCode) {
+ return EntityUtils.toString(response.getEntity(), ENCODING_UTF8);
+ } else {
+ log.error("The response code is {}", statusCode);
+ return FAILED;
+ }
+ }
+ } catch (ClientProtocolException cpe) {
+ log.error(CLIENT_PRTOCOL_EXCEPTION, cpe);
+ } catch (IOException ioe) {
+ log.error(IO_EXCEPTION, ioe);
+ } catch (Exception e) {
+ log.error(EXCEPTION, e);
+ }
+ log.error(LOG_FORMATTER, url, " API POST calling has finished!");
+ return FAILED;
+ }
+
+ private static void setHeader(HttpRequestBase request, Map<String, String> headerMap) {
+ if (headerMap != null) {
+ Set<String> keySet = headerMap.keySet();
+ for (String key : keySet) {
+ request.addHeader(key, headerMap.get(key));
+ }
+ }
+ }
+
+ private static StringEntity setBodyByJson(String requestBodyJson) {
+ StringEntity se = new StringEntity(requestBodyJson, ContentType.APPLICATION_JSON);
+ se.setContentEncoding(ENCODING_UTF8);
+ return se;
+ }
+}
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ObjectInstanceMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ObjectInstanceMapper.xml
index 63047ce..cec563c 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ObjectInstanceMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ObjectInstanceMapper.xml
@@ -5,11 +5,13 @@
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.ObjectInstanceMapper">
<insert id="insertObjectInstanceList">
- insert into object_instance(parent_id, object_instance)
- values
- <foreach collection="objectInstances" index="index" item="item" separator=",">
- (#{parentId}, #{item})
- </foreach>
+ <if test="objectInstances != null and objectInstances.size>0">
+ insert into object_instance(parent_id, object_instance)
+ values
+ <foreach collection="objectInstances" index="index" item="item" separator=",">
+ (#{parentId}, #{item})
+ </foreach>
+ </if>
</insert>
<select id="getObjectInstances" resultType="java.lang.String">
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java
index 30ffd01..37a8b79 100644
--- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java
@@ -19,8 +19,8 @@ package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.clldeliverymodule
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
import org.onap.usecaseui.intentanalysis.adapters.so.SOService;
@@ -29,6 +29,7 @@ import org.onap.usecaseui.intentanalysis.bean.models.*;
import org.onap.usecaseui.intentanalysis.service.ContextService;
import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
import org.onap.usecaseui.intentanalysis.service.ExpectationService;
+import org.onap.usecaseui.intentanalysis.util.HttpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -37,7 +38,6 @@ import java.util.ArrayList;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
-import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest(classes = IntentAnalysisApplicationTests.class)
@RunWith(SpringRunner.class)
@@ -98,6 +98,7 @@ public class CLLDeliveryActuationModuleTest {
List<Expectation> expectationList = new ArrayList<>();
Expectation expectation = new Expectation();
expectation.setExpectationId("expectationId1");
+ expectation.setExpectationObject(new ExpectationObject());
List<ExpectationTarget> targetList = new ArrayList<>();
ExpectationTarget target = new ExpectationTarget();