PCE unit testing update 06/79406/3
authordoha.khaled <dkhaled.ext@orange.com>
Thu, 10 Jan 2019 10:22:07 +0000 (12:22 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Mon, 21 Jan 2019 15:28:15 +0000 (16:28 +0100)
Change-Id: I5e3e60917f855b4dbf854a158c4d6c4d2f31b78d

pce/src/test/java/org/opendaylight/transportpce/pce/PceSendingPceRPCsTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceProviderTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImplTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/utils/DataStoreUtils.java
pce/src/test/java/org/opendaylight/transportpce/pce/utils/DataUtils.java

index 0ac1d4c9e5c069cbb2dd692310799627caef281c..3f577853bd9abc12142f79559d1006d385f86cd1 100644 (file)
@@ -8,15 +8,9 @@
 
 package org.opendaylight.transportpce.pce;
 
-import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.transportpce.pce.impl.PceServiceRPCImpl;
-import org.opendaylight.transportpce.pce.service.PathComputationService;
-import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
 import org.opendaylight.transportpce.pce.utils.PceTestData;
-import org.opendaylight.transportpce.pce.utils.PceTestUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
 
@@ -32,7 +26,7 @@ public class PceSendingPceRPCsTest extends AbstractTest {
     }
 
     @Test
-    public void test(){
+    public void test() {
 //        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil()
 //            , "topologyData/NW-for-test-5-4.xml");
         pceSendingPceRPCs.pathComputation();
index 54f60f2bcb343c2244bb334c4f5f5c6d7441a46b..3d844243baa69bdf1207ebb9f499fae3c7513e6f 100644 (file)
@@ -10,13 +10,12 @@ package org.opendaylight.transportpce.pce.impl;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.transportpce.pce.stub.RpcProviderRegistryStub;
-import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PceService;
 
@@ -37,7 +36,7 @@ public class PceProviderTest extends AbstractTest {
     }
 
     @Test
-    public void testIntialization(){
+    public void testIntialization() {
         pceProvider.init();
         pceProvider.close();
     }
index 59c6ebe9415a42ecba673b7f80d995d83879c6c1..9f59e17f99a28177e5ee8748f828263cbe4ba2a5 100644 (file)
@@ -19,7 +19,10 @@ import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
 import org.opendaylight.transportpce.pce.utils.DataUtils;
 import org.opendaylight.transportpce.pce.utils.PceTestData;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.*;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public class PceServiceRPCImplTest extends AbstractTest {
index 506130d40c3d641ce1987214ab25b89125640970..1a09b3f9fdb10e8fcd28708a6e9c9d084ce055b1 100644 (file)
@@ -13,9 +13,16 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.transportpce.pce.utils.*;
+import org.opendaylight.transportpce.pce.utils.DataStoreUtils;
+import org.opendaylight.transportpce.pce.utils.DataUtils;
+import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock2;
+import org.opendaylight.transportpce.pce.utils.PceTestData;
+import org.opendaylight.transportpce.pce.utils.PceTestUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.*;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
 
 public class PathComputationServiceImplTest extends AbstractTest {
 
@@ -25,51 +32,57 @@ public class PathComputationServiceImplTest extends AbstractTest {
     @Before
     public void setUp() {
         notificationPublishService = this.getDataStoreContextUtil().createNotificationPublishService();
-        pathComputationServiceImpl = new PathComputationServiceImpl(this.getDataBroker(), notificationPublishService);
+        pathComputationServiceImpl = new PathComputationServiceImpl(this.getDataBroker(),
+            notificationPublishService);
     }
 
     @Test
-    public void dummyTest(){
+    public void dummyTest() {
         pathComputationServiceImpl.init();
         pathComputationServiceImpl.close();
     }
 
 
     @Test
-    public void testCancelResourceReserve(){
+    public void testCancelResourceReserve() {
         CancelResourceReserveInput input = DataUtils.getCancelResourceReserveInput();
         CancelResourceReserveOutput output = pathComputationServiceImpl.cancelResourceReserve(input);
         Assert.assertEquals("200", output.getConfigurationResponseCommon().getResponseCode());
         Assert.assertEquals("Yes", output.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(input.getServiceHandlerHeader().getRequestId(), output.getConfigurationResponseCommon().getRequestId());
-        Assert.assertEquals("Cancelling ResourceReserve failed !", output.getConfigurationResponseCommon().getResponseMessage());
+        Assert.assertEquals(input.getServiceHandlerHeader().getRequestId(), output.getConfigurationResponseCommon()
+            .getRequestId());
+        Assert.assertEquals("Cancelling ResourceReserve failed !", output.getConfigurationResponseCommon()
+            .getResponseMessage());
     }
 
     @Test
-    public void testCancelResourceReserve2(){
+    public void testCancelResourceReserve2() {
         notificationPublishService = new NotificationPublishServiceMock2();
         pathComputationServiceImpl = new PathComputationServiceImpl(this.getDataBroker(), notificationPublishService);
         CancelResourceReserveInput input = DataUtils.getCancelResourceReserveInput();
         CancelResourceReserveOutput output = pathComputationServiceImpl.cancelResourceReserve(input);
         Assert.assertEquals("200", output.getConfigurationResponseCommon().getResponseCode());
         Assert.assertEquals("Yes", output.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(input.getServiceHandlerHeader().getRequestId(), output.getConfigurationResponseCommon().getRequestId());
-        Assert.assertEquals("Cancelling ResourceReserve failed !", output.getConfigurationResponseCommon().getResponseMessage());
+        Assert.assertEquals(input.getServiceHandlerHeader().getRequestId(), output.getConfigurationResponseCommon()
+            .getRequestId());
+        Assert.assertEquals("Cancelling ResourceReserve failed !", output.getConfigurationResponseCommon()
+            .getResponseMessage());
     }
 
     @Test
     public void testPathComputationRequest() throws ExecutionException, InterruptedException {
-        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil()
-            "topologyData/NW-for-test-5-4.xml");
+        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
+            "topologyData/NW-for-test-5-4.xml");
         PathComputationRequestInput input = PceTestData.getEmptyPCERequest();
         PathComputationRequestOutput output = pathComputationServiceImpl.pathComputationRequest(input);
-        Assert.assertEquals("Path not calculated", output.getConfigurationResponseCommon().getResponseCode());
+        Assert.assertEquals("Path not calculated", output.getConfigurationResponseCommon()
+            .getResponseCode());
     }
 
     @Test
     public void testPathComputationRequest2() throws ExecutionException, InterruptedException {
-        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil()
-        , "topologyData/NW-for-test-5-4.xml");
+        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
+            "topologyData/NW-for-test-5-4.xml");
         PathComputationRequestInput input = PceTestData.getPCE_test1_request_54();
         PathComputationRequestOutput output = pathComputationServiceImpl.pathComputationRequest(input);
         Assert.assertEquals("200", output.getConfigurationResponseCommon().getResponseCode());
@@ -78,9 +91,10 @@ public class PathComputationServiceImplTest extends AbstractTest {
     @Test
     public void testPathComputationRequest21() throws ExecutionException, InterruptedException {
         notificationPublishService = new NotificationPublishServiceMock2();
-        pathComputationServiceImpl = new PathComputationServiceImpl(this.getDataBroker(), notificationPublishService);
-        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil()
-            , "topologyData/NW-for-test-5-4.xml");
+        pathComputationServiceImpl = new PathComputationServiceImpl(this.getDataBroker(),
+            notificationPublishService);
+        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
+            "topologyData/NW-for-test-5-4.xml");
         PathComputationRequestInput input = PceTestData.getPCE_test1_request_54();
         PathComputationRequestOutput output = pathComputationServiceImpl.pathComputationRequest(input);
         Assert.assertEquals("200", output.getConfigurationResponseCommon().getResponseCode());
@@ -110,11 +124,6 @@ public class PathComputationServiceImplTest extends AbstractTest {
         Assert.assertEquals("500", output.getConfigurationResponseCommon().getResponseCode());
     }
 
-    /**
-     *
-     * @throws ExecutionException
-     * @throws InterruptedException
-     */
     @Test
     public void testPathComputationRequest25() throws ExecutionException, InterruptedException {
         DataStoreUtils.writeTopologyIntoDataStore(this.getDataBroker(), DataStoreUtils.getNetwork3());
@@ -133,8 +142,8 @@ public class PathComputationServiceImplTest extends AbstractTest {
 
     @Test
     public void testPathComputationRequest3() throws ExecutionException, InterruptedException {
-        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil()
-            "topologyData/NW-for-test-5-4.xml");
+        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
+            "topologyData/NW-for-test-5-4.xml");
         PathComputationRequestInput input = PceTestData.getPCE_test2_request_54();
         PathComputationRequestOutput output = pathComputationServiceImpl.pathComputationRequest(input);
         Assert.assertEquals("200", output.getConfigurationResponseCommon().getResponseCode());
@@ -143,8 +152,8 @@ public class PathComputationServiceImplTest extends AbstractTest {
 
     @Test
     public void testPathComputationRequest4() throws ExecutionException, InterruptedException {
-        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil()
-            "topologyData/NW-for-test-5-4.xml");
+        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
+            "topologyData/NW-for-test-5-4.xml");
         PathComputationRequestInput input = PceTestData.getPCE_test3_request_54();
         PathComputationRequestOutput output = pathComputationServiceImpl.pathComputationRequest(input);
         Assert.assertEquals("200", output.getConfigurationResponseCommon().getResponseCode());
@@ -152,8 +161,8 @@ public class PathComputationServiceImplTest extends AbstractTest {
 
     @Test
     public void testPathComputationRequest5() throws ExecutionException, InterruptedException {
-        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil()
-            "topologyData/NW-for-test-5-4.xml");
+        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
+            "topologyData/NW-for-test-5-4.xml");
         PathComputationRequestInput input = PceTestData.getPCERequest();
         PathComputationRequestOutput output = pathComputationServiceImpl.pathComputationRequest(input);
         Assert.assertEquals("200", output.getConfigurationResponseCommon().getResponseCode());
@@ -162,8 +171,8 @@ public class PathComputationServiceImplTest extends AbstractTest {
 
     @Test
     public void testPathComputationRequest6() throws ExecutionException, InterruptedException {
-        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil()
-            "topologyData/NW-simple-topology.xml");
+        PceTestUtils.writeTopologyIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(),
+            "topologyData/NW-simple-topology.xml");
         PathComputationRequestInput input = PceTestData.getPCE_simpletopology_test1_request();
         PathComputationRequestOutput output = pathComputationServiceImpl.pathComputationRequest(input);
         Assert.assertEquals("200", output.getConfigurationResponseCommon().getResponseCode());
index cd8338bed571452a2451ebd80e1eb3027f4d8b49..1bca6be44d1e90e3527c6fe532f035c12efc82ae 100644 (file)
@@ -15,7 +15,11 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.NetworkUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.*;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.Network;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NetworkBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NetworkId;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NetworkKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NodeId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.network.NetworkTypesBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.network.Node;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.network.NodeBuilder;
@@ -29,6 +33,9 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public final class DataStoreUtils {
 
+    private DataStoreUtils(){
+
+    }
 
     public static void writeTopologyIntoDataStore(DataBroker dataBroker, Network network)
         throws ExecutionException, InterruptedException {
@@ -39,7 +46,7 @@ public final class DataStoreUtils {
         writeOnlyTransaction.submit().get();
     }
 
-    public static Network getEmptyNetwork(){
+    public static Network getEmptyNetwork() {
         Augmentation<Network> aug = new Network1Builder().build();
         Network network = new NetworkBuilder()
             .setNetworkId(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))
@@ -49,7 +56,7 @@ public final class DataStoreUtils {
         return network;
     }
 
-    public static Network getNetwork1(){
+    public static Network getNetwork1() {
         List<Node> nodes = new ArrayList<>();
         Node node1 = new NodeBuilder()
             .setNodeId(new NodeId("node 1"))
@@ -65,7 +72,7 @@ public final class DataStoreUtils {
         return network;
     }
 
-    public static Network getNetwork2(){
+    public static Network getNetwork2() {
         List<Node> nodes = new ArrayList<>();
         Augmentation<Network> aug = new Network1Builder().build();
         Network network = new NetworkBuilder()
@@ -77,7 +84,7 @@ public final class DataStoreUtils {
         return network;
     }
 
-    public static Network getNetwork3(){
+    public static Network getNetwork3() {
         List<Link> links = new ArrayList<>();
         List<Node> nodes = new ArrayList<>();
         Augmentation<Network> aug = new Network1Builder().setLink(links).build();
@@ -90,7 +97,7 @@ public final class DataStoreUtils {
         return network;
     }
 
-    public static Network getNetwork4(){
+    public static Network getNetwork4() {
         List<Link> links = new ArrayList<>();
         Link link1 = new LinkBuilder()
             .setLinkId(new LinkId("link1"))
index b453b55c5badfeb6513b5a7c59515148b928ff10..fa8700614b97e10c5cc8884512262a2634a29068 100644 (file)
@@ -8,29 +8,17 @@
 
 package org.opendaylight.transportpce.pce.utils;
 
-import java.util.Arrays;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceAEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceZEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceZEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.RoutingConstraintsSp;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraintsBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraintsBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeader;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder;
 
 public final class DataUtils {
 
-    public static CancelResourceReserveInput getCancelResourceReserveInput(){
+    private DataUtils(){
+
+    }
+
+    public static CancelResourceReserveInput getCancelResourceReserveInput() {
         CancelResourceReserveInput input = new CancelResourceReserveInputBuilder()
             .setServiceName("service 1")
             .setServiceHandlerHeader(new ServiceHandlerHeaderBuilder()