2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property
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.ric.portal.dashboard.config;
23 import java.lang.invoke.MethodHandles;
24 import java.util.ArrayList;
25 import java.util.List;
27 import org.oransc.ric.portal.dashboard.model.RicInstance;
28 import org.oransc.ric.portal.dashboard.model.RicInstanceList;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.beans.factory.annotation.Value;
33 import org.springframework.context.annotation.Bean;
34 import org.springframework.context.annotation.Profile;
35 import org.springframework.stereotype.Component;
38 * Publishes a mock list of RIC instances.
42 public class RICInstanceMockConfiguration {
44 private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
46 // Publish constants for use in tests
47 public static final String INSTANCE_KEY_1 = "i1";
48 public static final String INSTANCE_KEY_2 = "i2";
49 public static final String[] INSTANCE_KEYS = { INSTANCE_KEY_1, INSTANCE_KEY_2 };
51 // Simulate remote method delay for UI testing
55 public RICInstanceMockConfiguration(@Value("${mock.config.delay:0}") int delayMs) {
56 logger.debug("ctor: configured with delay {}", delayMs);
57 this.delayMs = delayMs;
61 public RicInstanceList ricInstanceList() throws InterruptedException {
63 logger.debug("ricInstanceList sleeping {}", delayMs);
64 Thread.sleep(delayMs);
66 List<RicInstance> instances = new ArrayList<>();
67 for (String key : INSTANCE_KEYS) {
68 RicInstance i = new RicInstance().key(key).name("RIC Instance " + key)
69 .appUrlPrefix("http://" + key + ".domain.name/app")
70 .pltUrlPrefix("http://" + key + ".domain.name/plt")
71 .caasUrlPrefix("http://" + key + ".domain.name/caas");
74 return new RicInstanceList(instances);