2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2023 Nordix Foundation. All rights reserved.
4 * ===============================================================================================
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.
16 * ============LICENSE_END========================================================================
19 package com.oransc.rappmanager.sme.service;
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.assertFalse;
23 import static org.junit.jupiter.api.Assertions.assertNull;
24 import static org.junit.jupiter.api.Assertions.assertTrue;
25 import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
26 import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
27 import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
28 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
30 import com.fasterxml.jackson.core.JsonProcessingException;
31 import com.fasterxml.jackson.databind.ObjectMapper;
32 import com.oransc.rappmanager.configuration.RappManagerConfiguration;
33 import com.oransc.rappmanager.models.Rapp;
34 import com.oransc.rappmanager.models.RappState;
35 import com.oransc.rappmanager.models.cache.RappCacheService;
36 import com.oransc.rappmanager.models.statemachine.RappStateMachine;
37 import com.oransc.rappmanager.sme.configuration.SmeConfiguration;
38 import com.oransc.rappmanager.sme.invoker.data.APIInvokerEnrolmentDetails;
39 import com.oransc.rappmanager.sme.provider.data.APIProviderEnrolmentDetails;
40 import com.oransc.rappmanager.sme.provider.data.APIProviderFunctionDetails;
41 import com.oransc.rappmanager.sme.provider.data.ApiProviderFuncRole;
42 import com.oransc.rappmanager.sme.publishservice.data.AefProfile;
43 import com.oransc.rappmanager.sme.publishservice.data.ServiceAPIDescription;
45 import java.io.FileInputStream;
46 import java.util.List;
48 import java.util.UUID;
49 import org.apache.http.entity.ContentType;
50 import org.junit.jupiter.api.BeforeAll;
51 import org.junit.jupiter.api.BeforeEach;
52 import org.junit.jupiter.api.Test;
53 import org.junit.jupiter.api.TestInstance;
54 import org.springframework.beans.factory.annotation.Autowired;
55 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
56 import org.springframework.boot.test.context.SpringBootTest;
57 import org.springframework.boot.test.mock.mockito.SpyBean;
58 import org.springframework.http.HttpMethod;
59 import org.springframework.http.HttpStatus;
60 import org.springframework.http.MediaType;
61 import org.springframework.mock.web.MockMultipartFile;
62 import org.springframework.test.context.TestPropertySource;
63 import org.springframework.test.web.client.ExpectedCount;
64 import org.springframework.test.web.client.MockRestServiceServer;
65 import org.springframework.test.web.servlet.MockMvc;
66 import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
67 import org.springframework.web.client.RestTemplate;
70 @TestPropertySource(properties = "rappmanager.csarlocation=src/test/resources")
71 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
73 public class SmeDeployerTest {
75 MockRestServiceServer mockServer;
77 SmeDeployer smeDeployer;
79 RestTemplate restTemplate;
81 SmeConfiguration smeConfiguration;
83 RappManagerConfiguration rappManagerConfiguration;
85 private MockMvc mockMvc;
87 RappCacheService rappCacheService;
89 RappStateMachine rappStateMachine;
90 private final String validRappFile = "valid-rapp-package.csar";
91 ObjectMapper objectMapper = new ObjectMapper();
92 String URI_PROVIDER_REGISTRATIONS, URI_PROVIDER_REGISTRATION, URI_PUBLISH_APIS, URI_PUBLISH_API, URI_INVOKERS,
97 URI_PROVIDER_REGISTRATIONS =
98 smeConfiguration.getBaseUrl() + smeConfiguration.getProviderBasePath() + "registrations";
99 URI_PROVIDER_REGISTRATION =
100 smeConfiguration.getBaseUrl() + smeConfiguration.getProviderBasePath() + "registrations/%s";
101 URI_PUBLISH_APIS = smeConfiguration.getBaseUrl() + smeConfiguration.getPublishApiBasePath() + "%s/service-apis";
103 smeConfiguration.getBaseUrl() + smeConfiguration.getPublishApiBasePath() + "%s/service-apis/%s";
104 URI_INVOKERS = smeConfiguration.getBaseUrl() + smeConfiguration.getInvokerBasePath() + "onboardedInvokers";
105 URI_INVOKER = smeConfiguration.getBaseUrl() + smeConfiguration.getInvokerBasePath() + "onboardedInvokers/%s";
110 mockServer = MockRestServiceServer.createServer(restTemplate);
114 void testCreateAMF() throws JsonProcessingException {
115 String apiProvDomId = UUID.randomUUID().toString();
116 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = new APIProviderEnrolmentDetails(apiProvDomId);
117 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
118 .andExpect(method(HttpMethod.POST)).andRespond(
119 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
120 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
121 APIProviderEnrolmentDetails apiProviderEnrolmentResponse = smeDeployer.createAMF();
123 assertEquals(apiProvDomId, apiProviderEnrolmentResponse.getApiProvDomId());
127 void testCreateAMFFailure() {
128 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
129 .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
130 APIProviderEnrolmentDetails apiProviderEnrolmentResponse = smeDeployer.createAMF();
132 assertNull(apiProviderEnrolmentResponse);
136 void testDeleteAMF() throws JsonProcessingException {
137 String apiProvDomId = UUID.randomUUID().toString();
138 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = new APIProviderEnrolmentDetails(apiProvDomId);
139 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
140 .andExpect(method(HttpMethod.POST)).andRespond(
141 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
142 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
143 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PROVIDER_REGISTRATION, apiProvDomId)))
144 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
145 smeDeployer.createAMF();
146 smeDeployer.deleteAMF();
151 void testCreateProviderDomain() throws Exception {
152 UUID rappId = UUID.randomUUID();
153 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
154 .packageLocation(rappManagerConfiguration.getCsarLocation()).state(RappState.ONBOARDED)
156 onBoardRappCsar(rappId);
157 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = getProviderDomainApiEnrollmentDetails();
158 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
159 .andExpect(method(HttpMethod.POST)).andRespond(
160 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
161 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
162 boolean createProviderDomain = smeDeployer.createProviderDomain(rapp);
164 assertTrue(createProviderDomain);
168 void testCreateProviderDomainFailure() throws Exception {
169 UUID rappId = UUID.randomUUID();
170 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
171 .packageLocation(rappManagerConfiguration.getCsarLocation()).state(RappState.ONBOARDED)
173 onBoardRappCsar(rappId);
174 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
175 .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
176 boolean createProviderDomain = smeDeployer.createProviderDomain(rapp);
178 assertFalse(createProviderDomain);
182 void testDeleteProviderFunc() {
183 UUID registrationId = UUID.randomUUID();
184 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PROVIDER_REGISTRATION, registrationId)))
185 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
186 smeDeployer.deleteProviderFunc(String.valueOf(registrationId));
191 void testCreatePublishApi() throws Exception {
192 UUID rappId = UUID.randomUUID();
193 UUID apfId = UUID.randomUUID();
194 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
195 .packageLocation(rappManagerConfiguration.getCsarLocation()).state(RappState.ONBOARDED)
196 .smeApfId(String.valueOf(apfId)).build();
197 onBoardRappCsar(rappId);
198 ServiceAPIDescription serviceAPIDescription = getServiceApiDescription();
199 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_APIS, apfId)))
200 .andExpect(method(HttpMethod.POST)).andRespond(
201 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
202 .body(objectMapper.writeValueAsString(serviceAPIDescription)));
203 boolean publishApi = smeDeployer.createPublishApi(rapp);
205 assertTrue(publishApi);
210 void testCreatePublishApiFailure() throws Exception {
211 UUID rappId = UUID.randomUUID();
212 UUID apfId = UUID.randomUUID();
213 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
214 .packageLocation(rappManagerConfiguration.getCsarLocation()).state(RappState.ONBOARDED)
215 .smeApfId(String.valueOf(apfId)).build();
216 onBoardRappCsar(rappId);
217 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_APIS, apfId)))
218 .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
219 boolean publishApi = smeDeployer.createPublishApi(rapp);
221 assertFalse(publishApi);
225 void testDeletePublishApi() {
226 String serviceApiId = String.valueOf(UUID.randomUUID());
227 String apfId = String.valueOf(UUID.randomUUID());
228 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApiId)))
229 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
230 smeDeployer.deletePublishApi(serviceApiId, apfId);
235 void testCreateInvoker() throws Exception {
236 UUID rappId = UUID.randomUUID();
237 UUID apfId = UUID.randomUUID();
238 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
239 .packageLocation(rappManagerConfiguration.getCsarLocation()).state(RappState.ONBOARDED)
240 .smeApfId(String.valueOf(apfId)).build();
241 onBoardRappCsar(rappId);
242 APIInvokerEnrolmentDetails apiInvokerEnrolmentDetails = getApiInvokerEnrollmentDetails();
243 mockServer.expect(ExpectedCount.once(), requestTo(URI_INVOKERS)).andExpect(method(HttpMethod.POST)).andRespond(
244 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
245 .body(objectMapper.writeValueAsString(apiInvokerEnrolmentDetails)));
246 boolean createInvoker = smeDeployer.createInvoker(rapp);
248 assertTrue(createInvoker);
252 void testCreateInvokerFailure() throws Exception {
253 UUID rappId = UUID.randomUUID();
254 UUID apfId = UUID.randomUUID();
255 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
256 .packageLocation(rappManagerConfiguration.getCsarLocation()).state(RappState.ONBOARDED)
257 .smeApfId(String.valueOf(apfId)).build();
258 onBoardRappCsar(rappId);
259 mockServer.expect(ExpectedCount.once(), requestTo(URI_INVOKERS)).andExpect(method(HttpMethod.POST))
260 .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
261 boolean createInvoker = smeDeployer.createInvoker(rapp);
263 assertFalse(createInvoker);
267 void testDeleteInvoker() {
268 String invokerId = String.valueOf(UUID.randomUUID());
269 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokerId)))
270 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
271 smeDeployer.deleteInvoker(invokerId);
276 void testDeployRapp() throws Exception {
277 UUID rappId = UUID.randomUUID();
278 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = getProviderDomainApiEnrollmentDetails();
279 APIProviderFunctionDetails apfProviderFunctionDetails = apiProviderEnrolmentDetails.getApiProvFuncs().stream()
280 .filter(apiProviderFunctionDetails -> apiProviderFunctionDetails.getApiProvFuncRole()
281 .equals(ApiProviderFuncRole.APF))
283 onBoardRappCsar(rappId);
284 Rapp rapp = rappCacheService.getRapp(String.valueOf(rappId)).get();
285 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
286 .andExpect(method(HttpMethod.POST)).andRespond(
287 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
288 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
289 ServiceAPIDescription serviceAPIDescription = getServiceApiDescription();
290 mockServer.expect(ExpectedCount.once(),
291 requestTo(String.format(URI_PUBLISH_APIS, apfProviderFunctionDetails.getApiProvFuncId())))
292 .andExpect(method(HttpMethod.POST)).andRespond(
293 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
294 .body(objectMapper.writeValueAsString(serviceAPIDescription)));
295 APIInvokerEnrolmentDetails apiInvokerEnrolmentDetails = getApiInvokerEnrollmentDetails();
296 mockServer.expect(ExpectedCount.once(), requestTo(URI_INVOKERS)).andExpect(method(HttpMethod.POST)).andRespond(
297 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
298 .body(objectMapper.writeValueAsString(apiInvokerEnrolmentDetails)));
299 boolean deployRapp = smeDeployer.deployRapp(rapp);
301 assertTrue(deployRapp);
305 void testDeployRappFailure() throws Exception {
306 UUID rappId = UUID.randomUUID();
307 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = getProviderDomainApiEnrollmentDetails();
308 APIProviderFunctionDetails apfProviderFunctionDetails = apiProviderEnrolmentDetails.getApiProvFuncs().stream()
309 .filter(apiProviderFunctionDetails -> apiProviderFunctionDetails.getApiProvFuncRole()
310 .equals(ApiProviderFuncRole.APF))
312 onBoardRappCsar(rappId);
313 Rapp rapp = rappCacheService.getRapp(String.valueOf(rappId)).get();
314 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
315 .andExpect(method(HttpMethod.POST)).andRespond(
316 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
317 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
318 ServiceAPIDescription serviceAPIDescription = getServiceApiDescription();
319 mockServer.expect(ExpectedCount.once(),
320 requestTo(String.format(URI_PUBLISH_APIS, apfProviderFunctionDetails.getApiProvFuncId())))
321 .andExpect(method(HttpMethod.POST)).andRespond(
322 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
323 .body(objectMapper.writeValueAsString(serviceAPIDescription)));
324 mockServer.expect(ExpectedCount.once(), requestTo(URI_INVOKERS)).andExpect(method(HttpMethod.POST))
325 .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
326 boolean deployRapp = smeDeployer.deployRapp(rapp);
328 assertFalse(deployRapp);
332 void testUndeployRapp() throws Exception {
333 UUID rappId = UUID.randomUUID();
334 UUID apfId = UUID.randomUUID();
335 List<String> invokers = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
336 List<String> serviceApis = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
337 Map<String, String> providerFuncs = Map.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()),
338 String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
339 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
340 .packageLocation(rappManagerConfiguration.getCsarLocation()).state(RappState.ONBOARDED)
341 .smeApfId(String.valueOf(apfId)).smeInvokers(invokers).smeServiceApis(serviceApis)
342 .smeProviderFunctions(providerFuncs).build();
343 onBoardRappCsar(rappId);
344 rapp.setRappId(rappCacheService.getRapp(String.valueOf(rappId)).get().getRappId());
345 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokers.get(0))))
346 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
347 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokers.get(1))))
348 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
349 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApis.get(0))))
350 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
351 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApis.get(1))))
352 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
353 mockServer.expect(ExpectedCount.once(),
354 requestTo(String.format(URI_PROVIDER_REGISTRATION, providerFuncs.values().toArray()[0])))
355 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
356 mockServer.expect(ExpectedCount.once(),
357 requestTo(String.format(URI_PROVIDER_REGISTRATION, providerFuncs.values().toArray()[1])))
358 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
360 boolean undeployRapp = smeDeployer.undeployRapp(rapp);
362 assertTrue(undeployRapp);
366 void testUndeployRappFailure() throws Exception {
367 UUID rappId = UUID.randomUUID();
368 UUID apfId = UUID.randomUUID();
369 List<String> invokers = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
370 List<String> serviceApis = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
371 Map<String, String> providerFuncs = Map.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()),
372 String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
373 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
374 .packageLocation(rappManagerConfiguration.getCsarLocation()).state(RappState.ONBOARDED)
375 .smeApfId(String.valueOf(apfId)).smeInvokers(invokers).smeServiceApis(serviceApis)
376 .smeProviderFunctions(providerFuncs).build();
377 onBoardRappCsar(rappId);
378 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokers.get(0))))
379 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
380 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokers.get(1))))
381 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
382 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApis.get(0))))
383 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
384 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApis.get(1))))
385 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
386 mockServer.expect(ExpectedCount.once(),
387 requestTo(String.format(URI_PROVIDER_REGISTRATION, providerFuncs.values().toArray()[0])))
388 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
389 mockServer.expect(ExpectedCount.once(),
390 requestTo(String.format(URI_PROVIDER_REGISTRATION, providerFuncs.values().toArray()[1])))
391 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
393 boolean undeployRapp = smeDeployer.undeployRapp(rapp);
395 assertFalse(undeployRapp);
398 APIProviderEnrolmentDetails getProviderDomainApiEnrollmentDetails() {
399 APIProviderEnrolmentDetails apiProviderEnrolmentDetails =
400 new APIProviderEnrolmentDetails(UUID.randomUUID().toString());
401 APIProviderFunctionDetails apiProviderFunctionDetailsAEF = new APIProviderFunctionDetails();
402 apiProviderFunctionDetailsAEF.setApiProvFuncInfo("AEF");
403 apiProviderFunctionDetailsAEF.setApiProvFuncRole(ApiProviderFuncRole.AEF);
404 apiProviderFunctionDetailsAEF.setApiProvFuncId(String.valueOf(UUID.randomUUID()));
405 APIProviderFunctionDetails apiProviderFunctionDetailsAPF = new APIProviderFunctionDetails();
406 apiProviderFunctionDetailsAPF.setApiProvFuncInfo("APF");
407 apiProviderFunctionDetailsAPF.setApiProvFuncRole(ApiProviderFuncRole.APF);
408 apiProviderFunctionDetailsAPF.setApiProvFuncId(String.valueOf(UUID.randomUUID()));
409 apiProviderEnrolmentDetails.setApiProvFuncs(
410 List.of(apiProviderFunctionDetailsAEF, apiProviderFunctionDetailsAPF));
411 return apiProviderEnrolmentDetails;
415 ServiceAPIDescription getServiceApiDescription() {
416 ServiceAPIDescription serviceAPIDescription = new ServiceAPIDescription();
417 AefProfile aefProfile = new AefProfile();
418 aefProfile.setAefId(String.valueOf(UUID.randomUUID()));
419 serviceAPIDescription.setAefProfiles(List.of(aefProfile));
420 return serviceAPIDescription;
423 APIInvokerEnrolmentDetails getApiInvokerEnrollmentDetails() {
424 APIInvokerEnrolmentDetails apiInvokerEnrolmentDetails = new APIInvokerEnrolmentDetails();
425 com.oransc.rappmanager.sme.invoker.data.ServiceAPIDescription serviceAPIDescription =
426 new com.oransc.rappmanager.sme.invoker.data.ServiceAPIDescription();
427 serviceAPIDescription.setApiId(String.valueOf(UUID.randomUUID()));
428 apiInvokerEnrolmentDetails.setApiList(List.of(serviceAPIDescription));
429 return apiInvokerEnrolmentDetails;
432 void onBoardRappCsar(UUID rappId) throws Exception {
433 String rappCsarPath = rappManagerConfiguration.getCsarLocation() + File.separator + validRappFile;
434 MockMultipartFile multipartFile =
435 new MockMultipartFile("file", validRappFile, ContentType.MULTIPART_FORM_DATA.getMimeType(),
436 new FileInputStream(rappCsarPath));
437 mockMvc.perform(MockMvcRequestBuilders.multipart("/rapps/{rapp_id}/onboard", rappId).file(multipartFile))
438 .andExpect(status().isAccepted());