Add first version of startup
[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 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;
33
34 public class StartupServiceTest {
35     ApplicationConfig appConfigMock;
36
37     @Test
38     public void startup_allOk() {
39         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);
45
46         Rics rics = new Rics();
47
48         StartupService serviceUnderTest = new StartupService(appConfigMock, rics);
49
50         serviceUnderTest.startup();
51
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());
54     }
55 }