48fdc779438fe3f60ce4353f47c4d31b7add7b46
[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 import static org.junit.Assert.assertNotNull;
12
13 import java.util.concurrent.ExecutionException;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.mockito.Mock;
17 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
18 import org.opendaylight.transportpce.common.mapping.PortMapping;
19 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
20 import org.opendaylight.transportpce.common.network.RequestProcessor;
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.rev200128.CancelResourceReserveInputBuilder;
29
30
31 public class PceServiceRPCImplTest extends AbstractTest {
32
33     private PathComputationService pathComputationService;
34     private NotificationPublishService notificationPublishService;
35     private NetworkTransactionImpl networkTransaction;
36     private PceServiceRPCImpl pceServiceRPC;
37     @Mock
38     private PortMapping portMapping;
39
40     @Before
41     public void setUp() throws ExecutionException, InterruptedException {
42         PceTestUtils.writeNetworkIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
43                 TransactionUtils.getNetworkForSpanLoss());
44         notificationPublishService = new NotificationPublishServiceMock();
45         networkTransaction =  new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker()));
46         pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
47                 null, portMapping);
48         pceServiceRPC = new PceServiceRPCImpl(pathComputationService);
49
50     }
51
52     @Test
53     public void testCancelResourceReserve() {
54         CancelResourceReserveInputBuilder cancelResourceReserveInput = new CancelResourceReserveInputBuilder();
55         assertNotNull(pceServiceRPC.cancelResourceReserve(cancelResourceReserveInput.build()));
56     }
57
58     @Test
59     public void testPathComputationRequest() {
60         assertNotNull(pceServiceRPC.pathComputationRequest(PceTestData.getPCERequest()));
61     }
62
63     @Test
64     public void testPathComputationRequestCoRoutingOrGeneral2() {
65         assertNotNull(pceServiceRPC.pathComputationRequest(
66                 PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2()));
67     }
68 }