Bump upstream dependencies to Ca
[transportpce.git] / pce / src / test / java / org / opendaylight / transportpce / pce / impl / PceServiceRPCImplTest.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
12 import static org.junit.jupiter.api.Assertions.assertNotNull;
13 import static org.mockito.ArgumentMatchers.any;
14 import static org.mockito.Mockito.times;
15 import static org.mockito.Mockito.verify;
16
17 import java.util.concurrent.ExecutionException;
18 import org.junit.jupiter.api.BeforeEach;
19 import org.junit.jupiter.api.Test;
20 import org.junit.jupiter.api.extension.ExtendWith;
21 import org.mockito.Mock;
22 import org.mockito.junit.jupiter.MockitoExtension;
23 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
24 import org.opendaylight.mdsal.binding.api.RpcProviderService;
25 import org.opendaylight.transportpce.common.mapping.PortMapping;
26 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
27 import org.opendaylight.transportpce.pce.service.PathComputationService;
28 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
29 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
30 import org.opendaylight.transportpce.pce.utils.PceTestData;
31 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
32 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
33 import org.opendaylight.transportpce.test.AbstractTest;
34 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInputBuilder;
35
36 @ExtendWith(MockitoExtension.class)
37 public class PceServiceRPCImplTest extends AbstractTest {
38
39     private PathComputationService pathComputationService;
40     private NotificationPublishService notificationPublishService;
41     private NetworkTransactionImpl networkTransaction;
42     @Mock
43     private PortMapping portMapping;
44     @Mock
45     private RpcProviderService rpcProviderService;
46
47
48     @BeforeEach
49     void setUp() throws ExecutionException, InterruptedException {
50         PceTestUtils.writeNetworkIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
51                 TransactionUtils.getNetworkForSpanLoss());
52         notificationPublishService = new NotificationPublishServiceMock();
53         networkTransaction =  new NetworkTransactionImpl(getDataBroker());
54         pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
55                 null, portMapping);
56     }
57
58     @Test
59     void testRpcRegistration() {
60         new PceServiceRPCImpl(rpcProviderService, pathComputationService);
61         verify(rpcProviderService, times(1)).registerRpcImplementations(any());
62     }
63
64     @Test
65     void testCancelResourceReserve() {
66         assertNotNull(new CancelResourceReserveImpl(pathComputationService)
67                 .invoke(new CancelResourceReserveInputBuilder().build()));
68     }
69
70     @Test
71     void testPathComputationRequest() {
72         assertNotNull(new PathComputationRequestImpl(pathComputationService)
73                 .invoke(PceTestData.getPCERequest()));
74     }
75
76     @Test
77     void testPathComputationRerouteRequest() {
78         assertNotNull(new PathComputationRerouteRequestImpl(pathComputationService)
79                 .invoke(PceTestData.getPCERerouteRequest()));
80     }
81
82     @Test
83     void testPathComputationRequestCoRoutingOrGeneral2() {
84         assertNotNull(new PathComputationRequestImpl(pathComputationService)
85                 .invoke(PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2()));
86     }
87 }