7836793332d01555d15a044b4c3a6e710f9c7940
[usecase-ui/intent-analysis.git] /
1 package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
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.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
10 import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
11 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
12 import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
13 import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
14 import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
15 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
16 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
17 import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
18 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
19 import org.onap.usecaseui.intentanalysis.service.IntentService;
20 import org.springframework.boot.test.context.SpringBootTest;
21 import org.springframework.test.context.junit4.SpringRunner;
22
23 import javax.annotation.Resource;
24 import java.util.ArrayList;
25 import java.util.LinkedHashMap;
26 import java.util.List;
27
28 import static org.mockito.ArgumentMatchers.any;
29 import static org.mockito.Mockito.when;
30
31 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
32 @RunWith(SpringRunner.class)
33 public class IntentProcessServiceTest {
34     @InjectMocks
35     IntentProcessService intentProcessService;
36     @Resource(name = "formatIntentInputManagementFunction")
37     private IntentManagementFunction intentOwner;
38     @Resource(name = "CLLBusinessIntentManagementFunction")
39     private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
40     Intent intent = new Intent();
41     IntentGoalBean intentGoalBean = new IntentGoalBean();
42     @Mock
43     IntentDetectionService intentDetectionService;
44     @Mock
45     IntentInvestigationService intentInvestigationService;
46     @Mock
47     IntentDefinitionService intentDefinitionService;
48     @Mock
49     IntentDistributionService intentDistributionService;
50     @Mock
51     IntentOperationService intentOperationService;
52     @Mock
53     IntentService intentService;
54
55
56     @Before
57     public void before() throws Exception {
58         intent.setIntentName("cllIntent");
59         intent.setIntentId("12345");
60         List<Expectation> expectationList = new ArrayList<>();
61
62         Expectation delivery = new Expectation();
63         delivery.setExpectationId("12345-delivery");
64         delivery.setExpectationName("deliveryExpectation");
65         delivery.setExpectationType(ExpectationType.DELIVERY);
66         ExpectationObject expectationObject = new ExpectationObject();
67         expectationObject.setObjectType(ObjectType.OBJECT1);
68         //expetationTarget  Context  FulfilmentInfo is empty
69         delivery.setExpectationObject(expectationObject);
70         expectationList.add(delivery);
71
72         Expectation assurance = new Expectation();
73         assurance.setExpectationId("12345-assurance");
74         assurance.setExpectationName("assuranceExpectation");
75         assurance.setExpectationType(ExpectationType.ASSURANCE);
76         ExpectationObject expectationObject1 = new ExpectationObject();
77         expectationObject1.setObjectType(ObjectType.OBJECT2);
78         //expetationTarget  Context  FulfilmentInfo  is empty
79         assurance.setExpectationObject(expectationObject1);
80         expectationList.add(assurance);
81
82         intent.setIntentExpectations(expectationList);
83         intentGoalBean.setIntent(intent);
84         intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
85     }
86     @Test
87     public void testIntentProcess() {
88         intentProcessService.setIntentRole(intentOwner,cllBusinessIntentManagementFunction);
89         LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>();
90         intentMap.put(intentGoalBean,cllBusinessIntentManagementFunction);
91         when(intentInvestigationService.investigationProcess(any())).thenReturn(intentMap);
92         intentProcessService.intentProcess(intent);
93         Assert.assertTrue(true);
94     }
95 }