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.
17 package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.clldeliverymodule;
19 import org.junit.Assert;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.mockito.InjectMocks;
23 import org.mockito.Mock;
24 import org.mockito.Mockito;
25 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
26 import org.onap.usecaseui.intentanalysis.adapters.so.SOService;
27 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
28 import org.onap.usecaseui.intentanalysis.bean.models.*;
29 import org.onap.usecaseui.intentanalysis.service.ContextService;
30 import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
31 import org.onap.usecaseui.intentanalysis.service.ExpectationService;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.boot.test.context.SpringBootTest;
34 import org.springframework.test.context.junit4.SpringRunner;
36 import java.util.ArrayList;
37 import java.util.List;
39 import static org.mockito.ArgumentMatchers.any;
40 import static org.junit.jupiter.api.Assertions.*;
42 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
43 @RunWith(SpringRunner.class)
44 public class CLLDeliveryActuationModuleTest {
46 CLLDeliveryActuationModule cllDeliveryActuationModulel;
49 private ExpectationService expectationService;
51 private ExpectationObjectService expectationObjectService;
53 private ContextService contextService;
55 private SOService soService;
56 Intent originalIntent = new Intent();
57 IntentGoalBean intentGoalBean = new IntentGoalBean();
60 public void testUpdateIntentOperationInfo() {
61 List<Expectation> expectationList = new ArrayList<>();
62 Expectation exp = new Expectation();
63 ExpectationObject expectationObject = new ExpectationObject();
64 expectationObject.setObjectInstance("objectInstance");
65 exp.setExpectationObject(expectationObject);
66 expectationList.add(exp);
67 originalIntent.setIntentExpectations(expectationList);
69 List<Expectation> gbExpectationList = new ArrayList<>();
70 Expectation deliveryExpectation = new Expectation();
72 ExpectationObject deliveryExpectationObject = new ExpectationObject();
73 deliveryExpectationObject.setObjectInstance("deliveryObjectInstance");
75 deliveryExpectation.setExpectationObject(deliveryExpectationObject);
76 gbExpectationList.add(deliveryExpectation);
77 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
78 Intent intent =new Intent();
79 intent.setIntentName("delivery intent");
80 intent.setIntentExpectations(gbExpectationList);
81 intentGoalBean.setIntent(intent);
83 //Mockito.doNothing().when(类对象).methodName();
84 Mockito.doNothing().when(expectationObjectService).updateExpectationObject(any(), any());
85 Mockito.doNothing().when(contextService).updateContextList(any(), any());
86 cllDeliveryActuationModulel.updateIntentOperationInfo(originalIntent,intentGoalBean);
90 public void testGetInstanceId(){
91 cllDeliveryActuationModulel.getInstanceId();
92 Assert.assertTrue(true);
95 public void testDirectOperation (){
96 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
97 Intent intent = new Intent();
98 List<Expectation> expectationList = new ArrayList<>();
99 Expectation expectation = new Expectation();
100 expectation.setExpectationId("expectationId1");
101 List<ExpectationTarget> targetList = new ArrayList<>();
102 ExpectationTarget target = new ExpectationTarget();
104 List<Condition> conditionList = new ArrayList<>();
105 Condition con = new Condition();
106 con.setConditionName("source");
107 conditionList.add(con);
108 target.setTargetConditions(conditionList);
109 targetList.add(target);
110 expectation.setExpectationTargets(targetList);
111 expectationList.add(expectation);
112 intent.setIntentExpectations(expectationList);
113 intentGoalBean.setIntent(intent);
115 //Mockito.doNothing().when(soService).createIntentInstance(any());
116 Mockito.when(expectationObjectService.getExpectationObject(any())).thenReturn(new ExpectationObject());
117 Mockito.doNothing().when(expectationObjectService).updateExpectationObject(any(),any());
118 cllDeliveryActuationModulel.fulfillIntent(intentGoalBean,null);
119 Assert.assertTrue(true);