summaryrefslogtreecommitdiffstats
path: root/intentanalysis/src
diff options
context:
space:
mode:
authorhekeguang <hekeguang@chinamobile.com>2022-11-03 18:52:28 +0800
committerhekeguang <hekeguang@chinamobile.com>2022-11-03 18:52:48 +0800
commit08a80f6a60ee9637395afb92d7a5dc1d5ead56c2 (patch)
tree877049c06479b61b69cf38b35b7e84a5a8f126e2 /intentanalysis/src
parent6dce92da99be58aa2af3da3589e179ae1baf6a73 (diff)
Add test code.
Issue-ID: USECASEUI-716 Change-Id: I33e0b24f48a91f325b71442a869dc1cd7055343a Signed-off-by: hekeguang <hekeguang@chinamobile.com>
Diffstat (limited to 'intentanalysis/src')
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java84
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModuleTest.java95
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModuleTest.java22
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextServiceTest.java183
4 files changed, 384 insertions, 0 deletions
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
new file mode 100644
index 0000000..698dd40
--- /dev/null
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModuleTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2022 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.clldeliveryIntentmgt.clldeliverymodule;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
+import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
+import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
+import org.onap.usecaseui.intentanalysis.service.ContextService;
+import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+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)
+public class CLLDeliveryActuationModuleTest {
+ @InjectMocks
+ CLLDeliveryActuationModule cllDeliveryActuationModulel;
+ @Mock
+ private ExpectationObjectService expectationObjectService;
+ @Mock
+ private ContextService contextService;
+
+ Intent originalIntent = new Intent();
+ IntentGoalBean intentGoalBean = new IntentGoalBean();
+
+ @Test
+ public void testUpdateIntentOperationInfo() {
+ List<Expectation> expectationList = new ArrayList<>();
+ Expectation exp = new Expectation();
+ ExpectationObject expectationObject = new ExpectationObject();
+ expectationObject.setObjectInstance("objectInstance");
+ exp.setExpectationObject(expectationObject);
+ expectationList.add(exp);
+ originalIntent.setIntentExpectations(expectationList);
+
+ List<Expectation> gbExpectationList = new ArrayList<>();
+ Expectation deliveryExpectation = new Expectation();
+
+ ExpectationObject deliveryExpectationObject = new ExpectationObject();
+ deliveryExpectationObject.setObjectInstance("deliveryObjectInstance");
+
+ deliveryExpectation.setExpectationObject(deliveryExpectationObject);
+ gbExpectationList.add(deliveryExpectation);
+ intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
+ Intent intent =new Intent();
+ intent.setIntentName("delivery intent");
+ intent.setIntentExpectations(gbExpectationList);
+ intentGoalBean.setIntent(intent);
+
+ //Mockito.doNothing().when(类对象).methodName();
+ Mockito.doNothing().when(expectationObjectService).updateExpectationObject(any(), any());
+ Mockito.doNothing().when(contextService).updateContextList(any(), any());
+ cllDeliveryActuationModulel.updateIntentOperationInfo(originalIntent,intentGoalBean);
+ }
+
+} \ No newline at end of file
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModuleTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModuleTest.java
new file mode 100644
index 0000000..ce0823e
--- /dev/null
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModuleTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2022 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.clldeliveryIntentmgt.clldeliverymodule;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
+import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
+import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
+import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
+import org.onap.usecaseui.intentanalysis.bean.models.*;
+import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+@SpringBootTest(classes = IntentAnalysisApplicationTests.class)
+@RunWith(SpringRunner.class)
+public class CLLDeliveryDecisionModuleTest {
+ @InjectMocks
+ CLLDeliveryDecisionModule cllDeliveryDecisionModule;
+
+ Intent intent = new Intent();
+
+ @Before
+ public void before() throws Exception {
+ intent.setIntentName("CLLBusiness intent");
+ intent.setIntentId("testIntentId");
+ List<Expectation> expectationList = new ArrayList<>();
+
+ Expectation delivery = new Expectation();
+ delivery.setExpectationId("12345-delivery");
+ delivery.setExpectationName("clldeliveryExpectation");
+ delivery.setExpectationType(ExpectationType.DELIVERY);
+ ExpectationObject expectationObject = new ExpectationObject();
+ expectationObject.setObjectType(ObjectType.SLICING);
+ //expetationTarget Context FulfilmentInfo is empty
+
+ List<ExpectationTarget> expectationTargetList = new ArrayList<>();
+ ExpectationTarget expectationTarget = new ExpectationTarget();
+ expectationTarget.setTargetId("target1-1");
+ expectationTarget.setTargetName("source");
+ List<Condition> targetConditionList= new ArrayList<>();
+ Condition con = new Condition();
+ con.setConditionId("condition1");
+ con.setConditionName("condition of the cll service source");
+ con.setOperator(OperatorType.EQUALTO);
+ con.setConditionValue("true");
+ targetConditionList.add(con);
+
+ expectationTargetList.add(expectationTarget);
+ delivery.setExpectationTargets(expectationTargetList);
+
+ delivery.setExpectationObject(expectationObject);
+ expectationList.add(delivery);
+
+ Expectation assurance = new Expectation();
+ assurance.setExpectationId("12345-assurance");
+ assurance.setExpectationName("assuranceExpectation");
+ assurance.setExpectationType(ExpectationType.ASSURANCE);
+ ExpectationObject expectationObject1 = new ExpectationObject();
+ expectationObject1.setObjectType(ObjectType.CCVPN);
+ //expetationTarget Context FulfilmentInfo is empty
+ assurance.setExpectationObject(expectationObject1);
+ expectationList.add(assurance);
+
+ intent.setIntentExpectations(expectationList);
+
+
+ }
+ @Test
+ public void testIntentDefinition(){
+ cllDeliveryDecisionModule.getNewExpectationList(intent.getIntentExpectations());
+ Assert.assertTrue(true);}
+} \ No newline at end of file
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModuleTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModuleTest.java
index 0e74f1e..f2be749 100644
--- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModuleTest.java
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModuleTest.java
@@ -89,4 +89,26 @@ public class FormatIntentInputDecisionModuleTest {
formatIntentInputDecisionModule.investigationCreateProcess(intentGoalBean);
Assert.assertTrue(true);
}
+ @Test
+ public void testUpdateIntentInfo(){
+ Intent originalIntent = new Intent();
+
+ originalIntent.setIntentName("cllIntent");
+ originalIntent.setIntentId("12345");
+ List<Expectation> expectationList = new ArrayList<>();
+
+ Expectation delivery = new Expectation();
+ delivery.setExpectationId("12345-delivery");
+ delivery.setExpectationName("deliveryExpectation");
+ delivery.setExpectationType(ExpectationType.DELIVERY);
+ ExpectationObject expectationObject = new ExpectationObject();
+ expectationObject.setObjectType(ObjectType.SLICING);
+ //expetationTarget Context FulfilmentInfo is empty
+ delivery.setExpectationObject(expectationObject);
+ expectationList.add(delivery);
+ originalIntent.setIntentExpectations(expectationList);
+
+ formatIntentInputDecisionModule.UpdateIntentInfo(originalIntent,intent);
+ Assert.assertTrue(true);
+ }
} \ No newline at end of file
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextServiceTest.java
new file mode 100644
index 0000000..d0bd922
--- /dev/null
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextServiceTest.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2022 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.intentBaseService.contextService;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
+import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
+import org.onap.usecaseui.intentanalysis.bean.models.Condition;
+import org.onap.usecaseui.intentanalysis.bean.models.Context;
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
+import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@SpringBootTest(classes = IntentAnalysisApplicationTests.class)
+@RunWith(SpringRunner.class)
+public class IntentContextServiceTest {
+ @Spy
+ @InjectMocks
+ IntentContextService intentContextService;
+ @Mock
+ private IntentService intentService;
+
+ @Autowired
+ ApplicationContext applicationContext;
+ @Autowired
+ FormatIntentInputManagementFunction formatIntentInputManagementFunction;
+ @Autowired
+ CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
+ Intent originalIntent = new Intent();
+ Intent newIntent = new Intent();
+
+ @Before
+ public void before() throws Exception {
+ originalIntent.setIntentId("testIntentId");
+ originalIntent.setIntentName("testIntent");
+
+ newIntent.setIntentId("newIntentId");
+ newIntent.setIntentName("newIntent");
+ }
+
+ @Test
+ public void testUpdateChindIntentContext() {
+ intentContextService.updateChindIntentContext(originalIntent, newIntent);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void testUpdateParentIntentContext() {
+ intentContextService.updateParentIntentContext(originalIntent, newIntent);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void testUpdateParentIntentContextWithSubintnt() {
+ List<Context> contextList = new ArrayList<>();
+ Context context = new Context();
+ context.setContextId("contentId");
+ context.setContextName("subIntent info");
+
+ Condition con = new Condition();
+ con.setConditionId("conditionId");
+ con.setConditionName("first subIntent Id");
+ con.setOperator(OperatorType.EQUALTO);
+ con.setConditionValue("first subIntent id");
+
+ List<Condition> conditionList = new ArrayList<>();
+ conditionList.add(con);
+ context.setContextConditions(conditionList);
+
+ contextList.add(context);
+ originalIntent.setIntentContexts(contextList);
+ intentContextService.updateParentIntentContext(originalIntent, newIntent);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void testUpdateIntentOwnerHandlerContext() {
+ intentContextService.updateIntentOwnerHandlerContext(newIntent, formatIntentInputManagementFunction, cllBusinessIntentManagementFunction);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void testGetSubIntentInfoFromContext() {
+ List<Context> contextList = new ArrayList<>();
+ Context context = new Context();
+ context.setContextId("contentId");
+ context.setContextName("subIntent info");
+
+ Condition con = new Condition();
+ con.setConditionId("conditionId");
+ con.setConditionName("first subIntent Id");
+ con.setOperator(OperatorType.EQUALTO);
+ con.setConditionValue("first subIntent id");
+
+ List<Condition> conditionList = new ArrayList<>();
+ conditionList.add(con);
+ context.setContextConditions(conditionList);
+
+ contextList.add(context);
+ originalIntent.setIntentContexts(contextList);
+ // originalIntent.setIntentContexts();
+ when(intentService.getIntent(any())).thenReturn(originalIntent).thenReturn(newIntent);
+ intentContextService.getSubIntentInfoFromContext(originalIntent);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void testGetHandlerInfo() {
+ List<Context> contextList = new ArrayList<>();
+ Context context = new Context();
+ context.setContextId("contentId");
+ context.setContextName("subIntent info");
+
+ Condition con = new Condition();
+ con.setConditionId("conditionId");
+ con.setConditionName("first subIntent Id");
+ con.setOperator(OperatorType.EQUALTO);
+ con.setConditionValue("first subIntent id");
+
+ List<Condition> conditionList = new ArrayList<>();
+ conditionList.add(con);
+ context.setContextConditions(conditionList);
+
+ contextList.add(context);
+ originalIntent.setIntentContexts(contextList);
+ intentContextService.getHandlerInfo(originalIntent);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void testDeleteSubIntentContext() {
+ List<Context> contextList = new ArrayList<>();
+ Context context = new Context();
+ context.setContextId("contentId");
+ context.setContextName("subIntent info");
+
+ Condition con = new Condition();
+ con.setConditionId("conditionId");
+ con.setConditionName("first subIntent Id");
+ con.setOperator(OperatorType.EQUALTO);
+ con.setConditionValue("first subIntent id");
+
+ List<Condition> conditionList = new ArrayList<>();
+ conditionList.add(con);
+ context.setContextConditions(conditionList);
+
+ contextList.add(context);
+ originalIntent.setIntentContexts(contextList);
+ intentContextService.deleteSubIntentContext(originalIntent, "first subIntent Id");
+ Assert.assertTrue(true);
+ }
+} \ No newline at end of file