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.
16 package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule;
18 import org.junit.Assert;
19 import org.junit.Before;
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.policy.PolicyService;
27 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
28 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
29 import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
30 import org.onap.usecaseui.intentanalysis.bean.models.*;
31 import org.onap.usecaseui.intentanalysis.service.ContextService;
32 import org.onap.usecaseui.intentanalysis.service.IntentService;
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.mockito.Mockito.times;
41 import static org.mockito.Mockito.verify;
43 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
44 @RunWith(SpringRunner.class)
45 public class CLLAssuranceActuationModuleTest {
47 CLLAssuranceActuationModule cllAssuranceActuationModule;
49 IntentService intentService;
51 private PolicyService policyService;
53 private ContextService contextService;
54 Intent intent = new Intent();
57 public void before() throws Exception {
58 intent.setIntentName("CLL Delivery Intent");
59 List<Expectation> expectationList = new ArrayList<>();
60 Expectation deliveryExpectation = new Expectation();
61 deliveryExpectation.setExpectationName("CLL Delivery Expectation");
62 deliveryExpectation.setExpectationType(ExpectationType.DELIVERY);
63 ExpectationObject expectationObject = new ExpectationObject();
64 expectationObject.setObjectInstance("");
65 deliveryExpectation.setExpectationObject(expectationObject);
67 List<ExpectationTarget> targetList = new ArrayList<>();
68 ExpectationTarget target1 = new ExpectationTarget();
69 target1.setTargetName("bandwidth");
71 List<Condition> conditionList = new ArrayList<>();
72 Condition con = new Condition();
73 con.setConditionName("condition of the cll service bandwidth");
74 con.setOperator(OperatorType.EQUALTO);
75 con.setConditionValue("1000");
76 conditionList.add(con);
78 target1.setTargetConditions(conditionList);
79 targetList.add(target1);
81 deliveryExpectation.setExpectationTargets(targetList);
83 expectationList.add(deliveryExpectation);
85 Expectation assuranceExceptation = new Expectation();
86 assuranceExceptation.setExpectationType(ExpectationType.ASSURANCE);
87 ExpectationObject expectationObject2 = new ExpectationObject();
88 expectationObject2.setObjectInstance("");
89 assuranceExceptation.setExpectationObject(expectationObject2);
90 expectationList.add(assuranceExceptation);
91 intent.setIntentExpectations(expectationList);
95 public void testDirectOperation(){
96 // Mockito.doNothing().when(policyService).updateIntentConfigPolicy(any(), any(),any());
97 IntentGoalBean intentGoalBean = new IntentGoalBean(intent,IntentGoalType.DELETE);
98 List<Intent> intentList = new ArrayList<>();
99 intentList.add(intent);
101 Mockito.when(intentService.getIntentByName(any())).thenReturn(intentList);
103 cllAssuranceActuationModule.directOperation(intentGoalBean);
104 Assert.assertTrue(true);
107 public void testUpdateIntentOperationInfo(){
108 // updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){
109 Intent originIntent = new Intent();
110 originIntent.setIntentContexts(new ArrayList<>());
111 originIntent.setIntentId("12345");
112 cllAssuranceActuationModule.updateIntentOperationInfo(originIntent,new IntentGoalBean());
113 Assert.assertTrue(true);
116 public void testDeleteIntentToDb(){
117 Intent intent = new Intent();
118 intent.setIntentId("1234");
119 Mockito.when(intentService.getSubIntentList(any())).thenReturn(new ArrayList<>());
120 cllAssuranceActuationModule.deleteIntentToDb(intent);
121 verify(intentService, times(1)).deleteIntent(any());