add tests for impl layer pce module 61/89261/2
authorShaabanEltanany <shaaban.eltanany.ext@orange.com>
Wed, 22 Apr 2020 10:25:25 +0000 (12:25 +0200)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Wed, 22 Apr 2020 12:32:05 +0000 (12:32 +0000)
JIRA TRNSPRTPCE-209
Signed-off-by: guillame.lambert <guillaume.lambert@orange.com>
Change-Id: I842c0281795613248cb20ff76057358baeefd42a

pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceProviderTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java [new file with mode: 0644]

diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceProviderTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceProviderTest.java
new file mode 100644 (file)
index 0000000..b04a75a
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2020 Orange Labs, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.impl;
+
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.eq;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
+import org.opendaylight.transportpce.common.network.RequestProcessor;
+import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
+import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.TransportpcePceService;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+
+
+public class PceProviderTest extends AbstractTest {
+
+    private RpcProviderService rpcService;
+    private PathComputationService pathComputationService;
+    private NotificationPublishService notificationPublishService;
+    private NetworkTransactionImpl networkTransaction;
+    private RequestProcessor requestProcessor;
+    private ObjectRegistration<TransportpcePceService> rpcRegistration;
+    private PceProvider pceProvider;
+
+    @Before
+    public void setUp() {
+        rpcService = Mockito.mock(RpcProviderService.class);
+        notificationPublishService = new NotificationPublishServiceMock();
+        requestProcessor = Mockito.mock(RequestProcessor.class);
+        networkTransaction = new NetworkTransactionImpl(requestProcessor);
+        pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService);
+        pceProvider = new PceProvider(rpcService, pathComputationService);
+    }
+
+    @Test
+    public void testInit() {
+        this.rpcRegistration = new ObjectRegistration<TransportpcePceService>() {
+            @NonNull
+            @Override
+            public TransportpcePceService getInstance() {
+                return new PceServiceRPCImpl(pathComputationService);
+            }
+
+            @Override
+            public void close() {
+
+            }
+        };
+
+
+        Mockito
+                .when(rpcService
+                        .registerRpcImplementation(eq(TransportpcePceService.class), anyObject()))
+                .thenReturn(rpcRegistration);
+        pceProvider.init();
+        pceProvider.close();
+    }
+
+}
diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java
new file mode 100644 (file)
index 0000000..116551f
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2020 Orange Labs, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.pce.impl;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
+import org.opendaylight.transportpce.common.network.RequestProcessor;
+import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
+import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.CancelResourceReserveInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInputBuilder;
+
+
+
+
+public class PceServiceRPCImplTest extends AbstractTest {
+
+    private PathComputationService pathComputationService;
+    private NotificationPublishService notificationPublishService;
+    private NetworkTransactionImpl networkTransaction;
+    private RequestProcessor requestProcessor;
+    private PceServiceRPCImpl pceServiceRPC;
+
+    @Before
+    public void setUp() {
+        notificationPublishService = new NotificationPublishServiceMock();
+        requestProcessor = Mockito.mock(RequestProcessor.class);
+        networkTransaction = new NetworkTransactionImpl(requestProcessor);
+        pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService);
+        pceServiceRPC = new PceServiceRPCImpl(pathComputationService);
+    }
+
+    @Test
+    public void testCancelResourceReserve() {
+        CancelResourceReserveInputBuilder cancelResourceReserveInput = new CancelResourceReserveInputBuilder();
+        assertNotNull(pceServiceRPC.cancelResourceReserve(cancelResourceReserveInput.build()));
+    }
+
+    @Test
+    public void testPathComputationRequest() {
+        PathComputationRequestInput pathComputationRequestInput =
+                new PathComputationRequestInputBuilder().build();
+        assertNotNull(pceServiceRPC.pathComputationRequest(pathComputationRequestInput));
+    }
+
+}