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.
16 package org.onap.usecaseui.server.service.lcm.impl;
18 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
19 import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
20 import static com.github.tomakehurst.wiremock.client.WireMock.get;
21 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
22 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import java.util.List;
26 import org.junit.jupiter.api.Test;
27 import org.onap.usecaseui.server.config.AAIClientConfig;
28 import org.onap.usecaseui.server.config.SDCClientConfig;
29 import org.onap.usecaseui.server.config.SDCClientProperties;
30 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.beans.factory.annotation.Value;
33 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
34 import org.springframework.boot.context.properties.EnableConfigurationProperties;
35 import org.springframework.boot.test.context.SpringBootTest;
36 import org.springframework.http.HttpHeaders;
37 import org.wiremock.spring.EnableWireMock;
39 import lombok.SneakyThrows;
42 @EnableAutoConfiguration
43 @EnableConfigurationProperties(SDCClientProperties.class)
46 AAIClientConfig.class, SDCClientConfig.class , DefaultServiceTemplateService.class
49 "client.aai.baseUrl=${wiremock.server.baseUrl}",
50 "client.aai.username=AAI",
51 "client.aai.password=AAI",
52 "uui-server.client.sdc.base-url=${wiremock.server.baseUrl}",
53 "uui-server.client.sdc.username=someUser",
54 "uui-server.client.sdc.password=somePassword",
56 public class DefaultServiceTemplateServiceIntegrationTest {
59 DefaultServiceTemplateService defaultServiceTemplateService;
61 @Value("${uui-server.client.sdc.username}")
64 @Value("${uui-server.client.sdc.password}")
69 void thatSDCCatalogRequestsAreCorrect() {
71 get(urlPathEqualTo("/api/sdc/v1/catalog/services"))
72 .withQueryParam("category", equalTo("E2E Service"))
73 .withQueryParam("distributionStatus", equalTo("DISTRIBUTED"))
74 .withBasicAuth(username, password)
75 .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
76 .withHeader("X-ECOMP-InstanceID", equalTo("777"))
78 aResponse().withBodyFile("serviceTemplateResponse.json")
80 List<SDCServiceTemplate> serviceTemplates = defaultServiceTemplateService.listDistributedServiceTemplate();
81 assertNotNull(serviceTemplates);
82 assertEquals(1, serviceTemplates.size());
83 assertEquals("someCategory", serviceTemplates.get(0).getCategory());
84 assertEquals("someInvariantUuid", serviceTemplates.get(0).getInvariantUUID());
85 assertEquals("someName", serviceTemplates.get(0).getName());
86 assertEquals("/foo/bar", serviceTemplates.get(0).getToscaModelURL());
87 assertEquals("someUuid", serviceTemplates.get(0).getUuid());
88 assertEquals("someVersion", serviceTemplates.get(0).getVersion());