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.Mock;
23 import org.mockito.Mockito;
24 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
25 import org.onap.usecaseui.intentanalysis.adapters.so.SOService;
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.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;
41 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
42 @RunWith(SpringRunner.class)
43 public class CLLDeliveryActuationModuleTest {
45 CLLDeliveryActuationModule cllDeliveryActuationModulel;
48 private ExpectationService expectationService;
50 private ExpectationObjectService expectationObjectService;
52 private ContextService contextService;
54 private SOService soService;
55 Intent originalIntent = new Intent();
56 IntentGoalBean intentGoalBean = new IntentGoalBean();
59 public void testUpdateIntentOperationInfo() {
60 List<Expectation> expectationList = new ArrayList<>();
61 Expectation exp = new Expectation();
62 ExpectationObject expectationObject = new ExpectationObject();
63 expectationObject.setObjectInstance("objectInstance");
64 exp.setExpectationObject(expectationObject);
65 expectationList.add(exp);
66 originalIntent.setIntentExpectations(expectationList);
68 List<Expectation> gbExpectationList = new ArrayList<>();
69 Expectation deliveryExpectation = new Expectation();
71 ExpectationObject deliveryExpectationObject = new ExpectationObject();
72 deliveryExpectationObject.setObjectInstance("deliveryObjectInstance");
74 deliveryExpectation.setExpectationObject(deliveryExpectationObject);
75 deliveryExpectation.setExpectationType(ExpectationType.DELIVERY);
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 expectation.setExpectationObject(new ExpectationObject());
102 List<ExpectationTarget> targetList = new ArrayList<>();
103 ExpectationTarget target = new ExpectationTarget();
105 List<Condition> conditionList = new ArrayList<>();
106 Condition con = new Condition();
107 con.setConditionName("source");
108 conditionList.add(con);
109 target.setTargetConditions(conditionList);
110 targetList.add(target);
111 expectation.setExpectationTargets(targetList);
112 expectationList.add(expectation);
113 intent.setIntentExpectations(expectationList);
114 intentGoalBean.setIntent(intent);
116 //Mockito.doNothing().when(soService).createIntentInstance(any());
117 Mockito.when(expectationObjectService.getExpectationObject(any())).thenReturn(new ExpectationObject());
118 Mockito.doNothing().when(expectationObjectService).updateExpectationObject(any(),any());
119 cllDeliveryActuationModulel.fulfillIntent(intentGoalBean,null);
120 Assert.assertTrue(true);