2 * Copyright (C) 2023 CMCC, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.usecaseui.intentanalysis.formatintentinputMgt;
18 import org.junit.Assert;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.mockito.InjectMocks;
23 import org.mockito.Mock;
24 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
25 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
26 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
27 import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
28 import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
29 import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
30 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
31 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
32 import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
33 import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputActuationModule;
34 import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputDecisionModule;
35 import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputKnowledgeModule;
36 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
37 import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService;
38 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
39 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
40 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
41 import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
42 import org.onap.usecaseui.intentanalysis.service.IntentService;
43 import org.springframework.boot.test.context.SpringBootTest;
44 import org.springframework.context.ApplicationContext;
45 import org.springframework.test.context.junit4.SpringRunner;
47 import java.util.ArrayList;
48 import java.util.LinkedHashMap;
49 import java.util.List;
51 import static org.mockito.Mockito.mock;
53 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
54 @RunWith(SpringRunner.class)
55 public class FormatIntentInputManagementFunctionTest {
57 FormatIntentInputManagementFunction formatIntentInputManagementFunction;
58 KnowledgeModule knowledgeModule = mock(FormatIntentInputKnowledgeModule.class);
59 DecisionModule decisionModule = mock(FormatIntentInputDecisionModule.class);
60 ActuationModule actuationModule = mock(FormatIntentInputActuationModule.class);
62 CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
64 IntentInterfaceService intentInterfaceService;
66 ApplicationContext applicationContext;
68 IntentService intentService;
70 IntentContextService intentContextService;
73 Intent intent = new Intent();
74 IntentGoalBean intentGoalBean = new IntentGoalBean();
77 public void before() throws Exception {
78 intent.setIntentName("cllIntent");
79 intent.setIntentId("12345");
80 List<Expectation> expectationList = new ArrayList<>();
82 Expectation delivery = new Expectation();
83 delivery.setExpectationId("12345-delivery");
84 delivery.setExpectationName("deliveryExpectation");
85 delivery.setExpectationType(ExpectationType.DELIVERY);
86 ExpectationObject expectationObject = new ExpectationObject();
87 expectationObject.setObjectType(ObjectType.SLICING);
88 //expetationTarget Context FulfilmentInfo is empty
89 delivery.setExpectationObject(expectationObject);
90 expectationList.add(delivery);
92 Expectation assurance = new Expectation();
93 assurance.setExpectationId("12345-assurance");
94 assurance.setExpectationName("assuranceExpectation");
95 assurance.setExpectationType(ExpectationType.ASSURANCE);
96 ExpectationObject expectationObject1 = new ExpectationObject();
97 expectationObject1.setObjectType(ObjectType.CCVPN);
98 //expetationTarget Context FulfilmentInfo is empty
99 assurance.setExpectationObject(expectationObject1);
100 expectationList.add(assurance);
102 intent.setIntentExpectations(expectationList);
103 intentGoalBean.setIntent(intent);
104 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
108 public void testDetection() {
109 formatIntentInputManagementFunction.detection(intentGoalBean);
110 Assert.assertTrue(true);
114 public void testInvestigation() {
115 formatIntentInputManagementFunction.investigation(intentGoalBean);
116 Assert.assertTrue(true);
120 public void testImplementIntentCreate() {
121 LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
122 map.put(intentGoalBean, cllBusinessIntentManagementFunction);
123 formatIntentInputManagementFunction.implementIntent(intent, map);
124 Assert.assertTrue(true);
128 public void testImplementIntentUpdate() {
129 LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
130 intentGoalBean.setIntentGoalType(IntentGoalType.UPDATE);
131 map.put(intentGoalBean, cllBusinessIntentManagementFunction);
132 formatIntentInputManagementFunction.implementIntent(intent, map);
133 Assert.assertTrue(true);
137 public void testImplementIntentDelete() {
138 LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
139 intentGoalBean.setIntentGoalType(IntentGoalType.DELETE);
140 map.put(intentGoalBean, cllBusinessIntentManagementFunction);
141 formatIntentInputManagementFunction.implementIntent(intent, map);
142 Assert.assertTrue(true);
146 public void testUpdateIntentInfo() {
147 Intent originalIntent = new Intent();
149 originalIntent.setIntentName("cllIntent");
150 originalIntent.setIntentId("12345");
151 List<Expectation> expectationList = new ArrayList<>();
153 Expectation delivery = new Expectation();
154 delivery.setExpectationId("12345-delivery");
155 delivery.setExpectationName("deliveryExpectation");
156 delivery.setExpectationType(ExpectationType.DELIVERY);
157 ExpectationObject expectationObject = new ExpectationObject();
158 expectationObject.setObjectType(ObjectType.SLICING);
159 //expetationTarget Context FulfilmentInfo is empty
160 delivery.setExpectationObject(expectationObject);
161 expectationList.add(delivery);
162 originalIntent.setIntentExpectations(expectationList);
164 formatIntentInputManagementFunction.updateIntentInfo(originalIntent, intent);
165 Assert.assertTrue(true);