cc5830a4626163e5e06ccd1cb65ab4e729302aec
[usecase-ui/intent-analysis.git] /
1 /*
2  * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
19
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;
39
40 import javax.annotation.Resource;
41 import java.util.ArrayList;
42 import java.util.LinkedHashMap;
43 import java.util.List;
44
45 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
46 @RunWith(SpringRunner.class)
47 public class IntentDefinitionServiceTest {
48
49     @InjectMocks
50     IntentDefinitionService intentDefinitionService;
51
52     @Resource(name = "formatIntentInputManagementFunction")
53     private IntentManagementFunction intentOwner;
54     @Resource(name = "CLLBusinessIntentManagementFunction")
55     private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
56     @Mock
57     IntentContextService intentContextService;
58     Intent intent = new Intent();
59
60     @Before
61     public void before() throws Exception {
62
63         intent.setIntentName("cllIntent");
64         intent.setIntentId("12345");
65         List<Expectation> expectationList = new ArrayList<>();
66
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);
76
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);
86
87         intent.setIntentExpectations(expectationList);
88     }
89
90     @Test
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);
98     }
99 }