a2c3dd99c4253163d6411014a219b001d2090100
[usecase-ui/intent-analysis.git] /
1 /*
2  * Copyright (C) 2023 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
17 package org.onap.usecaseui.intentanalysis.service.impl;
18
19 import org.junit.Assert;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests;
23 import org.onap.usecaseui.intentanalysis.bean.models.*;
24 import org.onap.usecaseui.intentanalysis.mapper.ExpectationObjectMapper;
25 import org.onap.usecaseui.intentanalysis.service.IntentReportService;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.boot.test.context.SpringBootTest;
28 import org.springframework.test.context.junit4.SpringRunner;
29
30 import java.util.ArrayList;
31 import java.util.Collections;
32 import java.util.List;
33
34 @SpringBootTest(classes = IntentAnalysisApplicationTests.class)
35 @RunWith(SpringRunner.class)
36 public class IntentReportServiceTest {
37     @Autowired
38     private IntentReportService intentReportService;
39
40     @Autowired
41     ComponentNotificationServiceImpl componentNotificationService;
42
43     @Autowired
44     private ExpectationObjectMapper expectationObjectMapper;
45
46     @Test
47     public void getIntentReportByIntentIdTest() {
48         List<String> allObjectInstances = expectationObjectMapper.getAllObjectInstances();
49         List<String> cll = new ArrayList<>();
50         for (String target : allObjectInstances) {
51             if (target != null && target.contains("cll")) {
52                 cll.add(target);
53             }
54         }
55         FulfillmentOperation fulfillmentOperation = new FulfillmentOperation();
56         fulfillmentOperation.setObjectInstances(Collections.singletonList(cll.get(0)));
57         fulfillmentOperation.setOperation("delivery");
58         componentNotificationService.callBack(fulfillmentOperation);
59         IntentReport report = intentReportService.getIntentReportByIntentId("testIntentId111");
60         Assert.assertNotNull(report);
61     }
62 }