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;
14 import java.util.concurrent.ExecutionException;
15 import org.junit.jupiter.api.BeforeEach;
16 import org.junit.jupiter.api.Test;
17 import org.mockito.Mock;
18 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
19 import org.opendaylight.transportpce.common.mapping.PortMapping;
20 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
21 import org.opendaylight.transportpce.pce.service.PathComputationService;
22 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
23 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
24 import org.opendaylight.transportpce.pce.utils.PceTestData;
25 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
26 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
27 import org.opendaylight.transportpce.test.AbstractTest;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveInputBuilder;
31 public class PceServiceRPCImplTest extends AbstractTest {
33 private PathComputationService pathComputationService;
34 private NotificationPublishService notificationPublishService;
35 private NetworkTransactionImpl networkTransaction;
36 private PceServiceRPCImpl pceServiceRPC;
38 private PortMapping portMapping;
41 void setUp() throws ExecutionException, InterruptedException {
42 PceTestUtils.writeNetworkIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
43 TransactionUtils.getNetworkForSpanLoss());
44 notificationPublishService = new NotificationPublishServiceMock();
45 networkTransaction = new NetworkTransactionImpl(getDataBroker());
46 pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
48 pceServiceRPC = new PceServiceRPCImpl(pathComputationService);
52 void testCancelResourceReserve() {
53 CancelResourceReserveInputBuilder cancelResourceReserveInput = new CancelResourceReserveInputBuilder();
54 assertNotNull(pceServiceRPC.cancelResourceReserve(cancelResourceReserveInput.build()));
58 void testPathComputationRequest() {
59 assertNotNull(pceServiceRPC.pathComputationRequest(PceTestData.getPCERequest()));
63 void testPathComputationRerouteRequest() {
64 assertNotNull(pceServiceRPC.pathComputationRerouteRequest(PceTestData.getPCERerouteRequest()));
68 void testPathComputationRequestCoRoutingOrGeneral2() {
70 pceServiceRPC.pathComputationRequest(PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2()));