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.context.properties.EnableConfigurationProperties;
34 import org.springframework.boot.test.context.SpringBootTest;
35 import org.springframework.http.HttpHeaders;
36 import org.wiremock.spring.EnableWireMock;
38 import lombok.SneakyThrows;
41 @EnableConfigurationProperties(SDCClientProperties.class)
44 AAIClientConfig.class, SDCClientConfig.class , DefaultServiceTemplateService.class
47 "client.aai.baseUrl=${wiremock.server.baseUrl}",
48 "client.aai.username=AAI",
49 "client.aai.password=AAI",
50 "uui-server.client.sdc.base-url=${wiremock.server.baseUrl}",
51 "uui-server.client.sdc.username=someUser",
52 "uui-server.client.sdc.password=somePassword",
54 public class DefaultServiceTemplateServiceIntegrationTest {
57 DefaultServiceTemplateService defaultServiceTemplateService;
59 @Value("${uui-server.client.sdc.username}")
62 @Value("${uui-server.client.sdc.password}")
67 void thatSDCCatalogRequestsAreCorrect() {
69 get(urlPathEqualTo("/api/sdc/v1/catalog/services"))
70 .withQueryParam("category", equalTo("E2E Service"))
71 .withQueryParam("distributionStatus", equalTo("DISTRIBUTED"))
72 .withBasicAuth(username, password)
73 .withHeader(HttpHeaders.ACCEPT, equalTo("application/json"))
74 .withHeader("X-ECOMP-InstanceID", equalTo("777"))
76 aResponse().withBodyFile("serviceTemplateResponse.json")
78 List<SDCServiceTemplate> serviceTemplates = defaultServiceTemplateService.listDistributedServiceTemplate();
79 assertNotNull(serviceTemplates);
80 assertEquals(1, serviceTemplates.size());
81 assertEquals("someCategory", serviceTemplates.get(0).getCategory());
82 assertEquals("someInvariantUuid", serviceTemplates.get(0).getInvariantUUID());
83 assertEquals("someName", serviceTemplates.get(0).getName());
84 assertEquals("/foo/bar", serviceTemplates.get(0).getToscaModelURL());
85 assertEquals("someUuid", serviceTemplates.get(0).getUuid());
86 assertEquals("someVersion", serviceTemplates.get(0).getVersion());