Turn NetworkTransactionImpl into a component
[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.pce.service.PathComputationService;
21 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
22 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
23 import org.opendaylight.transportpce.pce.utils.PceTestData;
24 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
25 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
26 import org.opendaylight.transportpce.test.AbstractTest;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveInputBuilder;
28
29
30 public class PceServiceRPCImplTest extends AbstractTest {
31
32     private PathComputationService pathComputationService;
33     private NotificationPublishService notificationPublishService;
34     private NetworkTransactionImpl networkTransaction;
35     private PceServiceRPCImpl pceServiceRPC;
36     @Mock
37     private PortMapping portMapping;
38
39     @Before
40     public void setUp() throws ExecutionException, InterruptedException {
41         PceTestUtils.writeNetworkIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
42                 TransactionUtils.getNetworkForSpanLoss());
43         notificationPublishService = new NotificationPublishServiceMock();
44         networkTransaction =  new NetworkTransactionImpl(getDataBroker());
45         pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
46                 null, portMapping);
47         pceServiceRPC = new PceServiceRPCImpl(pathComputationService);
48
49     }
50
51     @Test
52     public void testCancelResourceReserve() {
53         CancelResourceReserveInputBuilder cancelResourceReserveInput = new CancelResourceReserveInputBuilder();
54         assertNotNull(pceServiceRPC.cancelResourceReserve(cancelResourceReserveInput.build()));
55     }
56
57     @Test
58     public void testPathComputationRequest() {
59         assertNotNull(pceServiceRPC.pathComputationRequest(PceTestData.getPCERequest()));
60     }
61
62     @Test
63     public void testPathComputationRerouteRequest() {
64         assertNotNull(pceServiceRPC.pathComputationRerouteRequest(PceTestData.getPCERerouteRequest()));
65     }
66
67     @Test
68     public void testPathComputationRequestCoRoutingOrGeneral2() {
69         assertNotNull(pceServiceRPC.pathComputationRequest(
70                 PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2()));
71     }
72 }