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.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.Expectation;
30 import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
31 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
32 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
33 import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
34 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
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 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
44 @RunWith(SpringRunner.class)
45 public class IntentDefinitionServiceTest {
48 IntentDefinitionService intentDefinitionService;
50 @Resource(name = "formatIntentInputManagementFunction")
51 private IntentManagementFunction intentOwner;
52 @Resource(name = "CLLBusinessIntentManagementFunction")
53 private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
54 Intent intent = new Intent();
57 public void before() throws Exception {
59 intent.setIntentName("cllIntent");
60 intent.setIntentId("12345");
61 List<Expectation> expectationList = new ArrayList<>();
63 Expectation delivery = new Expectation();
64 delivery.setExpectationId("12345-delivery");
65 delivery.setExpectationName("deliveryExpectation");
66 delivery.setExpectationType(ExpectationType.DELIVERY);
67 ExpectationObject expectationObject = new ExpectationObject();
68 expectationObject.setObjectType(ObjectType.OBJECT1);
69 //expetationTarget Context FulfilmentInfo is empty
70 delivery.setExpectationObject(expectationObject);
71 expectationList.add(delivery);
73 Expectation assurance = new Expectation();
74 assurance.setExpectationId("12345-assurance");
75 assurance.setExpectationName("assuranceExpectation");
76 assurance.setExpectationType(ExpectationType.ASSURANCE);
77 ExpectationObject expectationObject1 = new ExpectationObject();
78 expectationObject1.setObjectType(ObjectType.OBJECT2);
79 //expetationTarget Context FulfilmentInfo is empty
80 assurance.setExpectationObject(expectationObject1);
81 expectationList.add(assurance);
83 intent.setIntentExpectations(expectationList);
87 public void testDefinitionPorcess() {
88 intentDefinitionService.setIntentRole(intentOwner, cllBusinessIntentManagementFunction);
89 LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
90 IntentGoalBean gb = new IntentGoalBean(intent, IntentGoalType.CREATE);
91 map.put(gb, new IntentManagementFunction());
92 intentDefinitionService.definitionPorcess(map.entrySet().iterator().next());
93 Assert.assertTrue(true);