Remove outdated doc for A1 Adaptor
[integration.git] / test / mocks / masspnfsim / pnf-sim-lightweight / src / test / java / org / onap / pnfsimulator / netconfmonitor / netconf / NetconfConfigurationReaderTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  * PNF-REGISTRATION-HANDLER
4  * ================================================================================
5  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
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.onap.pnfsimulator.netconfmonitor.netconf;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.mockito.ArgumentMatchers.anyString;
25 import static org.mockito.Mockito.verify;
26 import static org.mockito.Mockito.when;
27
28 import com.tailf.jnc.Element;
29 import com.tailf.jnc.JNCException;
30 import com.tailf.jnc.NetconfSession;
31 import com.tailf.jnc.NodeSet;
32 import java.io.IOException;
33 import org.junit.jupiter.api.BeforeEach;
34 import org.junit.jupiter.api.Test;
35 import org.mockito.Mock;
36 import org.mockito.MockitoAnnotations;
37
38 class NetconfConfigurationReaderTest {
39
40     private static final String NETCONF_MODEL_PATH = "";
41     private static final String EXPECTED_STRING_XML = "<?xml version=\"1.0\"?>";
42     private NetconfConfigurationReader reader;
43
44     @Mock
45     private NetconfSession netconfSession;
46     @Mock
47     private NodeSet nodeSet;
48     @Mock
49     private Element element;
50
51     @BeforeEach
52     void setup() {
53         MockitoAnnotations.initMocks(this);
54         reader = new NetconfConfigurationReader(netconfSession, NETCONF_MODEL_PATH);
55     }
56
57     @Test
58     void properlyReadXML() throws IOException, JNCException {
59         when(netconfSession.getConfig(anyString())).thenReturn(nodeSet);
60         when(nodeSet.first()).thenReturn(element);
61         when(element.toXMLString()).thenReturn(EXPECTED_STRING_XML);
62
63         String result = reader.read();
64
65         verify(netconfSession).getConfig(anyString());
66         verify(nodeSet).first();
67         verify(element).toXMLString();
68         assertEquals(EXPECTED_STRING_XML, result);
69     }
70 }