3606eea1c8b20238e619aa766363201dabc7f81b
[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 package org.onap.usecaseui.intentanalysis.service.impl;
17
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.bean.enums.IntentGoalType;
26 import org.onap.usecaseui.intentanalysis.bean.enums.SupportArea;
27 import org.onap.usecaseui.intentanalysis.bean.enums.SupportInterface;
28 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
29 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
30 import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo;
31 import org.onap.usecaseui.intentanalysis.mapper.IMFRegInfoMapper;
32 import org.springframework.boot.test.context.SpringBootTest;
33 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
34
35 import java.util.ArrayList;
36 import java.util.List;
37
38 import static org.mockito.ArgumentMatchers.any;
39
40 @SpringBootTest(classes = ImfRegInfoServiceImplTest.class)
41 @RunWith(SpringJUnit4ClassRunner.class)
42 public class ImfRegInfoServiceImplTest {
43
44     @InjectMocks
45     private ImfRegInfoServiceImpl imfRegInfoServiceImpl;
46
47     @Mock
48     private IMFRegInfoMapper imfRegInfoMapper;
49     Intent intent = new Intent();
50     IntentGoalBean intentGoalBean = new IntentGoalBean();
51
52     @Before
53     public void setUp() {
54         intent.setIntentId("intentid");
55         intent.setIntentName("CLLBusiness");
56         intentGoalBean.setIntent(intent);
57         intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
58     }
59
60     @Test
61     public void itCanInsertIMFRegInfoRegInfo() {
62         Mockito.when(imfRegInfoMapper.insertIMFRegInfoRegInfo(any())).thenReturn(1);
63         imfRegInfoServiceImpl.insertIMFRegInfoRegInfo(new IntentManagementFunctionRegInfo());
64         Assert.assertTrue(true);
65     }
66
67     @Test
68     public void itCanGetImfRegInfoList() {
69         imfRegInfoServiceImpl.getImfRegInfoList();
70     }
71
72     @Test
73     public void itCanGetImfRegInfoListWithIntentGoalBean() {
74         List<IntentManagementFunctionRegInfo> list = new ArrayList<>();
75         IntentManagementFunctionRegInfo info = new IntentManagementFunctionRegInfo();
76         List<SupportArea> areas = new ArrayList<>();
77         areas.add(SupportArea.CLLBUSINESS);
78         info.setSupportArea(areas);
79
80         List<SupportInterface> interList = new ArrayList<>();
81         interList.add(SupportInterface.CREATE);
82         info.setSupportInterfaces(interList);
83
84         list.add(info);
85
86         Mockito.when(imfRegInfoMapper.getImfRegInfoList()).thenReturn(list);
87         imfRegInfoServiceImpl.getImfRegInfo(intentGoalBean);
88         Assert.assertTrue(true);
89     }
90 }