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 com.google.common.collect.ClassToInstanceMap;
18 import java.util.concurrent.ExecutionException;
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
21 import org.junit.jupiter.api.extension.ExtendWith;
22 import org.mockito.Mock;
23 import org.mockito.junit.jupiter.MockitoExtension;
24 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
25 import org.opendaylight.mdsal.binding.api.RpcProviderService;
26 import org.opendaylight.transportpce.common.mapping.PortMapping;
27 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
28 import org.opendaylight.transportpce.pce.service.PathComputationService;
29 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
30 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
31 import org.opendaylight.transportpce.pce.utils.PceTestData;
32 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
33 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
34 import org.opendaylight.transportpce.test.AbstractTest;
35 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInputBuilder;
38 @ExtendWith(MockitoExtension.class)
39 public class PceServiceRPCImplTest extends AbstractTest {
41 private PathComputationService pathComputationService;
42 private NotificationPublishService notificationPublishService;
43 private NetworkTransactionImpl networkTransaction;
45 private PortMapping portMapping;
47 private RpcProviderService rpcProviderService;
51 void setUp() throws ExecutionException, InterruptedException {
52 PceTestUtils.writeNetworkIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
53 TransactionUtils.getNetworkForSpanLoss());
54 notificationPublishService = new NotificationPublishServiceMock();
55 networkTransaction = new NetworkTransactionImpl(getDataBroker());
56 pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
61 void testRpcRegistration() {
62 new PceServiceRPCImpl(rpcProviderService, pathComputationService);
63 verify(rpcProviderService, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
67 void testCancelResourceReserve() {
68 assertNotNull(new CancelResourceReserveImpl(pathComputationService)
69 .invoke(new CancelResourceReserveInputBuilder().build()));
73 void testPathComputationRequest() {
74 assertNotNull(new PathComputationRequestImpl(pathComputationService)
75 .invoke(PceTestData.getPCERequest()));
79 void testPathComputationRerouteRequest() {
80 assertNotNull(new PathComputationRerouteRequestImpl(pathComputationService)
81 .invoke(PceTestData.getPCERerouteRequest()));
85 void testPathComputationRequestCoRoutingOrGeneral2() {
86 assertNotNull(new PathComputationRequestImpl(pathComputationService)
87 .invoke(PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2()));