c3d573542cc4f48a491cf4feb8385869fcc08567
[transportpce.git] / pce / src / test / java / org / opendaylight / transportpce / pce / impl / PceProviderTest.java
1 /*
2  * Copyright © 2020 Orange Labs, 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
9 package org.opendaylight.transportpce.pce.impl;
10
11 import static org.mockito.ArgumentMatchers.eq;
12
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.mockito.Mockito;
17 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
18 import org.opendaylight.mdsal.binding.api.RpcProviderService;
19 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
20 import org.opendaylight.transportpce.pce.service.PathComputationService;
21 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
22 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
23 import org.opendaylight.transportpce.test.AbstractTest;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceService;
25 import org.opendaylight.yangtools.concepts.ObjectRegistration;
26
27 public class PceProviderTest extends AbstractTest {
28
29     private RpcProviderService rpcService;
30     private PathComputationService pathComputationService;
31     private NotificationPublishService notificationPublishService;
32     private NetworkTransactionImpl networkTransaction;
33     private ObjectRegistration<TransportpcePceService> rpcRegistration;
34     private PceProvider pceProvider;
35
36     @Before
37     public void setUp() {
38         rpcService = Mockito.mock(RpcProviderService.class);
39         notificationPublishService = new NotificationPublishServiceMock();
40         networkTransaction = new NetworkTransactionImpl(getDataBroker());
41         pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
42                 null, null);
43         pceProvider = new PceProvider(rpcService, pathComputationService);
44     }
45
46     @Test
47     public void testInit() {
48         this.rpcRegistration = new ObjectRegistration<TransportpcePceService>() {
49             @NonNull
50             @Override
51             public TransportpcePceService getInstance() {
52                 return new PceServiceRPCImpl(pathComputationService);
53             }
54
55             @Override
56             public void close() {
57
58             }
59         };
60         Mockito
61                 .when(rpcService
62                         .registerRpcImplementation(eq(TransportpcePceService.class), Mockito.any()))
63                 .thenReturn(rpcRegistration);
64         pceProvider.init();
65         pceProvider.close();
66     }
67
68 }