2 * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
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.formatintentinputMgt.FormatIntentInputManagementFunction;
34 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
35 import org.springframework.boot.test.context.SpringBootTest;
36 import org.springframework.test.context.junit4.SpringRunner;
38 import javax.annotation.Resource;
39 import java.util.ArrayList;
40 import java.util.List;
41 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
42 @RunWith(SpringRunner.class)
43 public class IntentOperationServiceTest {
45 IntentOperationService intentOperationService;
47 @Resource(name = "formatIntentInputManagementFunction")
48 private IntentManagementFunction intentOwner;
49 @Resource(name = "formatIntentInputManagementFunction")
50 private FormatIntentInputManagementFunction formatIntentInputManagementFunction;
51 IntentGoalBean intentGoalBean = new IntentGoalBean();
52 Intent intent = new Intent();
54 public void before() throws Exception {
55 intent.setIntentName("cllIntent");
56 intent.setIntentId("12345");
57 List<Expectation> expectationList = new ArrayList<>();
59 Expectation delivery = new Expectation();
60 delivery.setExpectationId("12345-delivery");
61 delivery.setExpectationName("deliveryExpectation");
62 delivery.setExpectationType(ExpectationType.DELIVERY);
63 ExpectationObject expectationObject = new ExpectationObject();
64 expectationObject.setObjectType(ObjectType.SLICING);
65 //expetationTarget Context FulfilmentInfo is empty
66 delivery.setExpectationObject(expectationObject);
67 expectationList.add(delivery);
69 Expectation assurance = new Expectation();
70 assurance.setExpectationId("12345-assurance");
71 assurance.setExpectationName("assuranceExpectation");
72 assurance.setExpectationType(ExpectationType.ASSURANCE);
73 ExpectationObject expectationObject1 = new ExpectationObject();
74 expectationObject1.setObjectType(ObjectType.CCVPN);
75 //expetationTarget Context FulfilmentInfo is empty
76 assurance.setExpectationObject(expectationObject1);
77 expectationList.add(assurance);
79 intent.setIntentExpectations(expectationList);
80 intentGoalBean.setIntent(intent);
81 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
84 public void testIntentOperation() {
85 intentOperationService.setIntentRole(intentOwner, formatIntentInputManagementFunction);
86 IntentGoalBean intentGoalBean = new IntentGoalBean(intent,IntentGoalType.CREATE);
87 intentOperationService.operationProcess(intent, intentGoalBean);
88 Assert.assertTrue(true);