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.cllBusinessIntentMgt;
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.mockito.Mockito;
25 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
26 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
27 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
28 import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
29 import org.onap.usecaseui.intentanalysis.bean.models.*;
30 import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessActuationModule;
31 import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessDecisionModule;
32 import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessKnowledgeModule;
33 import org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.CLLDeliveryIntentManagementFunction;
34 import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputActuationModule;
35 import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputDecisionModule;
36 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
37 import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService;
38 import org.onap.usecaseui.intentanalysis.intentBaseService.intentEventRecord.IntentEventRecordService;
39 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
40 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
41 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
42 import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
43 import org.onap.usecaseui.intentanalysis.service.ContextService;
44 import org.onap.usecaseui.intentanalysis.service.IntentService;
45 import org.springframework.beans.factory.annotation.Autowired;
46 import org.springframework.boot.test.context.SpringBootTest;
47 import org.springframework.context.ApplicationContext;
48 import org.springframework.test.context.junit4.SpringRunner;
50 import java.util.ArrayList;
51 import java.util.LinkedHashMap;
52 import java.util.List;
54 import static org.mockito.ArgumentMatchers.any;
55 import static org.mockito.Mockito.mock;
57 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
58 @RunWith(SpringRunner.class)
59 public class CLLBusinessIntentManagementFunctionTest {
61 CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
62 KnowledgeModule knowledgeModule = mock(CLLBusinessKnowledgeModule.class);
63 DecisionModule decisionModule = mock(CLLBusinessDecisionModule.class);
64 ActuationModule actuationModule = mock(CLLBusinessActuationModule.class);
66 CLLDeliveryIntentManagementFunction cllDeliveryIntentManagementFunction;
68 public IntentContextService intentContextService;
70 IntentInterfaceService intentInterfaceService;
72 ApplicationContext applicationContext;
74 ContextService contextService;
76 IntentService intentService;
78 IntentEventRecordService intentEventRecordService;
80 Intent intent = new Intent();
81 IntentGoalBean intentGoalBean = new IntentGoalBean();
84 public void before() throws Exception {
85 intent.setIntentName("cllIntent");
86 intent.setIntentId("12345");
87 List<Expectation> expectationList = new ArrayList<>();
89 Expectation delivery = new Expectation();
90 delivery.setExpectationId("12345-delivery");
91 delivery.setExpectationName("deliveryExpectation");
92 delivery.setExpectationType(ExpectationType.DELIVERY);
93 ExpectationObject expectationObject = new ExpectationObject();
94 expectationObject.setObjectType(ObjectType.SLICING);
95 //expetationTarget Context FulfilmentInfo is empty
96 delivery.setExpectationObject(expectationObject);
97 expectationList.add(delivery);
99 Expectation assurance = new Expectation();
100 assurance.setExpectationId("12345-assurance");
101 assurance.setExpectationName("assuranceExpectation");
102 assurance.setExpectationType(ExpectationType.ASSURANCE);
103 ExpectationObject expectationObject1 = new ExpectationObject();
104 expectationObject1.setObjectType(ObjectType.CCVPN);
105 //expetationTarget Context FulfilmentInfo is empty
106 assurance.setExpectationObject(expectationObject1);
107 expectationList.add(assurance);
109 intent.setIntentExpectations(expectationList);
110 intentGoalBean.setIntent(intent);
111 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
115 public void testDetection() {
116 cllBusinessIntentManagementFunction.detection(intentGoalBean);
117 Assert.assertTrue(true);
120 public void testInvestigation() {
121 cllBusinessIntentManagementFunction.investigation(intentGoalBean);
122 Assert.assertTrue(true);
125 public void testImplementIntentCreate() { // TODO: 2023/3/30
126 LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
127 map.put(intentGoalBean, cllDeliveryIntentManagementFunction);
128 Mockito.when(decisionModule.intentObjectDefine(any(),any())).thenReturn(intent);
129 cllBusinessIntentManagementFunction.implementIntent(intent, map);
130 Assert.assertTrue(true);
133 public void testImplementIntentUpdate() {
134 LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
135 intentGoalBean.setIntentGoalType(IntentGoalType.UPDATE);
136 map.put(intentGoalBean, cllDeliveryIntentManagementFunction);
137 cllBusinessIntentManagementFunction.implementIntent(intent, map);
138 Assert.assertTrue(true);
142 public void testImplementIntentDelete() {
143 LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
144 intentGoalBean.setIntentGoalType(IntentGoalType.DELETE);
145 map.put(intentGoalBean, cllDeliveryIntentManagementFunction);
146 cllBusinessIntentManagementFunction.implementIntent(intent, map);
147 Assert.assertTrue(true);