2 * Copyright 2025 Deutsche Telekom.
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.
17 package org.onap.usecaseui.server.service.lcm.impl;
19 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
20 import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
21 import static com.github.tomakehurst.wiremock.client.WireMock.get;
22 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
26 import java.util.List;
28 import org.junit.jupiter.api.Test;
29 import org.onap.usecaseui.server.config.AAIClientConfig;
30 import org.onap.usecaseui.server.controller.lcm.CustomerController;
31 import org.onap.usecaseui.server.service.lcm.CustomerService;
32 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.beans.factory.annotation.Value;
35 import org.springframework.boot.test.context.SpringBootTest;
36 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
37 import org.springframework.http.HttpHeaders;
38 import org.wiremock.spring.EnableWireMock;
42 webEnvironment = WebEnvironment.RANDOM_PORT,
44 AAIClientConfig.class, DefaultCustomerService.class, CustomerController.class
47 "spring.main.web-application-type=none", // only temporary
48 "client.aai.baseUrl=${wiremock.server.baseUrl}",
49 "client.aai.username=AAI",
50 "client.aai.password=AAI"
52 public class DefaultCustomerServiceIntegrationTest {
55 CustomerService customerService;
57 @Value("${client.aai.username}")
60 @Value("${client.aai.password}")
64 void thatAAIRequestsAreCorrect() {
66 get("/api/aai-business/v13/customers")
67 .withBasicAuth(username, password)
68 .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
69 .withHeader("X-TransactionId", equalTo("7777"))
70 .withHeader("X-FromAppId", equalTo("uui"))
72 aResponse().withBodyFile("customersResponse.json")
75 List<AAICustomer> customers = customerService.listCustomer();
76 assertNotNull(customers);
77 assertEquals(1, customers.size());
78 assertEquals("someCustomer", customers.get(0).getGlobalCustomerId());
79 assertEquals("someSubscriber", customers.get(0).getSubscriberName());
80 assertEquals("someType", customers.get(0).getSubscriberType());
81 assertEquals("abcd", customers.get(0).getResourceVersion());