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
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.onap.pnfsimulator.netconfmonitor.netconf;
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;
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;
38 class NetconfConfigurationReaderTest {
40 private static final String NETCONF_MODEL_PATH = "";
41 private static final String EXPECTED_STRING_XML = "<?xml version=\"1.0\"?>";
42 private NetconfConfigurationReader reader;
45 private NetconfSession netconfSession;
47 private NodeSet nodeSet;
49 private Element element;
53 MockitoAnnotations.initMocks(this);
54 reader = new NetconfConfigurationReader(netconfSession, NETCONF_MODEL_PATH);
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);
63 String result = reader.read();
65 verify(netconfSession).getConfig(anyString());
66 verify(nodeSet).first();
67 verify(element).toXMLString();
68 assertEquals(EXPECTED_STRING_XML, result);