3 * Copyright 2025 Deutsche Telekom.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org.onap.usecaseui.server.service.nsmf.impl;
20 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
21 import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
22 import static com.github.tomakehurst.wiremock.client.WireMock.get;
23 import static com.github.tomakehurst.wiremock.client.WireMock.post;
24 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
28 import java.util.Collections;
29 import java.util.List;
31 import org.junit.jupiter.api.Test;
32 import org.onap.usecaseui.server.bean.nsmf.common.ServiceResult;
33 import org.onap.usecaseui.server.bean.nsmf.monitor.ServiceInfo;
34 import org.onap.usecaseui.server.bean.nsmf.monitor.ServiceList;
35 import org.onap.usecaseui.server.bean.nsmf.monitor.ServiceOnlineUserInfo;
36 import org.onap.usecaseui.server.bean.nsmf.monitor.ServiceOnlineUserList;
37 import org.onap.usecaseui.server.config.AAIClientConfig;
38 import org.onap.usecaseui.server.config.SOClientConfig;
39 import org.onap.usecaseui.server.controller.lcm.CustomerController;
40 import org.onap.usecaseui.server.service.lcm.CustomerService;
41 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
42 import org.onap.usecaseui.server.service.lcm.impl.DefaultCustomerService;
43 import org.springframework.beans.factory.annotation.Autowired;
44 import org.springframework.beans.factory.annotation.Value;
45 import org.springframework.boot.test.context.SpringBootTest;
46 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
47 import org.springframework.http.HttpHeaders;
48 import org.wiremock.spring.EnableWireMock;
51 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = {
52 SOClientConfig.class, ResourceMonitorServiceImpl.class, ResourceMonitorServiceConvert.class
54 "spring.main.web-application-type=none", // only temporary
55 "uui-server.client.so.baseUrl=${wiremock.server.baseUrl}",
56 "uui-server.client.so.username=InfraPortalClient",
57 "uui-server.client.so.password=password1",
60 public class ResourceMonitorServiceImplIntegrationTest {
63 ResourceMonitorServiceImpl resourceMonitorService;
65 @Value("${uui-server.client.so.username}")
68 @Value("${uui-server.client.so.password}")
72 void thatKpiRequestsAreCorrect() {
74 post("/api/datalake/v1/exposure/userNumber")
75 .withBasicAuth(username, password)
76 .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
78 aResponse().withBodyFile("kpiUserNumberResponse.json")));
80 String timestamp = "1739307776";
81 ServiceList serviceList = new ServiceList();
82 List<ServiceInfo> serviceInfoList = List.of(new ServiceInfo());
83 serviceList.setServiceInfoList(serviceInfoList);
84 ServiceResult serviceResult = resourceMonitorService.querySlicingOnlineUserNumber(timestamp, serviceList);
85 assertNotNull(serviceResult);
86 List<ServiceOnlineUserInfo> onlineUserInfoList = ((ServiceOnlineUserList) serviceResult.getResult_body()).getServiceOnlineUserInfoList();
87 assertEquals(1, onlineUserInfoList.size());
88 assertEquals("abc", onlineUserInfoList.get(0).getId());