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.formatintentinputMgt.formatintentinputModule;
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.mockito.Mock;
26 import org.mockito.Mockito;
27 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
28 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
29 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
30 import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
31 import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
32 import org.onap.usecaseui.intentanalysis.bean.models.*;
33 import org.onap.usecaseui.intentanalysis.service.IntentService;
34 import org.springframework.boot.test.context.SpringBootTest;
35 import org.springframework.test.context.junit4.SpringRunner;
37 import java.util.ArrayList;
38 import java.util.List;
40 import static org.mockito.ArgumentMatchers.anyString;
42 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
43 @RunWith(SpringRunner.class)
44 public class FormatIntentInputKnowledgeModuleTest {
46 FormatIntentInputKnowledgeModule formatIntentInputKnowledgeModule;
49 IntentService intentService;
50 IntentGoalBean intentGoalBean = new IntentGoalBean();
51 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.OBJECT1);
65 //expetationTarget Context FulfilmentInfo is empty
66 delivery.setExpectationObject(expectationObject);
67 List<ExpectationTarget> expectationTargets = new ArrayList<>();
68 ExpectationTarget expectationTarget = new ExpectationTarget();
69 expectationTarget.setTargetName("aaaa");
70 expectationTargets.add(expectationTarget);
71 delivery.setExpectationTargets(expectationTargets);
72 expectationList.add(delivery);
74 Expectation assurance = new Expectation();
75 assurance.setExpectationId("12345-assurance");
76 assurance.setExpectationName("assuranceExpectation");
77 assurance.setExpectationType(ExpectationType.ASSURANCE);
78 ExpectationObject expectationObject1 = new ExpectationObject();
79 expectationObject1.setObjectType(ObjectType.OBJECT2);
80 //expetationTarget Context FulfilmentInfo is empty
81 assurance.setExpectationObject(expectationObject1);
83 List<ExpectationTarget> expectationTarget2 = new ArrayList<>();
84 ExpectationTarget expectationTargetAssu = new ExpectationTarget();
85 expectationTargetAssu.setTargetName("aaaa");
86 expectationTarget2.add(expectationTargetAssu);
87 assurance.setExpectationTargets(expectationTarget2);
89 expectationList.add(assurance);
91 intent.setIntentExpectations(expectationList);
92 intent.setIntentExpectations(expectationList);
93 intent.setIntentExpectations(expectationList);
95 List<Context> intentContexts = new ArrayList<>();
96 Context context = new Context();
97 context.setContextName("owninfo");
99 List<Condition> conditionList = new ArrayList<>();//ownerName = formatIntentInputManagementFunction"
100 Condition condition = new Condition();
101 condition.setConditionName("ownerName");
102 condition.setOperator(OperatorType.EQUALTO);
103 condition.setConditionValue("formatIntentInputManagementFunction");
104 conditionList.add(condition);
105 context.setContextConditions(conditionList);
106 intentContexts.add(context);
107 intent.setIntentContexts(intentContexts);
109 intentGoalBean.setIntent(intent);
110 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
114 public void testFormatIntentInputKnowledgeModule() {
115 List<Intent> list = new ArrayList<>();
117 Mockito.when(intentService.getIntentByName(anyString())).thenReturn(list);
118 formatIntentInputKnowledgeModule.intentCognition(intent);
119 Assert.assertTrue(true);