3 * * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
5 * * Licensed under the Apache License, Version 2.0 (the "License");
6 * * you may not use this file except in compliance with the License.
7 * * You may obtain a copy of the License at
9 * * http://www.apache.org/licenses/LICENSE-2.0
11 * * Unless required by applicable law or agreed to in writing, software
12 * * distributed under the License is distributed on an "AS IS" BASIS,
13 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * * See the License for the specific language governing permissions and
15 * * limitations under the License.
19 package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule;
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.mockito.InjectMocks;
26 import org.mockito.Mock;
27 import org.mockito.Mockito;
28 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
29 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
30 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
31 import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
32 import org.onap.usecaseui.intentanalysis.bean.models.*;
33 import org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.CLLAssuranceIntentManagementFunction;
34 import org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.CLLDeliveryIntentManagementFunction;
35 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
36 import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService;
37 import org.springframework.boot.test.context.SpringBootTest;
38 import org.springframework.context.ApplicationContext;
39 import org.springframework.test.context.junit4.SpringRunner;
41 import java.util.ArrayList;
42 import java.util.List;
44 import static org.junit.jupiter.api.Assertions.*;
45 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
46 @RunWith(SpringRunner.class)
47 public class CLLBusinessDecisionModuleTest {
49 CLLBusinessDecisionModule cllBusinessDecisionModule;
52 private ImfRegInfoService imfRegInfoService;
54 private ApplicationContext applicationContext;
56 IntentGoalBean intentGoalBean = new IntentGoalBean();
57 Intent intent = new Intent();
59 public void before() throws Exception {
60 intent.setIntentName("cllIntent");
61 intent.setIntentId("12345");
62 List<Expectation> expectationList = new ArrayList<>();
64 Expectation delivery = new Expectation();
65 delivery.setExpectationId("12345-delivery");
66 delivery.setExpectationName("deliveryExpectation");
67 delivery.setExpectationType(ExpectationType.DELIVERY);
68 ExpectationObject expectationObject = new ExpectationObject();
69 expectationObject.setObjectType(ObjectType.SLICING);
70 //expetationTarget Context FulfilmentInfo is empty
71 delivery.setExpectationObject(expectationObject);
72 expectationList.add(delivery);
74 Expectation assurance = new Expectation();
75 assurance.setExpectationId("12345-assurance");
76 assurance.setExpectationName("assuranceExpectation");
77 assurance.setExpectationType(ExpectationType.ASSURANCE);
78 ExpectationObject expectationObject1 = new ExpectationObject();
79 expectationObject1.setObjectType(ObjectType.CCVPN);
80 //expetationTarget Context FulfilmentInfo is empty
81 assurance.setExpectationObject(expectationObject1);
82 expectationList.add(assurance);
84 intent.setIntentExpectations(expectationList);
85 intent.setIntentExpectations(expectationList);
86 intent.setIntentExpectations(expectationList);
87 intentGoalBean.setIntent(intent);
88 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
91 public void testNeedDecompostion(){
92 // IntentManagementFunctionRegInfo imfRegInfo = new IntentManagementFunctionRegInfo();
94 // imfRegInfo.setSupportArea("cll");
95 // imfRegInfo.setSupportInterfaces("CREATE");
96 // imfRegInfo.setHandleName("aaa");
97 // // Mockito.when(imfRegInfoService.getImfRegInfo(intentGoalBean)).thenReturn(imfRegInfo).thenReturn(imfRegInfo);
98 // Mockito.when(cllBusinessDecisionModule.exploreIntentHandlers(intentGoalBean)).thenReturn(new IntentManagementFunction());
99 // Mockito.when(applicationContext.getBean("CLLDeliveryIntentManagementFunction")).thenReturn(new CLLDeliveryIntentManagementFunction());
100 // cllBusinessDecisionModule.findHandler(intentGoalBean);
101 cllBusinessDecisionModule.needDecompostion(intentGoalBean);
102 Assert.assertTrue(true);
105 public void testIntentDecomposition(){
106 cllBusinessDecisionModule.intentDecomposition(intentGoalBean);
107 Assert.assertTrue(true);
111 public void testIntentOrchestration(){
112 List<IntentGoalBean> intentGoalBeanList=new ArrayList<>();
113 IntentGoalBean delivery=new IntentGoalBean();
115 Intent deliveryIntent= new Intent();
116 deliveryIntent.setIntentName("delivery");
118 delivery.setIntentGoalType(IntentGoalType.CREATE);
119 delivery.setIntent(deliveryIntent);
120 intentGoalBeanList.add(delivery);
122 IntentGoalBean assurance=new IntentGoalBean();
124 Intent assuranceIntent= new Intent();
125 deliveryIntent.setIntentName("assurance");
127 assurance.setIntentGoalType(IntentGoalType.CREATE);
128 assurance.setIntent(assuranceIntent);
129 intentGoalBeanList.add(assurance);
131 cllBusinessDecisionModule.intentOrchestration(intentGoalBeanList);
132 Assert.assertTrue(true);