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.controllers;
23 import static org.junit.Assert.assertEquals;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
27 import java.util.Vector;
29 import org.junit.Test;
30 import org.oransc.policyagent.configuration.ApplicationConfig;
31 import org.oransc.policyagent.configuration.ImmutableRicConfig;
32 import org.oransc.policyagent.configuration.RicConfig;
33 import org.oransc.policyagent.repository.Rics;
35 public class StartupServiceTest {
36 ApplicationConfig appConfigMock;
39 public void startup_allOk() {
40 ApplicationConfig appConfigMock = mock(ApplicationConfig.class);
41 Vector<RicConfig> ricConfigs = new Vector<>(2);
42 Vector<String> firstNodes = new Vector<String>(1);
43 firstNodes.add("nodeA");
44 ricConfigs.add(ImmutableRicConfig.builder().name("first").managedElementIds(firstNodes).baseUrl("url").build());
45 when(appConfigMock.getRicConfigs()).thenReturn(ricConfigs);
47 Rics rics = new Rics();
49 StartupService serviceUnderTest = new StartupService(appConfigMock, rics);
51 serviceUnderTest.startup();
53 assertEquals("Correct nymber of Rics not added to Rics", 1, rics.size());
54 assertEquals("Not correct Ric added to Rics", "first", rics.getRic("first").name());