b7ccf9183314c6424413b45928483ba772d4d9dd
[transportpce.git] / pce / src / test / java / org / opendaylight / transportpce / pce / service / PathComputationServiceImplTest.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 package org.opendaylight.transportpce.pce.service;
9
10 import org.junit.After;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
15 import org.opendaylight.transportpce.common.network.RequestProcessor;
16 import org.opendaylight.transportpce.pce.gnpy.GnpyResult;
17 import org.opendaylight.transportpce.pce.gnpy.GnpyTopoImpl;
18 import org.opendaylight.transportpce.pce.utils.PceTestData;
19 import org.opendaylight.transportpce.test.AbstractTest;
20
21 public class PathComputationServiceImplTest extends AbstractTest {
22
23     private PathComputationServiceImpl pathComputationServiceImpl;
24
25     @Before
26     public void setUp() {
27         pathComputationServiceImpl = new PathComputationServiceImpl(
28                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
29                 this.getNotificationPublishService());
30         pathComputationServiceImpl.init();
31     }
32
33     @Test
34     public void pathComputationRequestTest() {
35         Assert.assertNotNull(
36                 pathComputationServiceImpl.pathComputationRequest(PceTestData.getEmptyPCERequest()));
37
38     }
39
40     @Test(expected = Exception.class)
41     public void generateGnpyResponse() throws Exception {
42
43         GnpyResult gnpyResult =
44                 new GnpyResult("A-to-Z",
45                         new GnpyTopoImpl(new NetworkTransactionImpl(
46                                 new RequestProcessor(this.getNewDataBroker()))));
47         pathComputationServiceImpl.generateGnpyResponse(gnpyResult.getResponse(), "A-to-Z");
48     }
49
50
51     @After
52     public void destroy() {
53         pathComputationServiceImpl.close();
54     }
55 }