2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 Nordix Foundation
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
21 package org.oransc.policyagent;
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.awaitility.Awaitility.await;
25 import static org.junit.jupiter.api.Assertions.assertEquals;
26 import static org.junit.jupiter.api.Assertions.assertTrue;
27 import static org.mockito.ArgumentMatchers.any;
28 import static org.mockito.Mockito.doReturn;
30 import com.google.gson.Gson;
31 import com.google.gson.GsonBuilder;
32 import com.google.gson.JsonArray;
33 import com.google.gson.JsonElement;
34 import com.google.gson.JsonParser;
36 import java.nio.charset.StandardCharsets;
37 import java.time.Duration;
38 import java.time.Instant;
39 import java.util.ArrayList;
40 import java.util.List;
42 import org.junit.jupiter.api.AfterEach;
43 import org.junit.jupiter.api.BeforeEach;
44 import org.junit.jupiter.api.Test;
45 import org.junit.jupiter.api.extension.ExtendWith;
46 import org.oransc.policyagent.clients.AsyncRestClient;
47 import org.oransc.policyagent.configuration.ApplicationConfig;
48 import org.oransc.policyagent.configuration.ImmutableRicConfig;
49 import org.oransc.policyagent.configuration.RicConfig;
50 import org.oransc.policyagent.controllers.PolicyInfo;
51 import org.oransc.policyagent.controllers.ServiceRegistrationInfo;
52 import org.oransc.policyagent.controllers.ServiceStatus;
53 import org.oransc.policyagent.exceptions.ServiceException;
54 import org.oransc.policyagent.repository.ImmutablePolicy;
55 import org.oransc.policyagent.repository.ImmutablePolicyType;
56 import org.oransc.policyagent.repository.Lock.LockType;
57 import org.oransc.policyagent.repository.Policies;
58 import org.oransc.policyagent.repository.Policy;
59 import org.oransc.policyagent.repository.PolicyType;
60 import org.oransc.policyagent.repository.PolicyTypes;
61 import org.oransc.policyagent.repository.Ric;
62 import org.oransc.policyagent.repository.Ric.RicState;
63 import org.oransc.policyagent.repository.Rics;
64 import org.oransc.policyagent.repository.Services;
65 import org.oransc.policyagent.tasks.RicSupervision;
66 import org.oransc.policyagent.tasks.ServiceSupervision;
67 import org.oransc.policyagent.utils.MockA1Client;
68 import org.oransc.policyagent.utils.MockA1ClientFactory;
69 import org.slf4j.Logger;
70 import org.slf4j.LoggerFactory;
71 import org.springframework.beans.factory.annotation.Autowired;
72 import org.springframework.boot.test.context.SpringBootTest;
73 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
74 import org.springframework.boot.test.context.TestConfiguration;
75 import org.springframework.boot.web.server.LocalServerPort;
76 import org.springframework.context.ApplicationContext;
77 import org.springframework.context.annotation.Bean;
78 import org.springframework.http.HttpStatus;
79 import org.springframework.http.ResponseEntity;
80 import org.springframework.test.context.junit.jupiter.SpringExtension;
81 import org.springframework.web.reactive.function.client.WebClientResponseException;
83 import reactor.core.publisher.Mono;
84 import reactor.test.StepVerifier;
85 import reactor.util.annotation.Nullable;
87 @ExtendWith(SpringExtension.class)
88 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
89 public class ApplicationTest {
90 private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
93 ApplicationContext context;
99 private Policies policies;
102 private PolicyTypes policyTypes;
105 MockA1ClientFactory a1ClientFactory;
108 RicSupervision supervision;
113 private static Gson gson = new GsonBuilder() //
117 public static class MockApplicationConfig extends ApplicationConfig {
119 public String getLocalConfigurationFilePath() {
120 return ""; // No config file loaded for the test
125 * Overrides the BeanFactory.
128 static class TestBeanFactory {
129 private final PolicyTypes policyTypes = new PolicyTypes();
130 private final Services services = new Services();
131 private final Policies policies = new Policies();
132 MockA1ClientFactory a1ClientFactory = null;
135 public ApplicationConfig getApplicationConfig() {
136 return new MockApplicationConfig();
140 MockA1ClientFactory getA1ClientFactory() {
141 if (a1ClientFactory == null) {
142 this.a1ClientFactory = new MockA1ClientFactory(this.policyTypes);
144 return this.a1ClientFactory;
148 public PolicyTypes getPolicyTypes() {
149 return this.policyTypes;
153 Policies getPolicies() {
154 return this.policies;
158 Services getServices() {
159 return this.services;
163 public ServiceSupervision getServiceSupervision() {
164 Duration checkInterval = Duration.ofMillis(1);
165 return new ServiceSupervision(this.services, this.policies, this.getA1ClientFactory(), checkInterval);
173 public void reset() {
178 a1ClientFactory.reset();
182 public void verifyNoRicLocks() {
183 for (Ric ric : this.rics.getRics()) {
184 ric.getLock().lockBlocking(LockType.EXCLUSIVE);
185 ric.getLock().unlockBlocking();
186 assertThat(ric.getLock().getLockCounter()).isEqualTo(0);
187 assertThat(ric.getState()).isEqualTo(Ric.RicState.IDLE);
192 public void testGetRics() throws Exception {
194 this.addPolicyType("type1", "ric1");
195 String url = "/rics?policyType=type1";
196 String rsp = restClient().get(url).block();
197 assertThat(rsp).contains("ric1");
199 // nameless type for ORAN A1 1.1
201 this.addPolicyType("", "ric2");
202 url = "/rics?policyType=";
203 rsp = restClient().get(url).block();
204 assertThat(rsp).contains("ric2");
205 assertThat(rsp).doesNotContain("ric1");
207 // Non existing policy type
208 url = "/rics?policyType=XXXX";
209 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
213 public void testSynchronization() throws Exception {
214 addRic("ric").setState(Ric.RicState.UNDEFINED);
215 String ricName = "ric";
216 Policy policy2 = addPolicy("policyId2", "typeName", "service", ricName);
218 getA1Client(ricName).putPolicy(policy2); // put it in the RIC
219 policies.remove(policy2); // Remove it from the repo -> should be deleted in the RIC
221 String policyId = "policyId";
222 Policy policy = addPolicy(policyId, "typeName", "service", ricName); // This should be created in the RIC
223 supervision.checkAllRics(); // The created policy should be put in the RIC
224 await().untilAsserted(() -> RicState.SYNCHRONIZING.equals(rics.getRic(ricName).getState()));
225 await().untilAsserted(() -> RicState.IDLE.equals(rics.getRic(ricName).getState()));
227 Policies ricPolicies = getA1Client(ricName).getPolicies();
228 assertThat(ricPolicies.size()).isEqualTo(1);
229 Policy ricPolicy = ricPolicies.get(policyId);
230 assertThat(ricPolicy.json()).isEqualTo(policy.json());
234 public void testGetRicForManagedElement_thenReturnCorrectRic() throws Exception {
235 String ricName = "ric1";
236 String managedElementId = "kista_1";
237 addRic(ricName, managedElementId);
239 String url = "/ric?managedElementId=" + managedElementId;
240 String rsp = restClient().get(url).block();
241 assertThat(rsp).isEqualTo(ricName);
243 // test GET RIC for ManagedElement that does not exist
244 url = "/ric?managedElementId=" + "junk";
245 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
248 private String putPolicyUrl(String serviceName, String ricName, String policyTypeName, String policyInstanceId) {
249 if (policyTypeName.isEmpty()) {
250 return "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName;
252 return "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName + "&type="
258 public void testPutPolicy() throws Exception {
259 String serviceName = "service1";
260 String ricName = "ric1";
261 String policyTypeName = "type1";
262 String policyInstanceId = "instance1";
264 putService(serviceName);
265 addPolicyType(policyTypeName, ricName);
267 String url = putPolicyUrl(serviceName, ricName, policyTypeName, policyInstanceId);
268 final String policyBody = jsonString();
269 this.rics.getRic(ricName).setState(Ric.RicState.IDLE);
271 restClient().put(url, policyBody).block();
273 Policy policy = policies.getPolicy(policyInstanceId);
274 assertThat(policy).isNotNull();
275 assertThat(policy.id()).isEqualTo(policyInstanceId);
276 assertThat(policy.ownerServiceName()).isEqualTo(serviceName);
277 assertThat(policy.ric().name()).isEqualTo("ric1");
280 String rsp = restClient().get(url).block();
281 assertThat(rsp.contains(policyInstanceId)).isTrue();
283 // Test of error codes
284 url = putPolicyUrl(serviceName, ricName + "XX", policyTypeName, policyInstanceId);
285 testErrorCode(restClient().put(url, policyBody), HttpStatus.NOT_FOUND);
287 url = putPolicyUrl(serviceName, ricName, policyTypeName + "XX", policyInstanceId);
288 testErrorCode(restClient().put(url, policyBody), HttpStatus.NOT_FOUND);
290 url = putPolicyUrl(serviceName, ricName, policyTypeName, policyInstanceId);
291 this.rics.getRic(ricName).setState(Ric.RicState.SYNCHRONIZING);
292 testErrorCode(restClient().put(url, policyBody), HttpStatus.LOCKED);
293 this.rics.getRic(ricName).setState(Ric.RicState.IDLE);
298 * Test that HttpStatus and body from failing REST call to A1 is passed on to
301 * @throws ServiceException
303 public void testErrorFromRIC() throws ServiceException {
304 putService("service1");
305 addPolicyType("type1", "ric1");
307 String url = putPolicyUrl("service1", "ric1", "type1", "id1");
308 MockA1Client a1Client = a1ClientFactory.getOrCreateA1Client("ric1");
309 HttpStatus httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
310 String responseBody = "Refused";
311 byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8);
313 WebClientResponseException a1Exception = new WebClientResponseException(httpStatus.value(), "statusText", null,
314 responseBodyBytes, StandardCharsets.UTF_8, null);
315 doReturn(Mono.error(a1Exception)).when(a1Client).putPolicy(any());
318 testErrorCode(restClient().put(url, "{}"), httpStatus, responseBody);
321 this.addPolicy("instance1", "type1", "service1", "ric1");
322 doReturn(Mono.error(a1Exception)).when(a1Client).deletePolicy(any());
323 testErrorCode(restClient().delete("/policy?id=instance1"), httpStatus, responseBody);
326 this.addPolicy("instance1", "type1", "service1", "ric1");
327 doReturn(Mono.error(a1Exception)).when(a1Client).getPolicyStatus(any());
328 testErrorCode(restClient().get("/policy_status?id=instance1"), httpStatus, responseBody);
330 // Check that empty response body is OK
331 a1Exception = new WebClientResponseException(httpStatus.value(), "", null, null, null, null);
332 doReturn(Mono.error(a1Exception)).when(a1Client).getPolicyStatus(any());
333 testErrorCode(restClient().get("/policy_status?id=instance1"), httpStatus);
337 public void testPutTypelessPolicy() throws Exception {
338 putService("service1");
339 addPolicyType("", "ric1");
340 String url = putPolicyUrl("service1", "ric1", "", "id1");
341 restClient().put(url, jsonString()).block();
343 String rsp = restClient().get("/policies").block();
344 List<PolicyInfo> info = parseList(rsp, PolicyInfo.class);
345 assertThat(info).size().isEqualTo(1);
346 PolicyInfo policyInfo = info.get(0);
347 assertThat(policyInfo.id.equals("id1")).isTrue();
348 assertThat(policyInfo.type.equals("")).isTrue();
352 public void testRefuseToUpdatePolicy() throws Exception {
353 // Test that only the json can be changed for a already created policy
354 // In this case service is attempted to be changed
356 this.addRic("ricXXX");
357 this.addPolicy("instance1", "type1", "service1", "ric1");
359 // Try change ric1 -> ricXXX
360 String urlWrongRic = putPolicyUrl("service1", "ricXXX", "type1", "instance1");
361 testErrorCode(restClient().put(urlWrongRic, jsonString()), HttpStatus.CONFLICT);
365 public void testGetPolicy() throws Exception {
366 String url = "/policy?id=id";
367 Policy policy = addPolicy("id", "typeName", "service1", "ric1");
369 String rsp = restClient().get(url).block();
370 assertThat(rsp).isEqualTo(policy.json());
373 policies.remove(policy);
374 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
379 public void testDeletePolicy() throws Exception {
380 addPolicy("id", "typeName", "service1", "ric1");
381 assertThat(policies.size()).isEqualTo(1);
383 String url = "/policy?id=id";
384 ResponseEntity<String> entity = restClient().deleteForEntity(url).block();
386 assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
387 assertThat(policies.size()).isEqualTo(0);
389 // Delete a non existing policy
390 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
394 public void testGetPolicySchemas() throws Exception {
395 addPolicyType("type1", "ric1");
396 addPolicyType("type2", "ric2");
398 String url = "/policy_schemas";
399 String rsp = this.restClient().get(url).block();
400 assertThat(rsp).contains("type1");
401 assertThat(rsp).contains("[{\"title\":\"type2\"}");
403 List<String> info = parseSchemas(rsp);
404 assertThat(info.size()).isEqualTo(2);
406 url = "/policy_schemas?ric=ric1";
407 rsp = restClient().get(url).block();
408 assertThat(rsp).contains("type1");
409 info = parseSchemas(rsp);
410 assertThat(info.size()).isEqualTo(1);
412 // Get schema for non existing RIC
413 url = "/policy_schemas?ric=ric1XXX";
414 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
418 public void testGetPolicySchema() throws Exception {
419 addPolicyType("type1", "ric1");
420 addPolicyType("type2", "ric2");
422 String url = "/policy_schema?id=type1";
423 String rsp = restClient().get(url).block();
425 assertThat(rsp).contains("type1");
426 assertThat(rsp).contains("title");
428 // Get non existing schema
429 url = "/policy_schema?id=type1XX";
430 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
434 public void testGetPolicyTypes() throws Exception {
435 addPolicyType("type1", "ric1");
436 addPolicyType("type2", "ric2");
438 String url = "/policy_types";
439 String rsp = restClient().get(url).block();
440 assertThat(rsp).isEqualTo("[\"type2\",\"type1\"]");
442 url = "/policy_types?ric=ric1";
443 rsp = restClient().get(url).block();
444 assertThat(rsp).isEqualTo("[\"type1\"]");
446 // Get policy types for non existing RIC
447 url = "/policy_types?ric=ric1XXX";
448 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
452 public void testGetPolicies() throws Exception {
453 addPolicy("id1", "type1", "service1");
455 String url = "/policies";
456 String rsp = restClient().get(url).block();
458 List<PolicyInfo> info = parseList(rsp, PolicyInfo.class);
459 assertThat(info).size().isEqualTo(1);
460 PolicyInfo policyInfo = info.get(0);
461 assert (policyInfo.validate());
462 assertThat(policyInfo.id).isEqualTo("id1");
463 assertThat(policyInfo.type).isEqualTo("type1");
464 assertThat(policyInfo.service).isEqualTo("service1");
468 public void testGetPoliciesFilter() throws Exception {
469 addPolicy("id1", "type1", "service1");
470 addPolicy("id2", "type1", "service2");
471 addPolicy("id3", "type2", "service1");
473 String url = "/policies?type=type1";
474 String rsp = restClient().get(url).block();
476 assertThat(rsp).contains("id1");
477 assertThat(rsp).contains("id2");
478 assertThat(rsp.contains("id3")).isFalse();
480 url = "/policies?type=type1&service=service2";
481 rsp = restClient().get(url).block();
483 assertThat(rsp.contains("id1")).isFalse();
484 assertThat(rsp).contains("id2");
485 assertThat(rsp.contains("id3")).isFalse();
487 // Test get policies for non existing type
488 url = "/policies?type=type1XXX";
489 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
491 // Test get policies for non existing RIC
492 url = "/policies?ric=XXX";
493 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
497 public void testGetPolicyIdsFilter() throws Exception {
498 addPolicy("id1", "type1", "service1", "ric1");
499 addPolicy("id2", "type1", "service2", "ric1");
500 addPolicy("id3", "type2", "service1", "ric1");
502 String url = "/policy_ids?type=type1";
503 String rsp = restClient().get(url).block();
505 assertThat(rsp).contains("id1");
506 assertThat(rsp).contains("id2");
507 assertThat(rsp.contains("id3")).isFalse();
509 url = "/policy_ids?type=type1&service=service1&ric=ric1";
510 rsp = restClient().get(url).block();
511 assertThat(rsp).isEqualTo("[\"id1\"]");
513 // Test get policy ids for non existing type
514 url = "/policy_ids?type=type1XXX";
515 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
517 // Test get policy ids for non existing RIC
518 url = "/policy_ids?ric=XXX";
519 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
523 public void testPutAndGetService() throws Exception {
525 putService("name", 0, HttpStatus.CREATED);
526 putService("name", 0, HttpStatus.OK);
529 String url = "/services?name=name";
530 String rsp = restClient().get(url).block();
531 List<ServiceStatus> info = parseList(rsp, ServiceStatus.class);
532 assertThat(info.size()).isEqualTo(1);
533 ServiceStatus status = info.iterator().next();
534 assertThat(status.keepAliveIntervalSeconds).isEqualTo(0);
535 assertThat(status.serviceName).isEqualTo("name");
539 rsp = restClient().get(url).block();
540 assertThat(rsp.contains("name")).isTrue();
544 url = "/services/keepalive?name=name";
545 ResponseEntity<String> entity = restClient().putForEntity(url).block();
546 assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
549 assertThat(services.size()).isEqualTo(1);
550 url = "/services?name=name";
551 restClient().delete(url).block();
552 assertThat(services.size()).isEqualTo(0);
554 // Keep alive, no registerred service
555 testErrorCode(restClient().put("/services/keepalive?name=name", ""), HttpStatus.NOT_FOUND);
557 // PUT servive with bad payload
558 testErrorCode(restClient().put("/service", "crap"), HttpStatus.BAD_REQUEST);
559 testErrorCode(restClient().put("/service", "{}"), HttpStatus.BAD_REQUEST);
560 testErrorCode(restClient().put("/service", createServiceJson("name", -123)), HttpStatus.BAD_REQUEST);
562 // GET non existing servive
563 testErrorCode(restClient().get("/services?name=XXX"), HttpStatus.NOT_FOUND);
567 public void testServiceSupervision() throws Exception {
568 putService("service1", 1, HttpStatus.CREATED);
569 addPolicyType("type1", "ric1");
571 String url = putPolicyUrl("service1", "ric1", "type1", "instance1");
572 final String policyBody = jsonString();
573 restClient().put(url, policyBody).block();
575 assertThat(policies.size()).isEqualTo(1);
576 assertThat(services.size()).isEqualTo(1);
578 // Timeout after ~1 second
579 await().untilAsserted(() -> assertThat(policies.size()).isEqualTo(0));
580 assertThat(services.size()).isEqualTo(0);
584 public void testGetPolicyStatus() throws Exception {
585 addPolicy("id", "typeName", "service1", "ric1");
586 assertThat(policies.size()).isEqualTo(1);
588 String url = "/policy_status?id=id";
589 String rsp = restClient().get(url).block();
590 assertThat(rsp.equals("OK")).isTrue();
592 // GET non existing policy status
593 url = "/policy_status?id=XXX";
594 testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
597 private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException {
599 Policy p = ImmutablePolicy.builder().id(id) //
600 .json(jsonString()) //
601 .ownerServiceName(service) //
602 .ric(rics.getRic(ric)) //
603 .type(addPolicyType(typeName, ric)) //
604 .lastModified("lastModified").build();
609 private Policy addPolicy(String id, String typeName, String service) throws ServiceException {
610 return addPolicy(id, typeName, service, "ric");
613 private String createServiceJson(String name, long keepAliveIntervalSeconds) {
614 ServiceRegistrationInfo service = new ServiceRegistrationInfo(name, keepAliveIntervalSeconds, "callbackUrl");
616 String json = gson.toJson(service);
620 private void putService(String name) {
621 putService(name, 0, null);
624 private void putService(String name, long keepAliveIntervalSeconds, @Nullable HttpStatus expectedStatus) {
625 String url = "/service";
626 String body = createServiceJson(name, keepAliveIntervalSeconds);
627 ResponseEntity<String> resp = restClient().putForEntity(url, body).block();
628 if (expectedStatus != null) {
629 assertEquals(expectedStatus, resp.getStatusCode(), "");
633 private String baseUrl() {
634 return "http://localhost:" + port;
637 private String jsonString() {
638 return "{\n \"servingCellNrcgi\": \"1\"\n }";
642 public void testConcurrency() throws Exception {
643 final Instant startTime = Instant.now();
644 List<Thread> threads = new ArrayList<>();
645 a1ClientFactory.setResponseDelay(Duration.ofMillis(1));
647 addPolicyType("type1", "ric");
648 addPolicyType("type2", "ric");
650 for (int i = 0; i < 100; ++i) {
652 new Thread(new ConcurrencyTestRunnable(baseUrl(), supervision, a1ClientFactory, rics, policyTypes),
657 for (Thread t : threads) {
660 assertThat(policies.size()).isEqualTo(0);
661 logger.info("Concurrency test took " + Duration.between(startTime, Instant.now()));
664 private AsyncRestClient restClient() {
665 return new AsyncRestClient(baseUrl());
668 private void testErrorCode(Mono<?> request, HttpStatus expStatus) {
669 testErrorCode(request, expStatus, "");
672 private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains) {
673 StepVerifier.create(request) //
674 .expectSubscription() //
675 .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) //
679 private boolean checkWebClientError(Throwable t, HttpStatus expStatus, String responseContains) {
680 assertTrue(t instanceof WebClientResponseException);
681 WebClientResponseException e = (WebClientResponseException) t;
682 assertThat(e.getStatusCode()).isEqualTo(expStatus);
683 assertThat(e.getResponseBodyAsString()).contains(responseContains);
687 private MockA1Client getA1Client(String ricName) throws ServiceException {
688 return a1ClientFactory.getOrCreateA1Client(ricName);
691 private PolicyType addPolicyType(String policyTypeName, String ricName) {
692 PolicyType type = ImmutablePolicyType.builder() //
693 .name(policyTypeName) //
694 .schema("{\"title\":\"" + policyTypeName + "\"}") //
697 policyTypes.put(type);
698 addRic(ricName).addSupportedPolicyType(type);
702 private Ric addRic(String ricName) {
703 return addRic(ricName, null);
706 private Ric addRic(String ricName, String managedElement) {
707 if (rics.get(ricName) != null) {
708 return rics.get(ricName);
710 List<String> mes = new ArrayList<>();
711 if (managedElement != null) {
712 mes.add(managedElement);
714 RicConfig conf = ImmutableRicConfig.builder() //
717 .managedElementIds(mes) //
718 .controllerName("") //
720 Ric ric = new Ric(conf);
721 ric.setState(Ric.RicState.IDLE);
726 private static <T> List<T> parseList(String jsonString, Class<T> clazz) {
727 List<T> result = new ArrayList<>();
728 JsonArray jsonArr = JsonParser.parseString(jsonString).getAsJsonArray();
729 for (JsonElement jsonElement : jsonArr) {
730 T o = gson.fromJson(jsonElement.toString(), clazz);
736 private static List<String> parseSchemas(String jsonString) {
737 JsonArray arrayOfSchema = JsonParser.parseString(jsonString).getAsJsonArray();
738 List<String> result = new ArrayList<>();
739 for (JsonElement schemaObject : arrayOfSchema) {
740 result.add(schemaObject.toString());