import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
import org.opendaylight.transportpce.pce.utils.PceTestData;
import org.opendaylight.transportpce.pce.utils.PceTestUtils;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private PathComputationService pathComputationService;
private RendererServiceOperations rendererServiceOperations;
+ private NetworkModelWavelengthService networkModelWavelengthService;
private ServicehandlerImpl serviceHandler;
@Mock
@Before
public void setUp() {
this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
- this.rendererServiceOperations);
- this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ this.rendererServiceOperations, this.networkModelWavelengthService);
+ this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
MockitoAnnotations.initMocks(this);
}
this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
"topologyData/NW-simple-topology.xml");
- this.rendererServiceOperations = new StubRendererServiceOperations();
+ this.rendererServiceOperations =
+ new StubRendererServiceOperations(this.networkModelWavelengthService, getDataBroker());
}
@Test
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
Assert.assertEquals(0, output0.get().getErrors().size());
}
+ @Test
+ public void createTempServiceHandlerServiceCreateValid() throws ExecutionException, InterruptedException {
+ TempServiceCreateInput serviceInput = ServiceDataUtils.buildTempServiceCreateInput();
+ ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+ .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
+ PathComputationRequestOutput pathComputationRequestOutput =
+ new PathComputationRequestOutputBuilder(PceTestData.getPCE_simpletopology_test1_result((long) 5))
+ .setConfigurationResponseCommon(configurationResponseCommon).build();
+ Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
+ .thenReturn(pathComputationRequestOutput);
+ Mockito.when(this.serviceDataStoreOperationsMock.createTempService(any(TempServiceCreateInput.class),
+ any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
+ any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+ ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+ .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
+ Mockito.when(
+ this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
+ .thenReturn(new ServiceImplementationRequestOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon2).build());
+ Mockito.when(this.serviceDataStoreOperationsMock.modifyTempService(serviceInput.getCommonId(), State.InService,
+ State.InService)).thenReturn(OperationResult.ok("successful"));
+ Future<RpcResult<TempServiceCreateOutput>> output0 =
+ this.serviceHandlerImplMock.tempServiceCreate(serviceInput);
+ Assert.assertNotNull(output0);
+ Assert.assertTrue(output0.get().isSuccessful());
+ Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
+ ResponseCodes.FINAL_ACK_YES, "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get()
+ .getResult());
+ Assert.assertEquals(0, output0.get().getErrors().size());
+ }
+
@Test
public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
emptyServiceNameInput = builtInput.setServiceName("").build();
Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
- "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
+ "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+ .getResult());
}
@Test
nullServiceNameInput = builtInput.setServiceName(null).build();
Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
- "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
+ "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+ .getResult());
+ }
+
+ @Test
+ public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
+ TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
+ TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
+ emptyServiceNameInput = builtInput.setCommonId("").build();
+ Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
+ ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
+ "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+ .getResult());
+ }
+
+ @Test
+ public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
+ TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
+ TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
+ emptyServiceNameInput = builtInput.setCommonId(null).build();
+ Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
+ ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
+ "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
+ .get().getResult());
}
@Test
@Test
public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ ServicehandlerImpl servicehandler =
+ new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
@Test
public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
- ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ ServicehandlerImpl servicehandler =
+ new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
txDirectionBuilder.setLgx(lgx);
serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
- this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
.getResult();
}
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class)))
.thenReturn(OperationResult.failed("Failed to create servicePath " + serviceCreateInput.getServiceName()
+ " to ServicePath List"));
Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
ResponseCodes.FINAL_ACK_YES);
Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
- verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceCreateInput.class),
+ verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class));
}
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
rxDirectionBuilder.setLgx(lgx);
serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
- this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+ this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
.getResult();
}
Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
}
+ @Test
+ public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
+ TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+ TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
+ serviceDeleteInput = builder.setCommonId("").build();
+ TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
+ Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+ ResponseCodes.FINAL_ACK_YES);
+ Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+ }
+
+ @Test
+ public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
+ TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+ TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
+ serviceDeleteInput = builder.setCommonId(null).build();
+ TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
+ Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+ ResponseCodes.FINAL_ACK_YES);
+ Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+ }
+
@Test
public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
}
+ @Test
+ public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
+ TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+ Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
+ TempServiceDeleteOutput result =
+ this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
+ Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+ ResponseCodes.FINAL_ACK_YES);
+ Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+ }
+
@Test
public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteInput input = ModelMappingUtils
- .createServiceDeleteInput(serviceDeleteInput);
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("success").build();
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .servicepath.rev170426.ServiceDeleteOutputBuilder()
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
.setConfigurationResponseCommon(configurationResponseCommon).build();
Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteInput input = ModelMappingUtils
- .createServiceDeleteInput(serviceDeleteInput);
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .servicepath.rev170426.ServiceDeleteOutputBuilder()
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
.setConfigurationResponseCommon(configurationResponseCommon).build();
Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
Mockito.when(this.serviceDataStoreOperationsMock
ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteInput input = ModelMappingUtils
- .createServiceDeleteInput(serviceDeleteInput);
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .servicepath.rev170426.ServiceDeleteOutputBuilder()
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
.setConfigurationResponseCommon(configurationResponseCommon).build();
Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
Mockito.when(this.serviceDataStoreOperationsMock
ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .servicepath.rev170426.ServiceDeleteOutputBuilder()
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
+ .rev171017.ServiceDeleteOutputBuilder()
.setConfigurationResponseCommon(configurationResponseCommon).build();
Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
Mockito.when(this.serviceDataStoreOperationsMock
Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
}
+ @Test
+ public void deleteTempServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
+
+ TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+ Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+ .Services> service = Optional.of(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+ .temp.service.list.ServicesBuilder().setCommonId("service 1").build());
+ Mockito.when(this.serviceDataStoreOperationsMock.getTempService("service 1")).thenReturn(service);
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+ new ServiceInput(serviceDeleteInput));
+ ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+ .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
+ .rev171017.ServiceDeleteOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon).build();
+ Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
+ Mockito.when(this.serviceDataStoreOperationsMock
+ .deleteServicePath(serviceDeleteInput.getCommonId()))
+ .thenReturn(OperationResult.ok("success"));
+ Mockito.when(this.serviceDataStoreOperationsMock
+ .deleteTempService(serviceDeleteInput.getCommonId()))
+ .thenReturn(OperationResult.ok("success"));
+ TempServiceDeleteOutput result = this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get()
+ .getResult();
+ Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+ ResponseCodes.FINAL_ACK_YES);
+ Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
+ }
+
@Test
public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
/** Mock RPC service-delete. */
- Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null, null);
+ Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null);
Optional<Services> service = Optional.of(serviceMock);
Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
.ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get());
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .servicepath.rev170426.ServiceDeleteOutputBuilder()
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+ .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
+ .rev171017.ServiceDeleteOutputBuilder()
.setConfigurationResponseCommon(configurationResponseCommon).build();
Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
Mockito.when(this.serviceDataStoreOperationsMock
.thenReturn(pathComputationRequestOutput);
Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
- Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
ConfigurationResponseCommon configurationResponseCommon3 = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")