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.rev240205.CancelResourceReserveInputBuilder;
37 @ExtendWith(MockitoExtension.class)
38 public class PceServiceRPCImplTest extends AbstractTest {
40 private PathComputationService pathComputationService;
41 private NotificationPublishService notificationPublishService;
42 private NetworkTransactionImpl networkTransaction;
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,
60 void testRpcRegistration() {
61 new PceServiceRPCImpl(rpcProviderService, pathComputationService);
62 verify(rpcProviderService, times(1)).registerRpcImplementations(
63 any(CancelResourceReserveImpl.class), any(PathComputationRequestImpl.class),
64 any(PathComputationRerouteRequestImpl.class));
68 void testCancelResourceReserve() {
69 assertNotNull(new CancelResourceReserveImpl(pathComputationService)
70 .invoke(new CancelResourceReserveInputBuilder().build()));
74 void testPathComputationRequest() {
75 assertNotNull(new PathComputationRequestImpl(pathComputationService)
76 .invoke(PceTestData.getPCERequest()));
80 void testPathComputationRerouteRequest() {
81 assertNotNull(new PathComputationRerouteRequestImpl(pathComputationService)
82 .invoke(PceTestData.getPCERerouteRequest()));
86 void testPathComputationRequestCoRoutingOrGeneral2() {
87 assertNotNull(new PathComputationRequestImpl(pathComputationService)
88 .invoke(PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2()));