0a3cf0407c34d467d622ecfc40d5597686d1d026
[usecase-ui/intent-analysis.git] /
1 package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule;
2
3 import org.junit.Assert;
4 import org.junit.Before;
5 import org.junit.Test;
6 import org.junit.runner.RunWith;
7 import org.mockito.InjectMocks;
8 import org.mockito.Mock;
9 import org.mockito.Mockito;
10 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
11 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
12 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
13 import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
14 import org.onap.usecaseui.intentanalysis.bean.models.*;
15 import org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.CLLAssuranceIntentManagementFunction;
16 import org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.CLLDeliveryIntentManagementFunction;
17 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
18 import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService;
19 import org.springframework.boot.test.context.SpringBootTest;
20 import org.springframework.context.ApplicationContext;
21 import org.springframework.test.context.junit4.SpringRunner;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import static org.junit.jupiter.api.Assertions.*;
27 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
28 @RunWith(SpringRunner.class)
29 public class CLLBusinessDecisionModuleTest {
30     @InjectMocks
31     CLLBusinessDecisionModule cllBusinessDecisionModule;
32
33     @Mock
34     private ImfRegInfoService imfRegInfoService;
35     @Mock
36     private ApplicationContext applicationContext;
37
38     IntentGoalBean intentGoalBean = new IntentGoalBean();
39     Intent intent = new Intent();
40     @Before
41     public void before() throws Exception {
42         intent.setIntentName("cllIntent");
43         intent.setIntentId("12345");
44         List<Expectation> expectationList = new ArrayList<>();
45
46         Expectation delivery = new Expectation();
47         delivery.setExpectationId("12345-delivery");
48         delivery.setExpectationName("deliveryExpectation");
49         delivery.setExpectationType(ExpectationType.DELIVERY);
50         ExpectationObject expectationObject = new ExpectationObject();
51         expectationObject.setObjectType(ObjectType.SLICING);
52         //expetationTarget  Context  FulfilmentInfo is empty
53         delivery.setExpectationObject(expectationObject);
54         expectationList.add(delivery);
55
56         Expectation assurance = new Expectation();
57         assurance.setExpectationId("12345-assurance");
58         assurance.setExpectationName("assuranceExpectation");
59         assurance.setExpectationType(ExpectationType.ASSURANCE);
60         ExpectationObject expectationObject1 = new ExpectationObject();
61         expectationObject1.setObjectType(ObjectType.CCVPN);
62         //expetationTarget  Context  FulfilmentInfo  is empty
63         assurance.setExpectationObject(expectationObject1);
64         expectationList.add(assurance);
65
66         intent.setIntentExpectations(expectationList);
67         intent.setIntentExpectations(expectationList);
68         intent.setIntentExpectations(expectationList);
69         intentGoalBean.setIntent(intent);
70         intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
71     }
72     @Test
73     public void testNeedDecompostion(){
74 //        IntentManagementFunctionRegInfo imfRegInfo = new IntentManagementFunctionRegInfo();
75 //
76 //        imfRegInfo.setSupportArea("cll");
77 //        imfRegInfo.setSupportInterfaces("CREATE");
78 //        imfRegInfo.setHandleName("aaa");
79 //      //  Mockito.when(imfRegInfoService.getImfRegInfo(intentGoalBean)).thenReturn(imfRegInfo).thenReturn(imfRegInfo);
80 //        Mockito.when(cllBusinessDecisionModule.exploreIntentHandlers(intentGoalBean)).thenReturn(new IntentManagementFunction());
81 //        Mockito.when(applicationContext.getBean("CLLDeliveryIntentManagementFunction")).thenReturn(new CLLDeliveryIntentManagementFunction());
82 //        cllBusinessDecisionModule.findHandler(intentGoalBean);
83         cllBusinessDecisionModule.needDecompostion(intentGoalBean);
84         Assert.assertTrue(true);
85     }
86     @Test
87     public void testIntentDecomposition(){
88         cllBusinessDecisionModule.intentDecomposition(intentGoalBean);
89         Assert.assertTrue(true);
90     }
91
92     @Test
93     public void testIntentOrchestration(){
94         List<IntentGoalBean> intentGoalBeanList=new ArrayList<>();
95         IntentGoalBean delivery=new IntentGoalBean();
96
97         Intent deliveryIntent= new Intent();
98         deliveryIntent.setIntentName("delivery");
99
100         delivery.setIntentGoalType(IntentGoalType.CREATE);
101         delivery.setIntent(deliveryIntent);
102         intentGoalBeanList.add(delivery);
103
104         IntentGoalBean assurance=new IntentGoalBean();
105
106         Intent assuranceIntent= new Intent();
107         deliveryIntent.setIntentName("assurance");
108
109         assurance.setIntentGoalType(IntentGoalType.CREATE);
110         assurance.setIntent(assuranceIntent);
111         intentGoalBeanList.add(assurance);
112
113         cllBusinessDecisionModule.intentOrchestration(intentGoalBeanList);
114         Assert.assertTrue(true);
115     }
116 }