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;
28 import org.junit.Test;
29 import org.oransc.policyagent.configuration.ApplicationConfig;
30 import org.oransc.policyagent.configuration.ImmutableRicConfig;
31 import org.oransc.policyagent.configuration.RicConfig;
32 import org.oransc.policyagent.repository.Rics;
34 public class StartupServiceTest {
35 ApplicationConfig appConfigMock;
38 public void startup_allOk() {
39 ApplicationConfig appConfigMock = mock(ApplicationConfig.class);
40 Vector<RicConfig> ricConfigs = new Vector<>(2);
41 Vector<String> firstNodes = new Vector<String>(1);
42 firstNodes.add("nodeA");
43 ricConfigs.add(ImmutableRicConfig.builder().name("first").managedElementIds(firstNodes).baseUrl("url").build());
44 when(appConfigMock.getRicConfigs()).thenReturn(ricConfigs);
46 Rics rics = new Rics();
48 StartupService serviceUnderTest = new StartupService(appConfigMock, rics);
50 serviceUnderTest.startup();
52 assertEquals("Correct nymber of Rics not added to Rics", 1, rics.size());
53 assertEquals("Not correct Ric added to Rics", "first", rics.getRic("first").name());