1 package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
3 import org.junit.Assert;
4 import org.junit.Before;
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;
23 import javax.annotation.Resource;
24 import java.util.ArrayList;
25 import java.util.LinkedHashMap;
26 import java.util.List;
28 import static org.mockito.ArgumentMatchers.any;
29 import static org.mockito.Mockito.when;
31 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
32 @RunWith(SpringRunner.class)
33 public class IntentProcessServiceTest {
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();
43 IntentDetectionService intentDetectionService;
45 IntentInvestigationService intentInvestigationService;
47 IntentDefinitionService intentDefinitionService;
49 IntentDistributionService intentDistributionService;
51 IntentOperationService intentOperationService;
53 IntentService intentService;
57 public void before() throws Exception {
58 intent.setIntentName("cllIntent");
59 intent.setIntentId("12345");
60 List<Expectation> expectationList = new ArrayList<>();
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);
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);
82 intent.setIntentExpectations(expectationList);
83 intentGoalBean.setIntent(intent);
84 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
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);