ce0823ee6674cfac2cc1352a12fb430979c88060
[usecase-ui/intent-analysis.git] /
1 /*
2  * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.clldeliverymodule;
18
19 import org.junit.Assert;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23 import org.mockito.InjectMocks;
24 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
25 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
26 import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
27 import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
28 import org.onap.usecaseui.intentanalysis.bean.models.*;
29 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
30 import org.springframework.boot.test.context.SpringBootTest;
31 import org.springframework.test.context.junit4.SpringRunner;
32
33 import java.util.ArrayList;
34 import java.util.List;
35
36 import static org.junit.jupiter.api.Assertions.*;
37 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
38 @RunWith(SpringRunner.class)
39 public class CLLDeliveryDecisionModuleTest {
40     @InjectMocks
41     CLLDeliveryDecisionModule cllDeliveryDecisionModule;
42
43     Intent intent = new Intent();
44
45     @Before
46     public void before() throws Exception {
47         intent.setIntentName("CLLBusiness intent");
48         intent.setIntentId("testIntentId");
49         List<Expectation> expectationList = new ArrayList<>();
50
51         Expectation delivery = new Expectation();
52         delivery.setExpectationId("12345-delivery");
53         delivery.setExpectationName("clldeliveryExpectation");
54         delivery.setExpectationType(ExpectationType.DELIVERY);
55         ExpectationObject expectationObject = new ExpectationObject();
56         expectationObject.setObjectType(ObjectType.SLICING);
57         //expetationTarget  Context  FulfilmentInfo is empty
58
59         List<ExpectationTarget> expectationTargetList = new ArrayList<>();
60         ExpectationTarget expectationTarget = new ExpectationTarget();
61         expectationTarget.setTargetId("target1-1");
62         expectationTarget.setTargetName("source");
63         List<Condition> targetConditionList= new ArrayList<>();
64         Condition con = new Condition();
65         con.setConditionId("condition1");
66         con.setConditionName("condition of the cll service source");
67         con.setOperator(OperatorType.EQUALTO);
68         con.setConditionValue("true");
69         targetConditionList.add(con);
70
71         expectationTargetList.add(expectationTarget);
72         delivery.setExpectationTargets(expectationTargetList);
73
74         delivery.setExpectationObject(expectationObject);
75         expectationList.add(delivery);
76
77         Expectation assurance = new Expectation();
78         assurance.setExpectationId("12345-assurance");
79         assurance.setExpectationName("assuranceExpectation");
80         assurance.setExpectationType(ExpectationType.ASSURANCE);
81         ExpectationObject expectationObject1 = new ExpectationObject();
82         expectationObject1.setObjectType(ObjectType.CCVPN);
83         //expetationTarget  Context  FulfilmentInfo  is empty
84         assurance.setExpectationObject(expectationObject1);
85         expectationList.add(assurance);
86
87         intent.setIntentExpectations(expectationList);
88
89
90     }
91     @Test
92     public void testIntentDefinition(){
93         cllDeliveryDecisionModule.getNewExpectationList(intent.getIntentExpectations());
94         Assert.assertTrue(true);}
95 }