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;
11 import org.junit.After;
12 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.mockito.Mockito;
16 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
17 import org.opendaylight.transportpce.pce.utils.PceTestData;
18 import org.opendaylight.transportpce.test.AbstractTest;
19 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.PathBandwidth;
20 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.PathPropertiesBuilder;
21 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathMetric;
22 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathMetricBuilder;
23 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.no.path.info.NoPathBuilder;
24 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.Response;
25 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.ResponseBuilder;
26 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.ResponseKey;
27 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.NoPathCaseBuilder;
28 import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.PathCaseBuilder;
29 import org.opendaylight.yangtools.yang.common.Decimal64;
31 public class PathComputationServiceImplTest extends AbstractTest {
33 private PathComputationServiceImpl pathComputationServiceImpl;
34 private static NetworkTransactionService networkTransactionService = null;
38 networkTransactionService = Mockito.mock(NetworkTransactionService.class);
39 pathComputationServiceImpl = new PathComputationServiceImpl(
40 networkTransactionService,
41 this.getNotificationPublishService(), null, null);
42 pathComputationServiceImpl.init();
46 public void pathComputationRequestTest() {
47 pathComputationServiceImpl.generateGnpyResponse(null,"path");
49 pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCE_simpletopology_test1_request()));
54 public void testPathComputationRequestNoPath() {
55 Response response = new ResponseBuilder()
56 .withKey(new ResponseKey("responseId")).setResponseType(new NoPathCaseBuilder()
57 .setNoPath(new NoPathBuilder().setNoPath("no path").build()).build()).build();
59 pathComputationServiceImpl.generateGnpyResponse(response,"path");
61 pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCE_test3_request_54()));
66 public void testPathComputationRequestPathCase() {
67 PathMetric pathMetric = new PathMetricBuilder()
68 .setAccumulativeValue(Decimal64.valueOf("21"))
69 .setMetricType(PathBandwidth.VALUE).build();
70 Response response = new ResponseBuilder()
71 .withKey(new ResponseKey("responseId")).setResponseType(new PathCaseBuilder()
72 .setPathProperties(new PathPropertiesBuilder().setPathMetric(Map.of(pathMetric.key(),pathMetric))
73 .build()).build()).build();
75 pathComputationServiceImpl.generateGnpyResponse(response,"path");
77 pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCE_test3_request_54()));
82 public void destroy() {
83 pathComputationServiceImpl.close();