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.Test;
20 import org.junit.runner.RunWith;
21 import org.mockito.InjectMocks;
22 import org.mockito.Mock;
23 import org.mockito.Mockito;
24 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
25 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
26 import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
27 import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
28 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
29 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
30 import org.onap.usecaseui.intentanalysis.service.ContextService;
31 import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
32 import org.springframework.boot.test.context.SpringBootTest;
33 import org.springframework.test.context.junit4.SpringRunner;
35 import java.util.ArrayList;
36 import java.util.List;
38 import static org.mockito.ArgumentMatchers.any;
39 import static org.junit.jupiter.api.Assertions.*;
41 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
42 @RunWith(SpringRunner.class)
43 public class CLLDeliveryActuationModuleTest {
45 CLLDeliveryActuationModule cllDeliveryActuationModulel;
47 private ExpectationObjectService expectationObjectService;
49 private ContextService contextService;
51 Intent originalIntent = new Intent();
52 IntentGoalBean intentGoalBean = new IntentGoalBean();
55 public void testUpdateIntentOperationInfo() {
56 List<Expectation> expectationList = new ArrayList<>();
57 Expectation exp = new Expectation();
58 ExpectationObject expectationObject = new ExpectationObject();
59 expectationObject.setObjectInstance("objectInstance");
60 exp.setExpectationObject(expectationObject);
61 expectationList.add(exp);
62 originalIntent.setIntentExpectations(expectationList);
64 List<Expectation> gbExpectationList = new ArrayList<>();
65 Expectation deliveryExpectation = new Expectation();
67 ExpectationObject deliveryExpectationObject = new ExpectationObject();
68 deliveryExpectationObject.setObjectInstance("deliveryObjectInstance");
70 deliveryExpectation.setExpectationObject(deliveryExpectationObject);
71 gbExpectationList.add(deliveryExpectation);
72 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
73 Intent intent =new Intent();
74 intent.setIntentName("delivery intent");
75 intent.setIntentExpectations(gbExpectationList);
76 intentGoalBean.setIntent(intent);
78 //Mockito.doNothing().when(类对象).methodName();
79 Mockito.doNothing().when(expectationObjectService).updateExpectationObject(any(), any());
80 Mockito.doNothing().when(contextService).updateContextList(any(), any());
81 cllDeliveryActuationModulel.updateIntentOperationInfo(originalIntent,intentGoalBean);