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;
23 import static org.mockito.ArgumentMatchers.anyString;
24 import static org.mockito.Mockito.any;
25 import static org.mockito.Mockito.anyLong;
26 import static org.mockito.Mockito.doNothing;
27 import static org.mockito.Mockito.times;
28 import static org.mockito.Mockito.verify;
29 import static org.mockito.Mockito.when;
31 import com.tailf.jnc.JNCException;
32 import java.io.IOException;
33 import java.util.Timer;
34 import org.junit.jupiter.api.BeforeEach;
35 import org.junit.jupiter.api.Test;
36 import org.mockito.Mock;
37 import org.mockito.MockitoAnnotations;
38 import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationCache;
39 import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationReader;
40 import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationWriter;
42 class NetconfMonitorServiceTest {
44 private NetconfMonitorService service;
49 private NetconfConfigurationReader reader;
51 private NetconfConfigurationWriter writer;
53 private NetconfConfigurationCache cache;
57 MockitoAnnotations.initMocks(this);
58 service = new NetconfMonitorService(timer, reader, writer, cache);
62 void startNetconfService() throws IOException, JNCException {
63 when(reader.read()).thenReturn("message");
64 doNothing().when(writer).writeToFile(anyString());
65 doNothing().when(cache).update(anyString());
69 verify(cache, times(1)).update(anyString());
70 verify(writer, times(1)).writeToFile(anyString());
71 verify(timer, times(1)).scheduleAtFixedRate(any(), anyLong(), anyLong());