X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fimpl%2FPceServiceRPCImplTest.java;h=a90beececd7bbed77ca5b2dcb1d1e8fb1640bc6c;hb=198afc243c98aedfc5b30b93c1a5e3052d30868c;hp=48fdc779438fe3f60ce4353f47c4d31b7add7b46;hpb=56ad6406faba3227e19a6f609325c8b9dbaca3fb;p=transportpce.git 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 index 48fdc7794..a90beecec 100644 --- a/pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java +++ b/pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java @@ -8,16 +8,23 @@ package org.opendaylight.transportpce.pce.impl; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import com.google.common.collect.ClassToInstanceMap; import java.util.concurrent.ExecutionException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.transportpce.common.mapping.PortMapping; 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; @@ -25,44 +32,58 @@ import org.opendaylight.transportpce.pce.utils.PceTestData; import org.opendaylight.transportpce.pce.utils.PceTestUtils; import org.opendaylight.transportpce.pce.utils.TransactionUtils; 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.rev240205.CancelResourceReserveInputBuilder; +@ExtendWith(MockitoExtension.class) public class PceServiceRPCImplTest extends AbstractTest { private PathComputationService pathComputationService; private NotificationPublishService notificationPublishService; private NetworkTransactionImpl networkTransaction; - private PceServiceRPCImpl pceServiceRPC; @Mock private PortMapping portMapping; + @Mock + private RpcProviderService rpcProviderService; - @Before - public void setUp() throws ExecutionException, InterruptedException { - PceTestUtils.writeNetworkIntoDataStore(this.getDataBroker(), this.getDataStoreContextUtil(), + + @BeforeEach + void setUp() throws ExecutionException, InterruptedException { + PceTestUtils.writeNetworkIntoDataStore(getDataBroker(), getDataStoreContextUtil(), TransactionUtils.getNetworkForSpanLoss()); notificationPublishService = new NotificationPublishServiceMock(); - networkTransaction = new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())); + networkTransaction = new NetworkTransactionImpl(getDataBroker()); pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService, null, portMapping); - pceServiceRPC = new PceServiceRPCImpl(pathComputationService); + } + @Test + void testRpcRegistration() { + new PceServiceRPCImpl(rpcProviderService, pathComputationService); + verify(rpcProviderService, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class)); + } + + @Test + void testCancelResourceReserve() { + assertNotNull(new CancelResourceReserveImpl(pathComputationService) + .invoke(new CancelResourceReserveInputBuilder().build())); } @Test - public void testCancelResourceReserve() { - CancelResourceReserveInputBuilder cancelResourceReserveInput = new CancelResourceReserveInputBuilder(); - assertNotNull(pceServiceRPC.cancelResourceReserve(cancelResourceReserveInput.build())); + void testPathComputationRequest() { + assertNotNull(new PathComputationRequestImpl(pathComputationService) + .invoke(PceTestData.getPCERequest())); } @Test - public void testPathComputationRequest() { - assertNotNull(pceServiceRPC.pathComputationRequest(PceTestData.getPCERequest())); + void testPathComputationRerouteRequest() { + assertNotNull(new PathComputationRerouteRequestImpl(pathComputationService) + .invoke(PceTestData.getPCERerouteRequest())); } @Test - public void testPathComputationRequestCoRoutingOrGeneral2() { - assertNotNull(pceServiceRPC.pathComputationRequest( - PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2())); + void testPathComputationRequestCoRoutingOrGeneral2() { + assertNotNull(new PathComputationRequestImpl(pathComputationService) + .invoke(PceTestData.getPathComputationRequestInputWithCoRoutingOrGeneral2())); } }