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.
16 package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
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.intentBaseService.IntentManagementFunction;
34 import org.onap.usecaseui.intentanalysis.service.IntentService;
35 import org.springframework.boot.test.context.SpringBootTest;
36 import org.springframework.test.context.junit4.SpringRunner;
38 import javax.annotation.Resource;
39 import java.util.ArrayList;
40 import java.util.LinkedHashMap;
41 import java.util.List;
43 import static org.mockito.ArgumentMatchers.any;
44 import static org.mockito.Mockito.when;
46 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
47 @RunWith(SpringRunner.class)
48 public class IntentProcessServiceTest {
50 IntentProcessService intentProcessService;
51 @Resource(name = "formatIntentInputManagementFunction")
52 private IntentManagementFunction intentOwner;
53 @Resource(name = "CLLBusinessIntentManagementFunction")
54 private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
55 Intent intent = new Intent();
56 IntentGoalBean intentGoalBean = new IntentGoalBean();
58 IntentDetectionService intentDetectionService;
60 IntentInvestigationService intentInvestigationService;
62 IntentDefinitionService intentDefinitionService;
64 IntentDistributionService intentDistributionService;
66 IntentOperationService intentOperationService;
68 IntentService intentService;
72 public void before() throws Exception {
73 intent.setIntentName("cllIntent");
74 intent.setIntentId("12345");
75 List<Expectation> expectationList = new ArrayList<>();
77 Expectation delivery = new Expectation();
78 delivery.setExpectationId("12345-delivery");
79 delivery.setExpectationName("deliveryExpectation");
80 delivery.setExpectationType(ExpectationType.DELIVERY);
81 ExpectationObject expectationObject = new ExpectationObject();
82 expectationObject.setObjectType(ObjectType.SLICING);
83 //expetationTarget Context FulfilmentInfo is empty
84 delivery.setExpectationObject(expectationObject);
85 expectationList.add(delivery);
87 Expectation assurance = new Expectation();
88 assurance.setExpectationId("12345-assurance");
89 assurance.setExpectationName("assuranceExpectation");
90 assurance.setExpectationType(ExpectationType.ASSURANCE);
91 ExpectationObject expectationObject1 = new ExpectationObject();
92 expectationObject1.setObjectType(ObjectType.CCVPN);
93 //expetationTarget Context FulfilmentInfo is empty
94 assurance.setExpectationObject(expectationObject1);
95 expectationList.add(assurance);
97 intent.setIntentExpectations(expectationList);
98 intentGoalBean.setIntent(intent);
99 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
102 public void testIntentProcess() {
103 intentProcessService.setIntentRole(intentOwner,cllBusinessIntentManagementFunction);
104 LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>();
105 intentMap.put(intentGoalBean,cllBusinessIntentManagementFunction);
106 when(intentInvestigationService.investigationProcess(any())).thenReturn(intentMap);
107 IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE);
108 intentProcessService.intentProcess(intentGoalBean);
109 Assert.assertTrue(true);