2 * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onap.usecaseui.intentanalysis.service.impl;
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;
35 import java.util.ArrayList;
36 import java.util.List;
38 import static org.mockito.ArgumentMatchers.any;
40 @SpringBootTest(classes = ImfRegInfoServiceImplTest.class)
41 @RunWith(SpringJUnit4ClassRunner.class)
42 public class ImfRegInfoServiceImplTest {
45 private ImfRegInfoServiceImpl imfRegInfoServiceImpl;
48 private IMFRegInfoMapper imfRegInfoMapper;
49 Intent intent = new Intent();
50 IntentGoalBean intentGoalBean = new IntentGoalBean();
54 intent.setIntentId("intentid");
55 intent.setIntentName("CLLBusiness");
56 intentGoalBean.setIntent(intent);
57 intentGoalBean.setIntentGoalType(IntentGoalType.CREATE);
61 public void itCanInsertIMFRegInfoRegInfo() {
62 Mockito.when(imfRegInfoMapper.insertIMFRegInfoRegInfo(any())).thenReturn(1);
63 imfRegInfoServiceImpl.insertIMFRegInfoRegInfo(new IntentManagementFunctionRegInfo());
64 Assert.assertTrue(true);
68 public void itCanGetImfRegInfoList() {
69 imfRegInfoServiceImpl.getImfRegInfoList();
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);
80 List<SupportInterface> interList = new ArrayList<>();
81 interList.add(SupportInterface.CREATE);
82 info.setSupportInterfaces(interList);
86 Mockito.when(imfRegInfoMapper.getImfRegInfoList()).thenReturn(list);
87 imfRegInfoServiceImpl.getImfRegInfo(intentGoalBean);
88 Assert.assertTrue(true);