2 * Copyright © 2020 Orange Labs, Inc. and others. All rights reserved.
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
9 package org.opendaylight.transportpce.pce.impl;
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;
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.rev230925.CancelResourceReserveInputBuilder;
36 @ExtendWith(MockitoExtension.class)
37 public class PceServiceRPCImplTest extends AbstractTest {
39 private PathComputationService pathComputationService;
40 private NotificationPublishService notificationPublishService;
41 private NetworkTransactionImpl networkTransaction;
42 private PceServiceRPCImpl pceServiceRPC;
44 private PortMapping portMapping;
46 private RpcProviderService rpcProviderService;
50 void setUp() throws ExecutionException, InterruptedException {
51 PceTestUtils.writeNetworkIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
52 TransactionUtils.getNetworkForSpanLoss());
53 notificationPublishService = new NotificationPublishServiceMock();
54 networkTransaction = new NetworkTransactionImpl(getDataBroker());
55 pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
57 pceServiceRPC = new PceServiceRPCImpl(rpcProviderService, pathComputationService);
61 void testRpcRegistration() {
62 verify(rpcProviderService, times(1)).registerRpcImplementations(any());
66 void testCancelResourceReserve() {
67 CancelResourceReserveInputBuilder cancelResourceReserveInput = new CancelResourceReserveInputBuilder();
68 assertNotNull(pceServiceRPC.cancelResourceReserve(cancelResourceReserveInput.build()));
72 void testPathComputationRequest() {
73 assertNotNull(pceServiceRPC.pathComputationRequest(PceTestData.getPCERequest()));
77 void testPathComputationRerouteRequest() {
78 assertNotNull(pceServiceRPC.pathComputationRerouteRequest(PceTestData.getPCERerouteRequest()));
82 void testPathComputationRequestCoRoutingOrGeneral2() {
84 pceServiceRPC.pathComputationRequest(PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2()));