package org.opendaylight.transportpce.pce.impl;
-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 static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+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.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;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceService;
+@ExtendWith(MockitoExtension.class)
public class PceProviderTest extends AbstractTest {
+ @Mock
private RpcProviderService rpcService;
+ @Mock
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,
- null);
- pceProvider = new PceProvider(rpcService, pathComputationService);
- }
+ @Mock
+ private TransportpcePceService pceServiceRPCImpl;
@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), Mockito.any()))
- .thenReturn(rpcRegistration);
- pceProvider.init();
- pceProvider.close();
+ void testInit() {
+ new PceProvider(rpcService, pathComputationService, pceServiceRPCImpl);
+ verify(rpcService, times(1)).registerRpcImplementation(any(), any(TransportpcePceService.class));
}
-
}