Add unit tests PCE RPC path-computation-reroute
[transportpce.git] / pce / src / test / java / org / opendaylight / transportpce / pce / service / PathComputationServiceImplTest.java
index 29d40e3299c60ce4ff8fe56d2cf83c78005a191b..74fdf1e9756a517d17ae669905c103e67141db91 100644 (file)
@@ -7,46 +7,35 @@
  */
 package org.opendaylight.transportpce.pce.service;
 
-import java.math.BigDecimal;
 import java.util.Map;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.pce.gnpy.GnpyResult;
-import org.opendaylight.transportpce.pce.gnpy.GnpyTopoImpl;
 import org.opendaylight.transportpce.pce.utils.PceTestData;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.transportpce.test.DataStoreContext;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.PathBandwidth;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.generic.path.properties.PathPropertiesBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.generic.path.properties.path.properties.PathMetric;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.generic.path.properties.path.properties.PathMetricBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.no.path.info.NoPathBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.result.Response;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.result.ResponseBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.result.ResponseKey;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.result.response.response.type.NoPathCaseBuilder;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev200909.result.response.response.type.PathCaseBuilder;
-import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.PathBandwidth;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.PathPropertiesBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathMetric;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathMetricBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.no.path.info.NoPathBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.Response;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.ResponseBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.ResponseKey;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.NoPathCaseBuilder;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.PathCaseBuilder;
+import org.opendaylight.yangtools.yang.common.Decimal64;
 
 public class PathComputationServiceImplTest extends AbstractTest {
 
     private PathComputationServiceImpl pathComputationServiceImpl;
     private static NetworkTransactionService networkTransactionService = null;
-    private static GnpyTopoImpl gnpyTopoImpl = null;
-    private static GnpyResult gnpyResult = null;
-    private DataStoreContext dataStoreContext = this.getDataStoreContextUtil();
-    private DataBroker dataBroker = this.getDataBroker();
 
     @Before
     public void setUp() {
         networkTransactionService = Mockito.mock(NetworkTransactionService.class);
-        gnpyTopoImpl = Mockito.mock(GnpyTopoImpl.class);
-        gnpyResult = Mockito.mock(GnpyResult.class);
         pathComputationServiceImpl = new PathComputationServiceImpl(
                 networkTransactionService,
                 this.getNotificationPublishService(), null, null);
@@ -64,7 +53,7 @@ public class PathComputationServiceImplTest extends AbstractTest {
     @Test
     public void testPathComputationRequestNoPath() {
         Response response = new ResponseBuilder()
-                .withKey(new ResponseKey(Uint32.valueOf(1))).setResponseType(new NoPathCaseBuilder()
+                .withKey(new ResponseKey("responseId")).setResponseType(new NoPathCaseBuilder()
                 .setNoPath(new NoPathBuilder().setNoPath("no path").build()).build()).build();
 
         pathComputationServiceImpl.generateGnpyResponse(response,"path");
@@ -76,10 +65,10 @@ public class PathComputationServiceImplTest extends AbstractTest {
     @Test
     public void testPathComputationRequestPathCase() {
         PathMetric pathMetric = new PathMetricBuilder()
-                .setAccumulativeValue(new BigDecimal(21))
-                .setMetricType(PathBandwidth.class).build();
+                .setAccumulativeValue(Decimal64.valueOf("21"))
+                .setMetricType(PathBandwidth.VALUE).build();
         Response response = new ResponseBuilder()
-                .withKey(new ResponseKey(Uint32.valueOf(1))).setResponseType(new PathCaseBuilder()
+                .withKey(new ResponseKey("responseId")).setResponseType(new PathCaseBuilder()
                 .setPathProperties(new PathPropertiesBuilder().setPathMetric(Map.of(pathMetric.key(),pathMetric))
                 .build()).build()).build();
 
@@ -89,6 +78,14 @@ public class PathComputationServiceImplTest extends AbstractTest {
 
     }
 
+    @Test
+    public void pathComputationRerouteRequestTest() {
+        pathComputationServiceImpl.generateGnpyResponse(null,"path");
+        Assert.assertNotNull(pathComputationServiceImpl
+                .pathComputationRerouteRequest(PceTestData.getPCEReroute()));
+
+    }
+
     @After
     public void destroy() {
         pathComputationServiceImpl.close();