ea0bf7aec4473c4a798f3000f3b4452482799cd5
[usecase-ui/intent-analysis.git] /
1
2 /*
3  * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18
19 package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
20
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.mockito.InjectMocks;
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.springframework.boot.test.context.SpringBootTest;
37 import org.springframework.test.context.junit4.SpringRunner;
38
39 import javax.annotation.Resource;
40 import java.util.ArrayList;
41 import java.util.List;
42
43 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
44 @RunWith(SpringRunner.class)
45 public class IntentInvestigationServiceTest {
46     @InjectMocks
47     IntentInvestigationService intentInvestigationService;
48
49     @Resource(name = "formatIntentInputManagementFunction")
50     private IntentManagementFunction intentOwner;
51     @Resource(name = "CLLBusinessIntentManagementFunction")
52     private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
53     Intent intent = new Intent();
54     IntentGoalBean intentGoalBean = new IntentGoalBean();
55
56     @Before
57     public void before() throws Exception {
58         intent.setIntentName("cllIntent");
59         intent.setIntentId("12345");
60         List<Expectation> expectationList = new ArrayList<>();
61
62         Expectation delivery = new Expectation();
63         delivery.setExpectationId("12345-delivery");
64         delivery.setExpectationName("deliveryExpectation");
65         delivery.setExpectationType(ExpectationType.DELIVERY);
66         ExpectationObject expectationObject = new ExpectationObject();
67         expectationObject.setObjectType(ObjectType.OBJECT1);
68         //expetationTarget  Context  FulfilmentInfo is empty
69         delivery.setExpectationObject(expectationObject);
70         expectationList.add(delivery);
71
72         Expectation assurance = new Expectation();
73         assurance.setExpectationId("12345-assurance");
74         assurance.setExpectationName("assuranceExpectation");
75         assurance.setExpectationType(ExpectationType.ASSURANCE);
76         ExpectationObject expectationObject1 = new ExpectationObject();
77         expectationObject1.setObjectType(ObjectType.OBJECT2);
78         //expetationTarget  Context  FulfilmentInfo  is empty
79         assurance.setExpectationObject(expectationObject1);
80         expectationList.add(assurance);
81
82         intent.setIntentExpectations(expectationList);
83         intent.setIntentExpectations(expectationList);
84         intentGoalBean.setIntent(intent);
85         intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
86     }
87     @Test
88     public void testDetectionProcess() {
89         intentInvestigationService.setIntentRole(intentOwner, null);
90         intentInvestigationService.investigationProcess(intentGoalBean);
91         Assert.assertTrue(true);
92     }
93 }