366524f6dfc1572a33caba87ae61698d9b28820a
[nonrtric.git] / policy-agent / src / test / java / org / oransc / policyagent / controllers / StartupServiceTest.java
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2019 Nordix Foundation
6  * %%
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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===================================
19  */
20
21 package org.oransc.policyagent.controllers;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
26
27 import java.util.Vector;
28
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;
34
35 public class StartupServiceTest {
36     ApplicationConfig appConfigMock;
37
38     @Test
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);
46
47         Rics rics = new Rics();
48
49         StartupService serviceUnderTest = new StartupService(appConfigMock, rics);
50
51         serviceUnderTest.startup();
52
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());
55     }
56 }