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 static org.junit.jupiter.api.Assertions.assertNotNull;
13 import org.junit.jupiter.api.BeforeEach;
14 import org.junit.jupiter.api.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);
45 void pathComputationRequestTest() {
46 pathComputationServiceImpl.generateGnpyResponse(null,"path");
48 pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCE_simpletopology_test1_request()));
52 void testPathComputationRequestNoPath() {
53 Response response = new ResponseBuilder()
54 .withKey(new ResponseKey("responseId")).setResponseType(new NoPathCaseBuilder()
55 .setNoPath(new NoPathBuilder().setNoPath("no path").build()).build()).build();
57 pathComputationServiceImpl.generateGnpyResponse(response,"path");
58 assertNotNull(pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCE_test3_request_54()));
62 void testPathComputationRequestPathCase() {
63 PathMetric pathMetric = new PathMetricBuilder()
64 .setAccumulativeValue(Decimal64.valueOf("21"))
65 .setMetricType(PathBandwidth.VALUE).build();
66 Response response = new ResponseBuilder()
67 .withKey(new ResponseKey("responseId")).setResponseType(new PathCaseBuilder()
68 .setPathProperties(new PathPropertiesBuilder().setPathMetric(Map.of(pathMetric.key(),pathMetric))
69 .build()).build()).build();
71 pathComputationServiceImpl.generateGnpyResponse(response,"path");
72 assertNotNull(pathComputationServiceImpl.pathComputationRequest(PceTestData.getPCE_test3_request_54()));
76 void pathComputationRerouteRequestTest() {
77 pathComputationServiceImpl.generateGnpyResponse(null,"path");
78 assertNotNull(pathComputationServiceImpl.pathComputationRerouteRequest(PceTestData.getPCEReroute()));