2 * Copyright (C) 2022 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.
18 package org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule;
20 import org.junit.Assert;
21 import org.junit.Before;
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24 import org.mockito.InjectMocks;
25 import org.mockito.Mock;
26 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
27 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
28 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
29 import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
30 import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
31 import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
32 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
33 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
34 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
35 import org.springframework.boot.test.context.SpringBootTest;
36 import org.springframework.context.ApplicationContext;
37 import org.springframework.test.context.junit4.SpringRunner;
39 import java.util.ArrayList;
40 import java.util.List;
41 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
42 @RunWith(SpringRunner.class)
43 public class FormatIntentInputDecisionModuleTest {
45 FormatIntentInputDecisionModule formatIntentInputDecisionModule;
47 private ApplicationContext applicationContext;
48 IntentGoalBean intentGoalBean = new IntentGoalBean();
49 Intent intent = new Intent();
51 public void before() throws Exception {
52 intent.setIntentName("cllIntent");
53 intent.setIntentId("12345");
54 List<Expectation> expectationList = new ArrayList<>();
56 Expectation delivery = new Expectation();
57 delivery.setExpectationId("12345-delivery");
58 delivery.setExpectationName("deliveryExpectation");
59 delivery.setExpectationType(ExpectationType.DELIVERY);
60 ExpectationObject expectationObject = new ExpectationObject();
61 expectationObject.setObjectType(ObjectType.SLICING);
62 //expetationTarget Context FulfilmentInfo is empty
63 delivery.setExpectationObject(expectationObject);
64 expectationList.add(delivery);
66 Expectation assurance = new Expectation();
67 assurance.setExpectationId("12345-assurance");
68 assurance.setExpectationName("assuranceExpectation");
69 assurance.setExpectationType(ExpectationType.ASSURANCE);
70 ExpectationObject expectationObject1 = new ExpectationObject();
71 expectationObject1.setObjectType(ObjectType.CCVPN);
72 //expetationTarget Context FulfilmentInfo is empty
73 assurance.setExpectationObject(expectationObject1);
74 expectationList.add(assurance);
76 intent.setIntentExpectations(expectationList);
77 intent.setIntentExpectations(expectationList);
78 intent.setIntentExpectations(expectationList);
79 intentGoalBean.setIntent(intent);
80 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
83 public void testExploreIntentHandlers(){
84 IntentManagementFunction intentManagementFunction = formatIntentInputDecisionModule.exploreIntentHandlers(intentGoalBean);
85 Assert.assertTrue(true);
88 public void testFindHandler(){
89 formatIntentInputDecisionModule.investigationCreateProcess(intentGoalBean);
90 Assert.assertTrue(true);
93 public void testUpdateIntentInfo(){
94 Intent originalIntent = new Intent();
96 originalIntent.setIntentName("cllIntent");
97 originalIntent.setIntentId("12345");
98 List<Expectation> expectationList = new ArrayList<>();
100 Expectation delivery = new Expectation();
101 delivery.setExpectationId("12345-delivery");
102 delivery.setExpectationName("deliveryExpectation");
103 delivery.setExpectationType(ExpectationType.DELIVERY);
104 ExpectationObject expectationObject = new ExpectationObject();
105 expectationObject.setObjectType(ObjectType.SLICING);
106 //expetationTarget Context FulfilmentInfo is empty
107 delivery.setExpectationObject(expectationObject);
108 expectationList.add(delivery);
109 originalIntent.setIntentExpectations(expectationList);
111 formatIntentInputDecisionModule.UpdateIntentInfo(originalIntent,intent);
112 Assert.assertTrue(true);