import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
private ServiceDataStoreOperations serviceDataStoreOperations;
@Mock
private NotificationPublishService notificationPublishService;
+ @Mock
+ private PathComputationService pathComputationService;
@Test
public void testOnDataTreeChangedWhenDeleteService() {
when(service.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
when(service.getDataBefore()).thenReturn(buildService(State.InService, AdminStates.InService));
ServiceListener listener = new ServiceListener(servicehandler, serviceDataStoreOperations,
- notificationPublishService);
+ notificationPublishService, pathComputationService);
listener.onDataTreeChanged(changes);
verify(ch, times(1)).getRootNode();
verify(service, times(1)).getModificationType();
when(service.getDataBefore()).thenReturn(buildService(State.InService, AdminStates.InService));
when(service.getDataAfter()).thenReturn(serviceDown);
ServiceListener listener = new ServiceListener(servicehandler, serviceDataStoreOperations,
- notificationPublishService);
+ notificationPublishService, pathComputationService);
listener.onDataTreeChanged(changes);
verify(ch, times(1)).getRootNode();
verify(service, times(1)).getModificationType();
when(service.getModificationType()).thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED);
when(service.getDataBefore()).thenReturn(buildService(State.InService, AdminStates.InService));
ServiceListener listener = new ServiceListener(servicehandler, serviceDataStoreOperations,
- notificationPublishService);
+ notificationPublishService, pathComputationService);
listener.onDataTreeChanged(changes);
verify(ch, times(1)).getRootNode();
verify(service, times(2)).getModificationType();
.build())
.build())
.buildFuture());
- ServiceListener listener = new ServiceListener(servicehandler, serviceDataStoreOperations,
- notificationPublishService);
+ ServiceListener listener = Mockito.spy(new ServiceListener(servicehandler, serviceDataStoreOperations,
+ notificationPublishService, pathComputationService));
+ Mockito.doReturn(true).when(listener).serviceRerouteCheck(any());
+
listener.onDataTreeChanged(changes);
verify(ch, times(1)).getRootNode();
verify(service, times(1)).getModificationType();
when(service.getDataBefore()).thenReturn(buildService(State.InService, AdminStates.InService));
when(service.getDataAfter()).thenReturn(serviceAfter);
ServiceListener listener = new ServiceListener(servicehandler, serviceDataStoreOperations,
- notificationPublishService);
+ notificationPublishService, pathComputationService);
listener.onDataTreeChanged(changes);
verify(ch, times(1)).getRootNode();
verify(service, times(1)).getModificationType();