3 * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
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;
39 import javax.annotation.Resource;
40 import java.util.ArrayList;
41 import java.util.List;
43 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
44 @RunWith(SpringRunner.class)
45 public class IntentDetectionServiceTest {
47 IntentDetectionService intentDetectionService;
48 @Resource(name = "formatIntentInputManagementFunction")
49 private IntentManagementFunction intentOwner;
50 @Resource(name = "CLLBusinessIntentManagementFunction")
51 private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
52 Intent intent = new Intent();
55 public void before() throws Exception {
56 intent.setIntentName("cllIntent");
57 intent.setIntentId("12345");
58 List<Expectation> expectationList = new ArrayList<>();
60 Expectation delivery = new Expectation();
61 delivery.setExpectationId("12345-delivery");
62 delivery.setExpectationName("deliveryExpectation");
63 delivery.setExpectationType(ExpectationType.DELIVERY);
64 ExpectationObject expectationObject = new ExpectationObject();
65 expectationObject.setObjectType(ObjectType.SLICING);
66 //expetationTarget Context FulfilmentInfo is empty
67 delivery.setExpectationObject(expectationObject);
68 expectationList.add(delivery);
70 Expectation assurance = new Expectation();
71 assurance.setExpectationId("12345-assurance");
72 assurance.setExpectationName("assuranceExpectation");
73 assurance.setExpectationType(ExpectationType.ASSURANCE);
74 ExpectationObject expectationObject1 = new ExpectationObject();
75 expectationObject1.setObjectType(ObjectType.CCVPN);
76 //expetationTarget Context FulfilmentInfo is empty
77 assurance.setExpectationObject(expectationObject1);
78 expectationList.add(assurance);
80 intent.setIntentExpectations(expectationList);
84 public void testDetectionProcess() {
85 intentDetectionService.setIntentRole(intentOwner, null);
86 IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE);
87 intentDetectionService.detectionProcess(intentGoalBean);
88 Assert.assertTrue(true);