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
8 package org.opendaylight.transportpce.pce.service;
10 import org.junit.After;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.mockito.Mockito;
15 import org.opendaylight.mdsal.binding.api.DataBroker;
16 import org.opendaylight.transportpce.common.DataStoreContext;
17 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
18 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
19 import org.opendaylight.transportpce.common.network.RequestProcessor;
20 import org.opendaylight.transportpce.pce.gnpy.GnpyResult;
21 import org.opendaylight.transportpce.pce.gnpy.GnpyTopoImpl;
22 import org.opendaylight.transportpce.pce.utils.PceTestData;
23 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
24 import org.opendaylight.transportpce.pce.utils.TransactionUtils;
25 import org.opendaylight.transportpce.test.AbstractTest;
27 public class PathComputationServiceImplTest extends AbstractTest {
29 private PathComputationServiceImpl pathComputationServiceImpl;
30 private static NetworkTransactionService networkTransactionService = null;
31 private static GnpyTopoImpl gnpyTopoImpl = null;
32 private static GnpyResult gnpyResult = null;
33 private DataStoreContext dataStoreContext = this.getDataStoreContextUtil();
34 private DataBroker dataBroker = this.getDataBroker();
38 networkTransactionService = Mockito.mock(NetworkTransactionService.class);
39 gnpyTopoImpl = Mockito.mock(GnpyTopoImpl.class);
40 gnpyResult = Mockito.mock(GnpyResult.class);
41 pathComputationServiceImpl = new PathComputationServiceImpl(
42 networkTransactionService,
43 this.getNotificationPublishService());
44 pathComputationServiceImpl.init();
48 public void pathComputationRequestTest() {
50 pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCE_simpletopology_test1_request()));
54 @Test(expected = Exception.class)
55 public void generateGnpyResponse() throws Exception {
56 PceTestUtils.writeNetworkIntoDataStore(dataBroker, dataStoreContext, TransactionUtils.getNetworkForSpanLoss());
57 GnpyResult gnpyResult2 =
58 new GnpyResult("A-to-Z",
59 new GnpyTopoImpl(new NetworkTransactionImpl(
60 new RequestProcessor(dataBroker))));
61 pathComputationServiceImpl.generateGnpyResponse(gnpyResult2.getResponse(), "A-to-Z");
66 public void destroy() {
67 pathComputationServiceImpl.close();