move stubrenderer implementation to servicehandler test folder.
Change-Id: I8a284ea6445421aecbcd99a804274c5f20017e7d
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-transportpce-stubmodels</artifactId>
<version>${project.version}</version>
<classifier>features</classifier>
<type>xml</type>
- </dependency>
+ </dependency-->
</dependencies>
</project>
<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>odl-transportpce-stubmodels</artifactId>
<version>${project.version}</version>
<classifier>features</classifier>
<type>xml</type>
- </dependency>
+ </dependency-->
<dependency>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-common</artifactId>
<artifactId>transportpce-servicehandler</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-stubpce</artifactId>
<version>${project.version}</version>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-stubrenderer</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency-->
</dependencies>
<!-- skipping test since this is an umbrella project / folder -->
<module>features-transportpce</module>
<module>odl-transportpce-api</module>
<module>odl-transportpce-ordmodels</module>
- <module>odl-transportpce-stubmodels</module>
+ <!--module>odl-transportpce-stubmodels</module-->
<module>odl-transportpce</module>
</modules>
<module>renderer</module>
<module>networkmodel</module>
<module>olm</module>
- <module>tests</module>
+ <!--module>tests</module-->
<module>pce</module>
<module>servicehandler</module>
<module>features</module>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>transportpce-stubrenderer</artifactId>
+ <artifactId>transportpce-renderer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.Topology;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.LifecycleState;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
+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.ServiceRerouteOutputBuilder;
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.openroadm.topology.rev161014.topology.AToZ;
return builder.build();
}
+ public static org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
+ .ServiceDeleteInput createServiceDeleteInput(ServiceRerouteInput serviceRerouteInput, Services service) {
+ ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder();
+ builder.setServiceName(serviceRerouteInput.getServiceName());
+ builder.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder().setRequestId(
+ service.getSdncRequestHeader().getRequestId()).build());
+ return builder.build();
+ }
+
public static ServiceAEnd createServiceAEnd(
org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
.ServiceAEnd serviceAEnd) {
return RpcResultBuilder.success(output).buildFuture();
}
+
+ public static ListenableFuture<RpcResult<ServiceRerouteOutput>> createRerouteServiceReply(ServiceRerouteInput input,
+ String finalAck, String message, RpcStatus rpcStatus) {
+ ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
+ .setHardConstraints(null)
+ .setSoftConstraints(null)
+ .setStatusMessage(message)
+ .setStatus(rpcStatus);
+ return RpcResultBuilder.success(output.build()).buildFuture();
+ }
+
public static ListenableFuture<RpcResult<ServiceCreateOutput>> createCreateServiceReply(ServiceCreateInput input,
String finalAck,
String message, String responseCode) {
.setSoftConstraints(serviceReconfigureInput.getSoftConstraints())
.setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend);
}
+ if (output != null) {
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response
+ .parameters.sp.ResponseParameters responseParameters = output.getResponseParameters();
+ if (responseParameters != null) {
+ // service.setPceMetric(responseParameters.getPceMetric());
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426
+ .response.parameters.sp.response.parameters.PathDescription pathDescription =
+ responseParameters.getPathDescription();
+ if (pathDescription != null) {
+ List<AToZ> atozList = new ArrayList<>();
+ List<ZToA> ztoaList = new ArrayList<>();
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response
- .parameters.sp.ResponseParameters responseParameters = output.getResponseParameters();
- if (responseParameters != null) {
- // service.setPceMetric(responseParameters.getPceMetric());
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426
- .response.parameters.sp.response.parameters.PathDescription pathDescription =
- responseParameters.getPathDescription();
- if (pathDescription != null) {
- List<AToZ> atozList = new ArrayList<>();
- List<ZToA> ztoaList = new ArrayList<>();
+ for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
+ .path.description.atoz.direction.AToZ tmp : pathDescription.getAToZDirection().getAToZ()) {
- for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
- .path.description.atoz.direction.AToZ tmp : pathDescription.getAToZDirection().getAToZ()) {
+ AToZKey key = new AToZKey(tmp.key().getId());
+ AToZ atoz = new AToZBuilder().setId(tmp.getId()).withKey(key)
+ // .setResource(tmp.getResource())
+ .build();
+ atozList.add(atoz);
+ }
- AToZKey key = new AToZKey(tmp.key().getId());
- AToZ atoz = new AToZBuilder().setId(tmp.getId()).withKey(key)
- // .setResource(tmp.getResource())
- .build();
- atozList.add(atoz);
- }
+ for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
+ .path.description.ztoa.direction.ZToA
+ tmp : pathDescription.getZToADirection().getZToA()) {
+ ZToAKey key = new ZToAKey(tmp.key().getId());
+ ZToA ztoa = new ZToABuilder().setId(tmp.getId()).withKey(key)
+ // .setResource(tmp.getResource())
+ .build();
+ ztoaList.add(ztoa);
+ }
- for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
- .path.description.ztoa.direction.ZToA
- tmp : pathDescription.getZToADirection().getZToA()) {
- ZToAKey key = new ZToAKey(tmp.key().getId());
- ZToA ztoa = new ZToABuilder().setId(tmp.getId()).withKey(key)
- // .setResource(tmp.getResource())
- .build();
- ztoaList.add(ztoa);
+ Topology topology = new TopologyBuilder().setAToZ(atozList).setZToA(ztoaList).build();
+ service.setTopology(topology);
}
-
- Topology topology = new TopologyBuilder().setAToZ(atozList).setZToA(ztoaList).build();
- service.setTopology(topology);
}
}
return service.build();
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceList;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfo.TailRetention;
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.ServicesKey;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
//Check presence of service to be deleted
String serviceName = input.getServiceDeleteReqInfo().getServiceName();
- Optional<Services> service = this.serviceDataStoreOperations.getService(serviceName);
- if (!service.isPresent()) {
- message = "Service '" + serviceName + "' does not exist in datastore";
- LOG.error(message);
- return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
- message, ResponseCodes.RESPONSE_FAILED);
+ LOG.info("serviceName : {}", serviceName);
+ try {
+ Optional<Services> service = this.serviceDataStoreOperations.getService(serviceName);
+ if (!service.isPresent()) {
+ message = "Service '" + serviceName + "' does not exist in datastore";
+ LOG.error(message);
+ return ModelMappingUtils.createDeleteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ message, ResponseCodes.RESPONSE_FAILED);
+ }
+ } catch (NullPointerException e) {
+ LOG.info("failed to get service '{}' from datastore : ", serviceName, e);
}
LOG.debug("Service '{}' present in datastore !", serviceName);
@Override
public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
- InstanceIdentifier<Services> servicesIID = InstanceIdentifier.create(ServiceList.class)
- .child(Services.class, new ServicesKey(input.getServiceName()));
- ReadOnlyTransaction rtx = this.db.newReadOnlyTransaction();
- Optional<Services> servicesObject;
+ LOG.info("RPC service reroute received");
+ String message = "";
try {
- servicesObject = rtx.read(LogicalDatastoreType.OPERATIONAL, servicesIID).get().toJavaUtil();
+ Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(input.getServiceName());
if (servicesObject.isPresent()) {
ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
sdncBuilder.setRpcAction(RpcActions.ServiceDelete);
deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
// Calling delete service
- serviceDelete(deleteInputBldr.build());
+ ServiceDeleteOutput serviceDeleteOutput = serviceDelete(deleteInputBldr.build()).get().getResult();
// Calling create request now
+ if (!ResponseCodes.RESPONSE_OK
+ .equals(serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode())) {
+ message = "Service delete failed!";
+ return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ message, RpcStatus.Failed);
+ }
ServiceCreateInputBuilder serviceCreateBldr = new ServiceCreateInputBuilder();
serviceCreateBldr.setServiceName(input.getServiceName() + 2);
serviceCreateBldr.setCommonId(servicesObject.get().getCommonId());
ServiceZEndBuilder serviceZendBuilder = new ServiceZEndBuilder(servicesObject.get().getServiceZEnd());
serviceCreateBldr.setServiceZEnd(serviceZendBuilder.build());
serviceCreateBldr.setSoftConstraints(servicesObject.get().getSoftConstraints());
- serviceCreate(serviceCreateBldr.build());
+ ServiceCreateOutput serviceCreateOutput = serviceCreate(serviceCreateBldr.build()).get().getResult();
+ if (!ResponseCodes.RESPONSE_OK
+ .equals(serviceCreateOutput.getConfigurationResponseCommon().getResponseCode())) {
+ message = "Service create failed!";
+ return ModelMappingUtils.createRerouteServiceReply(input, ResponseCodes.FINAL_ACK_YES,
+ message, RpcStatus.Failed);
+ }
ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
.setHardConstraints(null).setSoftConstraints(null).setStatus(
org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful)
- .setStatusMessage("Success");
+ .setStatusMessage("Service reroute successfully !");
return RpcResultBuilder.success(output).buildFuture();
+ } else {
+ LOG.error("Service '{}' is not present", input.getServiceName());
+ message = "Service '" + input.getServiceName() + "' is not present";
}
} catch (InterruptedException | ExecutionException e) {
LOG.info("Exception caught" , e);
}
ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
- .setHardConstraints(null).setSoftConstraints(null).setStatus(RpcStatus.Failed).setStatusMessage("Failure");
-
+ .setHardConstraints(null).setSoftConstraints(null).setStatus(RpcStatus.Failed).setStatusMessage(message);
return RpcResultBuilder.success(output).buildFuture();
}
this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
"topologyData/NW-simple-topology.xml");
- this.rendererServiceOperations = new StubRendererServiceOperations(notificationPublishService);
+ this.rendererServiceOperations = new StubRendererServiceOperations();
}
@Test
public void testCreateServiceValid() throws ExecutionException, InterruptedException {
ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
+ 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.createService(any(ServiceCreateInput.class),
+ any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+ Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.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.modifyService(serviceInput.getServiceName(),
+ State.InService, State.InService)).thenReturn(OperationResult.ok("successful"));
- Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandler.serviceCreate(serviceInput);
+ Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandlerImplMock.serviceCreate(serviceInput);
Assert.assertNotNull(output0);
Assert.assertTrue(output0.get().isSuccessful());
Assert.assertEquals(output0.get().getResult(),
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);
+ .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
.setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
.setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
}
@Test
- public void rerouteServiceIsNotePresent() throws ExecutionException, InterruptedException {
+ public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
- Assert.assertEquals(result.getStatusMessage(), "Failure");
+ Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
}
@Test
public void rerouteServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
- ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
- ServiceCreateOutput createOutput = this.serviceHandler.serviceCreate(createInput).get().getResult();
- ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
- ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
+ ServiceRerouteInput serviceRerouteinput = ServiceDataUtils.buildServiceRerouteInput();
+ ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
+ ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
+
+ /** Mock RPC service-delete. */
+ Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null, 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
+ .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()
+ .setConfigurationResponseCommon(configurationResponseCommon).build();
+ Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
+ Mockito.when(this.serviceDataStoreOperationsMock
+ .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
+ .thenReturn(OperationResult.ok("success"));
+ Mockito.when(this.serviceDataStoreOperationsMock
+ .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
+ .thenReturn(OperationResult.ok("success"));
+
+ ConfigurationResponseCommon configurationResponseCommon2 = 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(configurationResponseCommon2).build();
+
+ /** Mock RPC service-create. */
+ Mockito.when(this.pceServiceWrapperMock.performPCE(any(ServiceCreateInput.class), any(Boolean.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),
+ any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+ ConfigurationResponseCommon configurationResponseCommon3 = 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(configurationResponseCommon3).build());
+ Mockito.when(this.serviceDataStoreOperationsMock.modifyService(any(String.class), any(State.class),
+ any(State.class))).thenReturn(OperationResult.ok("successful"));
+
+ ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult();
Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
result.getStatus());
- Assert.assertEquals("Success", result.getStatusMessage());
-
+ Assert.assertEquals("Service reroute successfully !", result.getStatusMessage());
}
}
+++ /dev/null
-/*
- * Copyright © 2018 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.servicehandler.mappers;
-
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.PathDescription;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.PathDescriptionBuilder;
-
-public final class PathDescriptionConverter {
-
- public static PathDescription getStub(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .servicepath.rev170426.service.implementation.request.input.PathDescription concrete) {
- PathDescriptionBuilder stubBuilder = new PathDescriptionBuilder();
- stubBuilder.setAToZDirection(concrete.getAToZDirection());
- stubBuilder.setZToADirection(concrete.getZToADirection());
- return stubBuilder.build();
- }
-
-
- public static org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service
- .implementation.request.input.PathDescription getConcrete(PathDescription stub) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service
- .implementation.request.input.PathDescriptionBuilder concreteBuilder = new org.opendaylight.yang.gen.v1
- .http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation.request.input
- .PathDescriptionBuilder();
- concreteBuilder.setAToZDirection(stub.getAToZDirection());
- concreteBuilder.setZToADirection(stub.getZToADirection());
- return concreteBuilder.build();
- }
-
- private PathDescriptionConverter() {
- }
-}
+++ /dev/null
-/*
- * Copyright © 2018 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.servicehandler.mappers;
-
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEndBuilder;
-
-public final class ServiceAEndConverter {
-
- public static ServiceAEnd getStub(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath
- .rev170426.service.implementation.request.input.ServiceAEnd concrete) {
- ServiceAEndBuilder stubBuilder = new ServiceAEndBuilder();
- stubBuilder.setClli(concrete.getClli());
- stubBuilder.setNodeId(concrete.getNodeId());
- stubBuilder.setRxDirection(concrete.getRxDirection());
- stubBuilder.setServiceFormat(concrete.getServiceFormat());
- stubBuilder.setServiceRate(concrete.getServiceRate());
- stubBuilder.setTxDirection(concrete.getTxDirection());
- return stubBuilder.build();
- }
-
-
- public static org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service
- .implementation.request.input.ServiceAEnd getConcrete(ServiceAEnd stub) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation
- .request.input.ServiceAEndBuilder concreteBuilder = new org.opendaylight.yang.gen.v1.http.org
- .transportpce.b.c._interface.servicepath.rev170426.service.implementation.request.input
- .ServiceAEndBuilder();
- concreteBuilder.setClli(stub.getClli());
- concreteBuilder.setNodeId(stub.getNodeId());
- concreteBuilder.setRxDirection(stub.getRxDirection());
- concreteBuilder.setServiceFormat(stub.getServiceFormat());
- concreteBuilder.setServiceRate(stub.getServiceRate());
- concreteBuilder.setTxDirection(stub.getTxDirection());
- return concreteBuilder.build();
- }
-
- private ServiceAEndConverter() {
- }
-}
+++ /dev/null
-/*
- * Copyright © 2018 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.servicehandler.mappers;
-
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInputBuilder;
-
-public final class ServiceDeleteInputConverter {
-
- public static ServiceDeleteInput getStub(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .servicepath.rev170426.ServiceDeleteInput concrete) {
- ServiceDeleteInputBuilder stubBuilder = new ServiceDeleteInputBuilder();
- stubBuilder.setServiceHandlerHeader(concrete.getServiceHandlerHeader());
- stubBuilder.setServiceName(concrete.getServiceName());
- return stubBuilder.build();
- }
-
-
- public static org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteInput getConcrete(ServiceDeleteInput stub) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteInputBuilder concreteBuilder = new org.opendaylight.yang.gen.v1.http.org.transportpce
- .b.c._interface.servicepath.rev170426.ServiceDeleteInputBuilder();
- concreteBuilder.setServiceHandlerHeader(stub.getServiceHandlerHeader());
- concreteBuilder.setServiceName(stub.getServiceName());
- return concreteBuilder.build();
- }
-
- private ServiceDeleteInputConverter() {
- }
-}
+++ /dev/null
-/*
- * Copyright © 2018 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.servicehandler.mappers;
-
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutputBuilder;
-
-public final class ServiceDeleteOutputConverter {
-
- public static ServiceDeleteOutput
- getStub(
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput
- concrete
- ) {
- ServiceDeleteOutputBuilder stubBuilder = new ServiceDeleteOutputBuilder();
- stubBuilder.setConfigurationResponseCommon(concrete.getConfigurationResponseCommon());
- return stubBuilder.build();
- }
-
-
- public static
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput
- getConcrete(ServiceDeleteOutput stub) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteOutputBuilder concreteBuilder =
- new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceDeleteOutputBuilder();
- concreteBuilder.setConfigurationResponseCommon(stub.getConfigurationResponseCommon());
- return concreteBuilder.build();
- }
-
- private ServiceDeleteOutputConverter() {
- }
-}
+++ /dev/null
-/*
- * Copyright © 2018 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.servicehandler.mappers;
-
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInputBuilder;
-
-public final class ServiceImplementationRequestInputConverter {
-
- public static ServiceImplementationRequestInput getStub(org.opendaylight.yang.gen.v1.http.org.transportpce
- .b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput concrete) {
- ServiceImplementationRequestInputBuilder stubBuilder = new ServiceImplementationRequestInputBuilder();
- stubBuilder.setServiceHandlerHeader(concrete.getServiceHandlerHeader());
- stubBuilder.setPathDescription(PathDescriptionConverter.getStub(concrete.getPathDescription()));
- stubBuilder.setServiceName(concrete.getServiceName());
- stubBuilder.setServiceAEnd(ServiceAEndConverter.getStub(concrete.getServiceAEnd()));
- stubBuilder.setServiceZEnd(ServiceZEndConverter.getStub(concrete.getServiceZEnd()));
- return stubBuilder.build();
- }
-
-
- public static org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceImplementationRequestInput getConcrete(ServiceImplementationRequestInput stub) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceImplementationRequestInputBuilder concreteBuilder = new org.opendaylight.yang.gen.v1.http.org
- .transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInputBuilder();
- concreteBuilder.setServiceHandlerHeader(stub.getServiceHandlerHeader());
- concreteBuilder.setPathDescription(PathDescriptionConverter.getConcrete(stub.getPathDescription()));
- concreteBuilder.setServiceName(stub.getServiceName());
- concreteBuilder.setServiceAEnd(ServiceAEndConverter.getConcrete(stub.getServiceAEnd()));
- concreteBuilder.setServiceZEnd(ServiceZEndConverter.getConcrete(stub.getServiceZEnd()));
- return concreteBuilder.build();
- }
-
- private ServiceImplementationRequestInputConverter() {
- }
-
-}
+++ /dev/null
-/*
- * Copyright © 2018 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.servicehandler.mappers;
-
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutputBuilder;
-
-public final class ServiceImplementationRequestOutputConverter {
-
- public static ServiceImplementationRequestOutput getStub(org.opendaylight.yang.gen.v1.http.org.transportpce
- .b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput concrete) {
- ServiceImplementationRequestOutputBuilder stubBuilder = new ServiceImplementationRequestOutputBuilder();
- stubBuilder.setConfigurationResponseCommon(concrete.getConfigurationResponseCommon());
- return stubBuilder.build();
- }
-
-
- public static org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceImplementationRequestOutput getConcrete(ServiceImplementationRequestOutput stub) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
- .ServiceImplementationRequestOutputBuilder concreteBuilder = new org.opendaylight.yang.gen.v1.http.org
- .transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder();
- concreteBuilder.setConfigurationResponseCommon(stub.getConfigurationResponseCommon());
- return concreteBuilder.build();
- }
-
- private ServiceImplementationRequestOutputConverter() {
- }
-
-}
+++ /dev/null
-/*
- * Copyright © 2018 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.servicehandler.mappers;
-
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEnd;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEndBuilder;
-
-public final class ServiceZEndConverter {
- public static ServiceZEnd getStub(
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation
- .request.input.ServiceZEnd concrete) {
- ServiceZEndBuilder stubBuilder = new ServiceZEndBuilder();
- stubBuilder.setClli(concrete.getClli());
- stubBuilder.setNodeId(concrete.getNodeId());
- stubBuilder.setRxDirection(concrete.getRxDirection());
- stubBuilder.setServiceFormat(concrete.getServiceFormat());
- stubBuilder.setServiceRate(concrete.getServiceRate());
- stubBuilder.setTxDirection(concrete.getTxDirection());
- return stubBuilder.build();
- }
-
-
- public static
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation
- .request.input.ServiceZEnd getConcrete(ServiceZEnd stub) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation
- .request.input.ServiceZEndBuilder concreteBuilder =
- new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service
- .implementation.request.input.ServiceZEndBuilder();
- concreteBuilder.setClli(stub.getClli());
- concreteBuilder.setNodeId(stub.getNodeId());
- concreteBuilder.setRxDirection(stub.getRxDirection());
- concreteBuilder.setServiceFormat(stub.getServiceFormat());
- concreteBuilder.setServiceRate(stub.getServiceRate());
- concreteBuilder.setTxDirection(stub.getTxDirection());
- return concreteBuilder.build();
- }
-
- private ServiceZEndConverter(){
- }
-}
PathComputationService pathComputationService = new PathComputationServiceImpl(getDataBroker(),
notificationPublishService);
this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
- this.rendererServiceOperations = new StubRendererServiceOperations(notificationPublishService);
+ this.rendererServiceOperations = new StubRendererServiceOperations();
this.serviceHandler = new ServicehandlerImpl(getDataBroker(), pathComputationService,
this.rendererServiceOperations);
}
*/
package org.opendaylight.transportpce.servicehandler.stub;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
-import org.opendaylight.transportpce.servicehandler.mappers.ServiceDeleteInputConverter;
-import org.opendaylight.transportpce.servicehandler.mappers.ServiceDeleteOutputConverter;
-import org.opendaylight.transportpce.servicehandler.mappers.ServiceImplementationRequestInputConverter;
-import org.opendaylight.transportpce.servicehandler.mappers.ServiceImplementationRequestOutputConverter;
-import org.opendaylight.transportpce.stubrenderer.impl.StubrendererImpl;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
public class StubRendererServiceOperations implements RendererServiceOperations {
private static final Logger LOG = LoggerFactory.getLogger(StubRendererServiceOperations.class);
- private StubrendererImpl stubrenderer;
-
- public StubRendererServiceOperations(NotificationPublishService notificationPublishService) {
- this.stubrenderer = new StubrendererImpl(notificationPublishService);
- }
@Override
public ServiceImplementationRequestOutput serviceImplementation(ServiceImplementationRequestInput input) {
- Future<RpcResult<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426
- .ServiceImplementationRequestOutput>> rpcResultFuture = this.stubrenderer
- .serviceImplementationRequest(ServiceImplementationRequestInputConverter.getStub(input));
+ ListenableFuture<RpcResult<ServiceImplementationRequestOutput>> rpcResultFuture = StubrendererImpl
+ .serviceImplementation(input);
try {
- return ServiceImplementationRequestOutputConverter.getConcrete(rpcResultFuture.get().getResult());
+ return rpcResultFuture.get().getResult();
} catch (InterruptedException e) {
LOG.error("RPC serviceImplementation failed !",e);
} catch (ExecutionException e) {
@Override
public ServiceDeleteOutput serviceDelete(ServiceDeleteInput input) {
- Future<RpcResult<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426
- .ServiceDeleteOutput>> rpcResultFuture = this.stubrenderer
- .serviceDelete(ServiceDeleteInputConverter.getStub(input));
+ ListenableFuture<RpcResult<ServiceDeleteOutput>> rpcResultFuture = StubrendererImpl.serviceDelete(input);
try {
- return ServiceDeleteOutputConverter.getConcrete(rpcResultFuture.get().getResult());
+ return rpcResultFuture.get().getResult();
} catch (InterruptedException e) {
LOG.error("RPC serviceDelete failed !",e);
} catch (ExecutionException e) {
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.servicehandler.stub;
+
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class for checking service sdnc-request-header compliancy.
+ *
+ * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
+ *
+ */
+public class StubrendererCompliancyCheck {
+ /** Logging. */
+ private static final Logger LOG = LoggerFactory.getLogger(StubrendererCompliancyCheck.class);
+ /** SdncRequestHeader. */
+ private ServiceHandlerHeader serviceHandlerHeader;
+ /** Service Name. */
+ private String serviceName;
+ /** Response message from procedure. */
+ private String message;
+
+
+ public StubrendererCompliancyCheck(String serviceName,ServiceHandlerHeader serviceHandlerHeader) {
+ this.serviceName = serviceName;
+ this.serviceHandlerHeader = serviceHandlerHeader;
+ this.setMessage("");
+ }
+
+ /**
+ * Check if a String is not null and not equal to void.
+ *
+ * @param value
+ * String value
+ * @return true if String ok false if not
+ */
+ public Boolean checkString(String value) {
+ Boolean result = false;
+ if (value != null && value.compareTo("") != 0) {
+ result = true;
+ }
+ return result;
+
+ }
+
+ /**
+ * Check Compliancy of Service request.
+ *
+ * @param contype
+ * Boolean to check connection Type
+ * @param servicehandler
+ * Boolean to check sndcRequestHeader
+ *
+ * @return true if String ok false if not
+ */
+ public Boolean check(Boolean contype, Boolean servicehandler) {
+ Boolean result = true;
+ if (!checkString(serviceName)) {
+ result = false;
+ message = "Service Name is not set";
+ LOG.info(message);
+ }
+ if (servicehandler) {
+ if (serviceHandlerHeader != null) {
+ String requestId = serviceHandlerHeader.getRequestId();
+ if (!checkString(requestId)) {
+ result = false;
+ message = "Service serviceHandlerHeader 'request-id' is not set";
+ LOG.info(message);
+ }
+ } else {
+ result = false;
+ message = "Service serviceHandlerHeader is not set ";
+ LOG.info(message);
+ }
+ }
+ return result;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2017 Orange, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+
+package org.opendaylight.transportpce.servicehandler.stub;
+
+import com.google.common.util.concurrent.ListenableFuture;
+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.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutputBuilder;
+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.ServiceImplementationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * Class to implement StubrendererService.
+ * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
+ *
+ */
+public final class StubrendererImpl {
+ /** Logging. */
+ private static final Logger LOG = LoggerFactory.getLogger(StubrendererImpl.class);
+ /** check service sdnc-request-header compliancy. */
+
+ private StubrendererImpl() {
+
+ }
+
+
+ public static ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
+ LOG.info("ServiceDelete request ...");
+ String message = "";
+ String responseCode = null;
+ try {
+ LOG.info("Wait for 1s til beginning the Renderer serviceDelete request");
+ Thread.sleep(1000); //sleep for 1s
+ } catch (InterruptedException e) {
+ message = "deleting service failed !";
+ LOG.error("deleting service failed !", e);
+ responseCode = "500";
+ }
+ ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator("yes")
+ .setRequestId(input.getServiceHandlerHeader().getRequestId())
+ .setResponseCode(responseCode)
+ .setResponseMessage(message);
+ ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon.build())
+ .build();
+ return RpcResultBuilder.success(output).buildFuture();
+ }
+
+ public static ListenableFuture<RpcResult<ServiceImplementationRequestOutput>>
+ serviceImplementation(ServiceImplementationRequestInput input) {
+ LOG.info("serviceImplementation request ...");
+ String message = "";
+ String responseCode = null;
+ try {
+ LOG.info("Wait for 1s til beginning the Renderer serviceDelete request");
+ Thread.sleep(1000); //sleep for 1s
+ } catch (InterruptedException e) {
+ message = "implementing service failed !";
+ LOG.error(message);
+ responseCode = "500";
+ }
+ ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+ .setAckFinalIndicator("yes")
+ .setRequestId(input.getServiceHandlerHeader().getRequestId())
+ .setResponseCode(responseCode)
+ .setResponseMessage(message);
+ ServiceImplementationRequestOutput output = new ServiceImplementationRequestOutputBuilder()
+ .setConfigurationResponseCommon(configurationResponseCommon.build())
+ .build();
+ return RpcResultBuilder.success(output).buildFuture();
+ }
+}