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.intentBaseService.intentProcessService;
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.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
35 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
36 import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService;
37 import org.springframework.boot.test.context.SpringBootTest;
38 import org.springframework.test.context.junit4.SpringRunner;
40 import javax.annotation.Resource;
41 import java.util.ArrayList;
42 import java.util.LinkedHashMap;
43 import java.util.List;
45 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
46 @RunWith(SpringRunner.class)
47 public class IntentDefinitionServiceTest {
50 IntentDefinitionService intentDefinitionService;
52 @Resource(name = "formatIntentInputManagementFunction")
53 private IntentManagementFunction intentOwner;
54 @Resource(name = "CLLBusinessIntentManagementFunction")
55 private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
57 IntentContextService intentContextService;
58 Intent intent = new Intent();
61 public void before() throws Exception {
63 intent.setIntentName("cllIntent");
64 intent.setIntentId("12345");
65 List<Expectation> expectationList = new ArrayList<>();
67 Expectation delivery = new Expectation();
68 delivery.setExpectationId("12345-delivery");
69 delivery.setExpectationName("deliveryExpectation");
70 delivery.setExpectationType(ExpectationType.DELIVERY);
71 ExpectationObject expectationObject = new ExpectationObject();
72 expectationObject.setObjectType(ObjectType.SLICING);
73 //expetationTarget Context FulfilmentInfo is empty
74 delivery.setExpectationObject(expectationObject);
75 expectationList.add(delivery);
77 Expectation assurance = new Expectation();
78 assurance.setExpectationId("12345-assurance");
79 assurance.setExpectationName("assuranceExpectation");
80 assurance.setExpectationType(ExpectationType.ASSURANCE);
81 ExpectationObject expectationObject1 = new ExpectationObject();
82 expectationObject1.setObjectType(ObjectType.CCVPN);
83 //expetationTarget Context FulfilmentInfo is empty
84 assurance.setExpectationObject(expectationObject1);
85 expectationList.add(assurance);
87 intent.setIntentExpectations(expectationList);
91 public void testDefinitionPorcess() {
92 intentDefinitionService.setIntentRole(intentOwner, cllBusinessIntentManagementFunction);
93 LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
94 IntentGoalBean gb = new IntentGoalBean(intent, IntentGoalType.CREATE);
95 map.put(gb, new IntentManagementFunction());
96 intentDefinitionService.definitionPorcess(intent, map.entrySet().iterator().next());
97 Assert.assertTrue(true);