64530488e4f12745d60cae92be91db82160c2b89
[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 IntentDistributionServiceTest {
46     @InjectMocks
47     IntentDistributionService IntentDistributionService;
48     @Resource(name = "formatIntentInputManagementFunction")
49     private IntentManagementFunction intentOwner;
50     @Resource(name = "CLLBusinessIntentManagementFunction")
51     private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
52     Intent intent = new Intent();
53     IntentGoalBean intentGoalBean = new IntentGoalBean();
54
55     @Before
56     public void before() throws Exception {
57         intent.setIntentName("cllIntent");
58         intent.setIntentId("12345");
59         List<Expectation> expectationList = new ArrayList<>();
60
61         Expectation delivery = new Expectation();
62         delivery.setExpectationId("12345-delivery");
63         delivery.setExpectationName("deliveryExpectation");
64         delivery.setExpectationType(ExpectationType.DELIVERY);
65         ExpectationObject expectationObject = new ExpectationObject();
66         expectationObject.setObjectType(ObjectType.SLICING);
67         //expetationTarget  Context  FulfilmentInfo is empty
68         delivery.setExpectationObject(expectationObject);
69         expectationList.add(delivery);
70
71         Expectation assurance = new Expectation();
72         assurance.setExpectationId("12345-assurance");
73         assurance.setExpectationName("assuranceExpectation");
74         assurance.setExpectationType(ExpectationType.ASSURANCE);
75         ExpectationObject expectationObject1 = new ExpectationObject();
76         expectationObject1.setObjectType(ObjectType.CCVPN);
77         //expetationTarget  Context  FulfilmentInfo  is empty
78         assurance.setExpectationObject(expectationObject1);
79         expectationList.add(assurance);
80
81         intent.setIntentExpectations(expectationList);
82         intentGoalBean.setIntent(intent);
83         intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
84     }
85     @Test
86     public void testIntentDistribution() {
87         IntentDistributionService.setIntentRole(intentOwner, cllBusinessIntentManagementFunction);
88         LinkedHashMap<IntentGoalBean, IntentManagementFunction> map = new LinkedHashMap<>();
89         map.put(intentGoalBean,cllBusinessIntentManagementFunction);
90         IntentDistributionService.distributionProcess(map.entrySet().iterator().next());
91         Assert.assertTrue(true);
92     }
93 }