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;
29 import com.fasterxml.jackson.core.JsonProcessingException;
30 import com.fasterxml.jackson.databind.ObjectMapper;
31 import com.oransc.rappmanager.models.cache.RappCacheService;
32 import com.oransc.rappmanager.models.csar.RappCsarConfigurationHandler;
33 import com.oransc.rappmanager.models.rapp.Rapp;
34 import com.oransc.rappmanager.models.rapp.RappState;
35 import com.oransc.rappmanager.models.rappinstance.RappInstance;
36 import com.oransc.rappmanager.models.rappinstance.RappSMEInstance;
37 import com.oransc.rappmanager.models.statemachine.RappInstanceStateMachine;
38 import com.oransc.rappmanager.models.statemachine.RappInstanceStateMachineConfig;
39 import com.oransc.rappmanager.sme.configuration.SmeConfiguration;
40 import com.oransc.rappmanager.sme.invoker.data.APIInvokerEnrolmentDetails;
41 import com.oransc.rappmanager.sme.provider.data.APIProviderEnrolmentDetails;
42 import com.oransc.rappmanager.sme.provider.data.APIProviderFunctionDetails;
43 import com.oransc.rappmanager.sme.provider.data.ApiProviderFuncRole;
44 import com.oransc.rappmanager.sme.publishservice.data.AefProfile;
45 import com.oransc.rappmanager.sme.publishservice.data.ServiceAPIDescription;
46 import java.util.List;
48 import java.util.UUID;
49 import org.junit.jupiter.api.BeforeAll;
50 import org.junit.jupiter.api.BeforeEach;
51 import org.junit.jupiter.api.Test;
52 import org.junit.jupiter.api.TestInstance;
53 import org.springframework.beans.factory.annotation.Autowired;
54 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
55 import org.springframework.boot.test.context.SpringBootTest;
56 import org.springframework.boot.test.mock.mockito.SpyBean;
57 import org.springframework.http.HttpMethod;
58 import org.springframework.http.HttpStatus;
59 import org.springframework.http.MediaType;
60 import org.springframework.test.web.client.ExpectedCount;
61 import org.springframework.test.web.client.MockRestServiceServer;
62 import org.springframework.web.client.RestTemplate;
64 @SpringBootTest(classes = {SmeConfiguration.class, SmeDeployer.class, BeanTestConfiguration.class,
65 RappCsarConfigurationHandler.class, RappCacheService.class, RappInstanceStateMachineConfig.class,
66 RappInstanceStateMachine.class})
67 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
69 class SmeDeployerTest {
71 MockRestServiceServer mockServer;
74 SmeDeployer smeDeployer;
76 RestTemplate restTemplate;
78 SmeConfiguration smeConfiguration;
79 String validCsarFileLocation = "src/test/resources/";
81 RappInstanceStateMachine rappInstanceStateMachine;
83 ObjectMapper objectMapper;
84 private final String validRappFile = "valid-rapp-package.csar";
85 String URI_PROVIDER_REGISTRATIONS, URI_PROVIDER_REGISTRATION, URI_PUBLISH_APIS, URI_PUBLISH_API, URI_INVOKERS,
90 URI_PROVIDER_REGISTRATIONS =
91 smeConfiguration.getBaseUrl() + smeConfiguration.getProviderBasePath() + "registrations";
92 URI_PROVIDER_REGISTRATION =
93 smeConfiguration.getBaseUrl() + smeConfiguration.getProviderBasePath() + "registrations/%s";
94 URI_PUBLISH_APIS = smeConfiguration.getBaseUrl() + smeConfiguration.getPublishApiBasePath() + "%s/service-apis";
96 smeConfiguration.getBaseUrl() + smeConfiguration.getPublishApiBasePath() + "%s/service-apis/%s";
97 URI_INVOKERS = smeConfiguration.getBaseUrl() + smeConfiguration.getInvokerBasePath() + "onboardedInvokers";
98 URI_INVOKER = smeConfiguration.getBaseUrl() + smeConfiguration.getInvokerBasePath() + "onboardedInvokers/%s";
103 mockServer = MockRestServiceServer.createServer(restTemplate);
107 void testCreateAMF() throws JsonProcessingException {
108 String apiProvDomId = UUID.randomUUID().toString();
109 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = new APIProviderEnrolmentDetails(apiProvDomId);
110 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
111 .andExpect(method(HttpMethod.POST)).andRespond(
112 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
113 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
114 APIProviderEnrolmentDetails apiProviderEnrolmentResponse = smeDeployer.createAMF();
116 assertEquals(apiProvDomId, apiProviderEnrolmentResponse.getApiProvDomId());
120 void testCreateAMFFailure() {
121 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
122 .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
123 APIProviderEnrolmentDetails apiProviderEnrolmentResponse = smeDeployer.createAMF();
125 assertNull(apiProviderEnrolmentResponse);
129 void testDeleteAMF() throws JsonProcessingException {
130 String apiProvDomId = UUID.randomUUID().toString();
131 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = new APIProviderEnrolmentDetails(apiProvDomId);
132 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
133 .andExpect(method(HttpMethod.POST)).andRespond(
134 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
135 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
136 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PROVIDER_REGISTRATION, apiProvDomId)))
137 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
138 smeDeployer.createAMF();
139 smeDeployer.deleteAMF();
144 void testCreateProviderDomain() throws Exception {
145 UUID rappId = UUID.randomUUID();
147 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
148 .state(RappState.COMMISSIONED).build();
149 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = getProviderDomainApiEnrollmentDetails();
150 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
151 .andExpect(method(HttpMethod.POST)).andRespond(
152 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
153 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
154 RappInstance rappInstance = getRappInstance();
155 boolean createProviderDomain = smeDeployer.createProviderDomain(rapp, rappInstance);
157 assertTrue(createProviderDomain);
161 void testCreateProviderDomainFailure() throws Exception {
162 UUID rappId = UUID.randomUUID();
164 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
165 .state(RappState.COMMISSIONED).build();
166 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
167 .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
168 RappInstance rappInstance = getRappInstance();
169 boolean createProviderDomain = smeDeployer.createProviderDomain(rapp, rappInstance);
171 assertFalse(createProviderDomain);
175 void testDeleteProviderFunc() {
176 UUID registrationId = UUID.randomUUID();
177 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PROVIDER_REGISTRATION, registrationId)))
178 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
179 smeDeployer.deleteProviderFunc(String.valueOf(registrationId));
184 void testCreatePublishApi() throws Exception {
185 UUID rappId = UUID.randomUUID();
186 UUID apfId = UUID.randomUUID();
188 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
189 .state(RappState.COMMISSIONED).build();
190 ServiceAPIDescription serviceAPIDescription = getServiceApiDescription();
191 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_APIS, apfId)))
192 .andExpect(method(HttpMethod.POST)).andRespond(
193 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
194 .body(objectMapper.writeValueAsString(serviceAPIDescription)));
195 RappInstance rappInstance = getRappInstance();
196 rappInstance.getSme().setApfId(String.valueOf(apfId));
197 boolean publishApi = smeDeployer.createPublishApi(rapp, rappInstance);
199 assertTrue(publishApi);
204 void testCreatePublishApiFailure() throws Exception {
205 UUID rappId = UUID.randomUUID();
206 UUID apfId = UUID.randomUUID();
208 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
209 .state(RappState.COMMISSIONED).build();
210 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_APIS, apfId)))
211 .andExpect(method(HttpMethod.POST)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
212 RappInstance rappInstance = getRappInstance();
213 rappInstance.getSme().setApfId(String.valueOf(apfId));
214 boolean publishApi = smeDeployer.createPublishApi(rapp, rappInstance);
216 assertFalse(publishApi);
220 void testDeletePublishApi() {
221 String serviceApiId = String.valueOf(UUID.randomUUID());
222 String apfId = String.valueOf(UUID.randomUUID());
223 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApiId)))
224 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
225 smeDeployer.deletePublishApi(serviceApiId, apfId);
230 void testCreateInvoker() throws Exception {
231 UUID rappId = UUID.randomUUID();
233 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
234 .state(RappState.COMMISSIONED).build();
235 APIInvokerEnrolmentDetails apiInvokerEnrolmentDetails = getApiInvokerEnrollmentDetails();
236 mockServer.expect(ExpectedCount.once(), requestTo(URI_INVOKERS)).andExpect(method(HttpMethod.POST)).andRespond(
237 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
238 .body(objectMapper.writeValueAsString(apiInvokerEnrolmentDetails)));
239 RappInstance rappInstance = getRappInstance();
240 boolean createInvoker = smeDeployer.createInvoker(rapp, rappInstance);
242 assertTrue(createInvoker);
246 void testCreateInvokerFailure() {
247 UUID rappId = UUID.randomUUID();
249 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
250 .state(RappState.COMMISSIONED).build();
251 mockServer.expect(ExpectedCount.once(), requestTo(URI_INVOKERS)).andExpect(method(HttpMethod.POST))
252 .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
253 RappInstance rappInstance = getRappInstance();
254 boolean createInvoker = smeDeployer.createInvoker(rapp, rappInstance);
256 assertFalse(createInvoker);
260 void testDeleteInvoker() {
261 String invokerId = String.valueOf(UUID.randomUUID());
262 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokerId)))
263 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
264 smeDeployer.deleteInvoker(invokerId);
269 void testDeployRappInstance() throws Exception {
270 UUID rappId = UUID.randomUUID();
271 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = getProviderDomainApiEnrollmentDetails();
272 APIProviderFunctionDetails apfProviderFunctionDetails = apiProviderEnrolmentDetails.getApiProvFuncs().stream()
273 .filter(apiProviderFunctionDetails -> apiProviderFunctionDetails.getApiProvFuncRole()
274 .equals(ApiProviderFuncRole.APF))
277 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
278 .state(RappState.COMMISSIONED).build();
279 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
280 .andExpect(method(HttpMethod.POST)).andRespond(
281 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
282 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
283 ServiceAPIDescription serviceAPIDescription = getServiceApiDescription();
284 mockServer.expect(ExpectedCount.once(),
285 requestTo(String.format(URI_PUBLISH_APIS, apfProviderFunctionDetails.getApiProvFuncId())))
286 .andExpect(method(HttpMethod.POST)).andRespond(
287 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
288 .body(objectMapper.writeValueAsString(serviceAPIDescription)));
289 APIInvokerEnrolmentDetails apiInvokerEnrolmentDetails = getApiInvokerEnrollmentDetails();
290 mockServer.expect(ExpectedCount.once(), requestTo(URI_INVOKERS)).andExpect(method(HttpMethod.POST)).andRespond(
291 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
292 .body(objectMapper.writeValueAsString(apiInvokerEnrolmentDetails)));
293 RappInstance rappInstance = getRappInstance();
294 rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId());
295 boolean deployRapp = smeDeployer.deployRappInstance(rapp, rappInstance);
297 assertTrue(deployRapp);
301 void testDeployRappInstanceWithoutSme() throws Exception {
302 UUID rappId = UUID.randomUUID();
304 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
305 .state(RappState.PRIMED).build();
306 RappInstance rappInstance = getRappInstance();
307 rappInstance.setSme(null);
308 rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId());
309 assertTrue(smeDeployer.deployRappInstance(rapp, rappInstance));
313 void testDeployRappFailure() throws Exception {
314 UUID rappId = UUID.randomUUID();
315 APIProviderEnrolmentDetails apiProviderEnrolmentDetails = getProviderDomainApiEnrollmentDetails();
316 APIProviderFunctionDetails apfProviderFunctionDetails = apiProviderEnrolmentDetails.getApiProvFuncs().stream()
317 .filter(apiProviderFunctionDetails -> apiProviderFunctionDetails.getApiProvFuncRole()
318 .equals(ApiProviderFuncRole.APF))
321 Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
322 .state(RappState.COMMISSIONED).build();
323 mockServer.expect(ExpectedCount.once(), requestTo(URI_PROVIDER_REGISTRATIONS))
324 .andExpect(method(HttpMethod.POST)).andRespond(
325 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
326 .body(objectMapper.writeValueAsString(apiProviderEnrolmentDetails)));
327 ServiceAPIDescription serviceAPIDescription = getServiceApiDescription();
328 mockServer.expect(ExpectedCount.once(),
329 requestTo(String.format(URI_PUBLISH_APIS, apfProviderFunctionDetails.getApiProvFuncId())))
330 .andExpect(method(HttpMethod.POST)).andRespond(
331 withStatus(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON)
332 .body(objectMapper.writeValueAsString(serviceAPIDescription)));
333 mockServer.expect(ExpectedCount.once(), requestTo(URI_INVOKERS)).andExpect(method(HttpMethod.POST))
334 .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
335 RappInstance rappInstance = getRappInstance();
336 rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId());
337 boolean deployRapp = smeDeployer.deployRappInstance(rapp, rappInstance);
339 assertFalse(deployRapp);
343 void testUndeployRappInstance() {
344 UUID rappId = UUID.randomUUID();
345 UUID apfId = UUID.randomUUID();
346 List<String> invokers = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
347 List<String> serviceApis = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
348 Map<String, String> providerFuncs = Map.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()),
349 String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
350 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
351 .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build();
352 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokers.get(0))))
353 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
354 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokers.get(1))))
355 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
356 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApis.get(0))))
357 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
358 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApis.get(1))))
359 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
360 mockServer.expect(ExpectedCount.once(),
361 requestTo(String.format(URI_PROVIDER_REGISTRATION, providerFuncs.values().toArray()[0])))
362 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
363 mockServer.expect(ExpectedCount.once(),
364 requestTo(String.format(URI_PROVIDER_REGISTRATION, providerFuncs.values().toArray()[1])))
365 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
366 RappInstance rappInstance = getRappInstance();
367 rappInstance.getSme().setApfId(String.valueOf(apfId));
368 rappInstance.getSme().setProviderFunctionIds(providerFuncs.values().stream().toList());
369 rappInstance.getSme().setServiceApiIds(serviceApis);
370 rappInstance.getSme().setInvokerIds(invokers);
371 rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId());
372 boolean undeployRapp = smeDeployer.undeployRappInstance(rapp, rappInstance);
374 assertTrue(undeployRapp);
378 void testUndeployRappInstanceWithoutSme() {
379 UUID rappId = UUID.randomUUID();
380 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
381 .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build();
382 RappInstance rappInstance = getRappInstance();
383 rappInstance.setSme(null);
384 assertTrue(smeDeployer.undeployRappInstance(rapp, rappInstance));
388 void testUndeployRappInstanceFailure() {
389 UUID rappId = UUID.randomUUID();
390 UUID apfId = UUID.randomUUID();
391 List<String> invokers = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
392 List<String> serviceApis = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
393 Map<String, String> providerFuncs = Map.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()),
394 String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
395 Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile)
396 .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build();
397 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokers.get(0))))
398 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
399 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_INVOKER, invokers.get(1))))
400 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
401 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApis.get(0))))
402 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
403 mockServer.expect(ExpectedCount.once(), requestTo(String.format(URI_PUBLISH_API, apfId, serviceApis.get(1))))
404 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
405 mockServer.expect(ExpectedCount.once(),
406 requestTo(String.format(URI_PROVIDER_REGISTRATION, providerFuncs.values().toArray()[0])))
407 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.NO_CONTENT));
408 mockServer.expect(ExpectedCount.once(),
409 requestTo(String.format(URI_PROVIDER_REGISTRATION, providerFuncs.values().toArray()[1])))
410 .andExpect(method(HttpMethod.DELETE)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
411 RappInstance rappInstance = getRappInstance();
412 rappInstance.getSme().setApfId(String.valueOf(apfId));
413 rappInstance.getSme().setProviderFunctionIds(providerFuncs.values().stream().toList());
414 rappInstance.getSme().setServiceApiIds(serviceApis);
415 rappInstance.getSme().setInvokerIds(invokers);
416 rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId());
417 boolean undeployRapp = smeDeployer.undeployRappInstance(rapp, rappInstance);
419 assertFalse(undeployRapp);
423 void testPrimingAndDeprimingDoesNothing() {
424 assertTrue(smeDeployer.primeRapp(null));
425 assertTrue(smeDeployer.deprimeRapp(null));
428 RappInstance getRappInstance() {
429 RappSMEInstance rappSMEInstance = new RappSMEInstance();
430 rappSMEInstance.setInvokers("invoker-app1");
431 rappSMEInstance.setServiceApis("api-set-1");
432 rappSMEInstance.setAefId("TEST_AEF_ID");
433 rappSMEInstance.setApfId(String.valueOf(UUID.randomUUID()));
434 rappSMEInstance.setProviderFunction("aef-provider-function");
435 RappInstance rappInstance = new RappInstance();
436 rappInstance.setSme(rappSMEInstance);
440 APIProviderEnrolmentDetails getProviderDomainApiEnrollmentDetails() {
441 APIProviderEnrolmentDetails apiProviderEnrolmentDetails =
442 new APIProviderEnrolmentDetails(UUID.randomUUID().toString());
443 APIProviderFunctionDetails apiProviderFunctionDetailsAEF = new APIProviderFunctionDetails();
444 apiProviderFunctionDetailsAEF.setApiProvFuncInfo("AEF");
445 apiProviderFunctionDetailsAEF.setApiProvFuncRole(ApiProviderFuncRole.AEF);
446 apiProviderFunctionDetailsAEF.setApiProvFuncId(String.valueOf(UUID.randomUUID()));
447 APIProviderFunctionDetails apiProviderFunctionDetailsAPF = new APIProviderFunctionDetails();
448 apiProviderFunctionDetailsAPF.setApiProvFuncInfo("APF");
449 apiProviderFunctionDetailsAPF.setApiProvFuncRole(ApiProviderFuncRole.APF);
450 apiProviderFunctionDetailsAPF.setApiProvFuncId(String.valueOf(UUID.randomUUID()));
451 apiProviderEnrolmentDetails.setApiProvFuncs(
452 List.of(apiProviderFunctionDetailsAEF, apiProviderFunctionDetailsAPF));
453 return apiProviderEnrolmentDetails;
457 ServiceAPIDescription getServiceApiDescription() {
458 ServiceAPIDescription serviceAPIDescription = new ServiceAPIDescription();
459 serviceAPIDescription.setApiId(String.valueOf(UUID.randomUUID()));
460 AefProfile aefProfile = new AefProfile();
461 aefProfile.setAefId(String.valueOf(UUID.randomUUID()));
462 serviceAPIDescription.setAefProfiles(List.of(aefProfile));
463 return serviceAPIDescription;
466 APIInvokerEnrolmentDetails getApiInvokerEnrollmentDetails() {
467 APIInvokerEnrolmentDetails apiInvokerEnrolmentDetails =
468 new APIInvokerEnrolmentDetails(String.valueOf(UUID.randomUUID()));
469 com.oransc.rappmanager.sme.invoker.data.ServiceAPIDescription serviceAPIDescription =
470 new com.oransc.rappmanager.sme.invoker.data.ServiceAPIDescription();
471 serviceAPIDescription.setApiId(String.valueOf(UUID.randomUUID()));
472 apiInvokerEnrolmentDetails.setApiList(List.of(serviceAPIDescription));
473 return apiInvokerEnrolmentDetails;