X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=blobdiff_plain;f=servicehandler%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2Fimpl%2FServicehandlerImplTest.java;h=63445c36d05fc948e3d13a38e9e550d2996ccc18;hp=8ff5eebc7fa843fde7355efee2de3d3c13bb1ec6;hb=e2af857602888e5347f137aac70f73ad02bb6c76;hpb=51ccff8b00d89eaeed91b0b46978766fb55dedf9 diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java index 8ff5eebc7..63445c36d 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java @@ -15,6 +15,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import java.util.Map; import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; @@ -29,6 +30,7 @@ import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.transportpce.common.ResponseCodes; import org.opendaylight.transportpce.pce.service.PathComputationService; import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations; +import org.opendaylight.transportpce.servicehandler.ServiceInput; import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl; import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl; import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl; @@ -36,6 +38,10 @@ import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOper import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl; import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils; import org.opendaylight.transportpce.test.AbstractTest; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput; @@ -61,7 +67,17 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempSer import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.ResourceBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPointBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; public class ServicehandlerImplTest extends AbstractTest { @@ -339,6 +355,9 @@ public class ServicehandlerImplTest extends AbstractTest { result.addListener(() -> endSignal.countDown(), executorService); endSignal.await(); + + Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, + result.get().getResult().getConfigurationResponseCommon().getResponseCode()); } @Test @@ -353,23 +372,80 @@ public class ServicehandlerImplTest extends AbstractTest { result.addListener(() -> endSignal.countDown(), executorService); endSignal.await(); + + Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, + result.get().getResult().getConfigurationResponseCommon().getResponseCode()); } @Test public void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException { - //create service to be rerouted later - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, - rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, - networkModelListenerImpl, serviceDataStoreOperations); - serviceDataStoreOperations.createService(serviceCreateInput); + Mockito.when(pathComputationService.pathComputationRerouteRequest(any())) + .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder() + .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder() + .setResponseCode(ResponseCodes.RESPONSE_OK) + .build()) + .build())); + Map atoz = Map.of( + new AToZKey("0"), + new AToZBuilder() + .setId("0") + .setResource(new ResourceBuilder() + .setResource(new TerminationPointBuilder() + .setTpNodeId("tpNodeIdC") + .setTpId("TpIdC1") + .build()) + .setState(State.InService) + .build()) + .build(), + new AToZKey("1"), + new AToZBuilder() + .setId("1") + .setResource(new ResourceBuilder() + .setResource(new TerminationPointBuilder() + .setTpNodeId("tpNodeIdD") + .setTpId("TpIdCD") + .build()) + .setState(State.InService) + .build()) + .build(), new AToZKey("2"), + new AToZBuilder() + .setId("2") + .setResource(new ResourceBuilder() + .setResource(new TerminationPointBuilder() + .setTpNodeId("tpNodeIdA") + .setTpId("TpIdA1") + .build()) + .setState(State.InService) + .build()) + .build() + + ); + serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput), + new PathComputationRequestOutputBuilder() + .setResponseParameters(new ResponseParametersBuilder() + .setPathDescription(new PathDescriptionBuilder() + .setAToZDirection(new AToZDirectionBuilder() + .setAToZ(atoz) + .setRate(Uint32.valueOf(1)) + .build()) + .setZToADirection(new ZToADirectionBuilder() + .setRate(Uint32.valueOf(1)) + .build()) + .build()) + .build()) + .build()); - //service reroute test action - //ServiceRerouteInput is created with the same service information that is created before - ListenableFuture> result = servicehandlerImpl.serviceReroute( - serviceRerouteInput); + serviceDataStoreOperations.createService(serviceCreateInput); + ListenableFuture> result = new ServicehandlerImpl(getNewDataBroker(), + pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, + rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations) + .serviceReroute(serviceRerouteInput); result.addListener(() -> endSignal.countDown(), executorService); endSignal.await(); + + Assert.assertEquals( + ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode()); } @Test