Introduce NetconfTimer
[netconf.git] / protocol / netconf-client / src / test / java / org / opendaylight / netconf / client / NetconfClientSessionNegotiatorFactoryTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netconf.client;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.mock;
13
14 import io.netty.channel.Channel;
15 import io.netty.util.concurrent.Promise;
16 import java.util.Optional;
17 import org.junit.Test;
18 import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
19 import org.opendaylight.netconf.common.impl.DefaultNetconfTimer;
20
21 public class NetconfClientSessionNegotiatorFactoryTest {
22     @Test
23     public void testGetSessionNegotiator() throws Exception {
24         NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
25         final var timer = new DefaultNetconfTimer();
26         NetconfSessionListenerFactory<NetconfClientSessionListener> listenerFactory =
27                 mock(NetconfSessionListenerFactory.class);
28         doReturn(sessionListener).when(listenerFactory).getSessionListener();
29
30         Channel channel = mock(Channel.class);
31         Promise<NetconfClientSession> promise = mock(Promise.class);
32         NetconfClientSessionNegotiatorFactory negotiatorFactory = new NetconfClientSessionNegotiatorFactory(timer,
33                 Optional.empty(), 200L);
34
35         NetconfClientSessionNegotiator sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory,
36             channel, promise);
37         assertNotNull(sessionNegotiator);
38     }
39 }