4050ac07bff9766a907988302542f5d2f261d546
[usecase-ui/server.git] /
1 /**
2  * Copyright 2025 Deutsche Telekom.
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.server.service.lcm.impl;
18
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;
25
26 import java.util.List;
27
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;
39
40 @EnableWireMock
41 @SpringBootTest(
42     webEnvironment = WebEnvironment.RANDOM_PORT,
43     classes = {
44         AAIClientConfig.class, DefaultCustomerService.class, CustomerController.class
45     },
46     properties = {
47         "spring.main.web-application-type=none", // only temporary
48         "uui-server.client.aai.baseUrl=${wiremock.server.baseUrl}",
49         "uui-server.client.aai.username=AAI",
50         "uui-server.client.aai.password=AAI"
51     })
52 public class DefaultCustomerServiceIntegrationTest {
53
54     @Autowired
55     CustomerService customerService;
56
57     @Value("${uui-server.client.aai.username}")
58     String username;
59
60     @Value("${uui-server.client.aai.password}")
61     String password;
62
63     @Test
64     void thatAAIRequestsAreCorrect() {
65         stubFor(
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"))
71             .willReturn(
72                 aResponse().withBodyFile("customersResponse.json")
73             ));
74
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());
82     }
83 }