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.RicRegion;
29 import org.oransc.ric.portal.dashboard.model.RicRegionList;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 import org.springframework.context.annotation.Bean;
33 import org.springframework.context.annotation.Configuration;
34 import org.springframework.context.annotation.Profile;
37 * Publishes a mock list of RIC instances.
41 public class RICInstanceMockConfiguration {
43 private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
45 // Publish constants for use in tests
46 public static final String REGION_NAME_1 = "Region AAA";
47 public static final String REGION_NAME_2 = "Region DDD";
48 public static final String INSTANCE_KEY_1 = "i1";
49 public static final String INSTANCE_KEY_2 = "i2";
50 public static final String[] INSTANCE_KEYS = { INSTANCE_KEY_1, INSTANCE_KEY_2 };
52 // No constructor needed, don't simulate delay from the Dashboard
55 public RicRegionList ricRegions() {
56 logger.debug("Creating mock bean ricRegions");
57 List<RicRegion> regions = new ArrayList<>();
58 RicRegion region1 = new RicRegion().name(REGION_NAME_1);
60 List<RicInstance> instances1 = new ArrayList<>();
61 region1.setInstances(instances1);
62 String key1 = INSTANCE_KEY_1;
63 instances1.add(new RicInstance().key(key1).name("RIC Instance " + key1) //
64 .appUrlPrefix("http://" + key1 + ".domain.name/app") //
65 .pltUrlPrefix("http://" + key1 + ".domain.name/plt") //
66 .caasUrlPrefix("http://" + key1 + ".domain.name/caas"));
67 RicRegion region2 = new RicRegion().name(REGION_NAME_2);
69 List<RicInstance> instances2 = new ArrayList<>();
70 region2.setInstances(instances2);
71 String key2 = INSTANCE_KEY_2;
72 instances2.add(new RicInstance().key(key2).name("RIC Instance " + key2) //
73 .appUrlPrefix("http://" + key2 + ".domain.name/app") //
74 .pltUrlPrefix("http://" + key2 + ".domain.name/plt") //
75 .caasUrlPrefix("http://" + key2 + ".domain.name/caas"));
76 return new RicRegionList(regions);