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