1957c637199928d76a9832cf88852c2ac865cd28
[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.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.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
33 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
34 import org.springframework.boot.test.context.SpringBootTest;
35 import org.springframework.test.context.junit4.SpringRunner;
36
37 import javax.annotation.Resource;
38 import java.util.ArrayList;
39 import java.util.List;
40
41 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
42 @RunWith(SpringRunner.class)
43 public class IntentDetectionServiceTest {
44     @InjectMocks
45     IntentDetectionService intentDetectionService;
46     @Resource(name = "formatIntentInputManagementFunction")
47     private IntentManagementFunction intentOwner;
48     @Resource(name = "CLLBusinessIntentManagementFunction")
49     private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
50     Intent intent = new Intent();
51
52     @Before
53     public void before() throws Exception {
54         intent.setIntentName("cllIntent");
55         intent.setIntentId("12345");
56         List<Expectation> expectationList = new ArrayList<>();
57
58         Expectation delivery = new Expectation();
59         delivery.setExpectationId("12345-delivery");
60         delivery.setExpectationName("deliveryExpectation");
61         delivery.setExpectationType(ExpectationType.DELIVERY);
62         ExpectationObject expectationObject = new ExpectationObject();
63         expectationObject.setObjectType(ObjectType.SLICING);
64         //expetationTarget  Context  FulfilmentInfo is empty
65         delivery.setExpectationObject(expectationObject);
66         expectationList.add(delivery);
67
68         Expectation assurance = new Expectation();
69         assurance.setExpectationId("12345-assurance");
70         assurance.setExpectationName("assuranceExpectation");
71         assurance.setExpectationType(ExpectationType.ASSURANCE);
72         ExpectationObject expectationObject1 = new ExpectationObject();
73         expectationObject1.setObjectType(ObjectType.CCVPN);
74         //expetationTarget  Context  FulfilmentInfo  is empty
75         assurance.setExpectationObject(expectationObject1);
76         expectationList.add(assurance);
77
78         intent.setIntentExpectations(expectationList);
79     }
80
81     @Test
82     public void testDetectionProcess() {
83         intentDetectionService.setIntentRole(intentOwner, null);
84         intentDetectionService.detectionProcess(intent);
85         Assert.assertTrue(true);
86
87     }
88 }