6aaeb02ebf26feffe6eb02449b8eb513b48ba74e
[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.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;
37
38 import javax.annotation.Resource;
39 import java.util.ArrayList;
40 import java.util.LinkedHashMap;
41 import java.util.List;
42
43 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
44 @RunWith(SpringRunner.class)
45 public class IntentDefinitionServiceTest {
46
47     @InjectMocks
48     IntentDefinitionService intentDefinitionService;
49
50     @Resource(name = "formatIntentInputManagementFunction")
51     private IntentManagementFunction intentOwner;
52     @Resource(name = "CLLBusinessIntentManagementFunction")
53     private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
54     Intent intent = new Intent();
55
56     @Before
57     public void before() throws Exception {
58
59         intent.setIntentName("cllIntent");
60         intent.setIntentId("12345");
61         List<Expectation> expectationList = new ArrayList<>();
62
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.SLICING);
69         //expetationTarget  Context  FulfilmentInfo is empty
70         delivery.setExpectationObject(expectationObject);
71         expectationList.add(delivery);
72
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.CCVPN);
79         //expetationTarget  Context  FulfilmentInfo  is empty
80         assurance.setExpectationObject(expectationObject1);
81         expectationList.add(assurance);
82
83         intent.setIntentExpectations(expectationList);
84     }
85
86     @Test
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);
94     }
95 }