remove stubs bundles from build process 43/77143/1
authorguillaume.lambert <guillaume.lambert@orange.com>
Mon, 17 Sep 2018 13:10:38 +0000 (15:10 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Fri, 19 Oct 2018 13:14:19 +0000 (15:14 +0200)
move stubrenderer implementation to servicehandler test folder.

Change-Id: I8a284ea6445421aecbcd99a804274c5f20017e7d
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
19 files changed:
features/features-transportpce/pom.xml
features/odl-transportpce/pom.xml
features/pom.xml
pom.xml
servicehandler/pom.xml
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServiceHandlerImplTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/PathDescriptionConverter.java [deleted file]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceAEndConverter.java [deleted file]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceDeleteInputConverter.java [deleted file]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceDeleteOutputConverter.java [deleted file]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceImplementationRequestInputConverter.java [deleted file]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceImplementationRequestOutputConverter.java [deleted file]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceZEndConverter.java [deleted file]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImplTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubRendererServiceOperations.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererCompliancyCheck.java [new file with mode: 0644]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java [new file with mode: 0644]

index 8e96c85fd267ae14adf2b281de72bad0c6fe865c..94158a3e0642cf39fcd652335c7aa76ba43736da 100644 (file)
@@ -43,12 +43,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <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>
index 9f254689ece0b9d2199db488073cb31ae0972c37..9487097d6ca6c69b7363575e2122e08df1638727 100644 (file)
@@ -88,13 +88,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <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>
@@ -125,7 +125,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>transportpce-servicehandler</artifactId>
       <version>${project.version}</version>
     </dependency>
-    <dependency>
+    <!--dependency>
       <groupId>org.opendaylight.transportpce</groupId>
       <artifactId>transportpce-stubpce</artifactId>
       <version>${project.version}</version>
@@ -134,7 +134,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <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 -->
index 6ab23c37e8a74c739667ca81aa697e1abecfeb2a..94d1555e2d489f05998d4280c90bab441c4add99 100644 (file)
@@ -26,7 +26,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <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>
 
diff --git a/pom.xml b/pom.xml
index d82ad328842c20d95c6d90e0c0631b9a01c89c6d..f731e05e9df69713ebf7ef844b445738db1f9ab2 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -36,7 +36,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <module>renderer</module>
     <module>networkmodel</module>
     <module>olm</module>
-    <module>tests</module>
+    <!--module>tests</module-->
     <module>pce</module>
     <module>servicehandler</module>
     <module>features</module>
index fabded4ddf380735e021aed3f5b6143ba1b2b8fc..7963a9858818fa27159a75cf0f314f1b26467186 100644 (file)
@@ -94,7 +94,7 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
     </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>transportpce-stubrenderer</artifactId>
+      <artifactId>transportpce-renderer</artifactId>
       <version>${project.version}</version>
     </dependency>
     <dependency>
index e5b44c40de68057525f04a483066626357bbf1ba..1f3ff47f7bf11c04666f8e99d7ff9ee422789fde 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev1
 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;
@@ -29,6 +30,9 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
 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;
@@ -116,6 +120,15 @@ public final class ModelMappingUtils {
         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) {
@@ -173,6 +186,17 @@ public final class ModelMappingUtils {
         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) {
@@ -238,40 +262,41 @@ public final class ModelMappingUtils {
                 .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();
index b81e9b4d5ac1871729a91b9e2987c58e38f3d36b..48583b38f131bc0f033cc234ddf7fd9643bcbd10 100644 (file)
@@ -14,8 +14,6 @@ import java.time.format.DateTimeFormatter;
 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;
@@ -45,7 +43,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
 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;
@@ -68,10 +65,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service
 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;
@@ -204,12 +199,17 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
 
         //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);
@@ -273,12 +273,10 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
 
     @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");
@@ -294,8 +292,14 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
                 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());
@@ -315,19 +319,27 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
                 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();
     }
 
index 1967a8ba950bfd0cb420f292ad76c6a597c7e7a8..104d1713cb6c1c86ec082f47be466ab3c3abb7e2 100644 (file)
@@ -112,15 +112,37 @@ public class ServiceHandlerImplTest extends AbstractTest {
         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(),
@@ -941,8 +963,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
         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();
@@ -964,25 +985,70 @@ public class ServiceHandlerImplTest extends AbstractTest {
     }
 
     @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());
     }
 }
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/PathDescriptionConverter.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/PathDescriptionConverter.java
deleted file mode 100644 (file)
index c1a949f..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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() {
-    }
-}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceAEndConverter.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceAEndConverter.java
deleted file mode 100644 (file)
index 471d097..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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() {
-    }
-}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceDeleteInputConverter.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceDeleteInputConverter.java
deleted file mode 100644 (file)
index 412afb8..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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() {
-    }
-}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceDeleteOutputConverter.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceDeleteOutputConverter.java
deleted file mode 100644 (file)
index b6ea691..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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() {
-    }
-}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceImplementationRequestInputConverter.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceImplementationRequestInputConverter.java
deleted file mode 100644 (file)
index 985cb64..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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() {
-    }
-
-}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceImplementationRequestOutputConverter.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceImplementationRequestOutputConverter.java
deleted file mode 100644 (file)
index 61aa496..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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() {
-    }
-
-}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceZEndConverter.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/mappers/ServiceZEndConverter.java
deleted file mode 100644 (file)
index c830b2d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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(){
-    }
-}
index 9ec0a651c3c026524b9b511e47dad70106987f10..60616616a856566a289a441dabf07a0b61cea56b 100644 (file)
@@ -38,7 +38,7 @@ public class ServiceDataStoreOperationsImplTest extends AbstractTest {
         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);
     }
index 6db468c39326da4d32ef4a144f57dedbeb174b45..37c926b29352cbd62a6692b9f5f6b09771540f84 100644 (file)
@@ -7,16 +7,9 @@
  */
 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;
@@ -27,19 +20,13 @@ import org.slf4j.LoggerFactory;
 
 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) {
@@ -50,11 +37,9 @@ public class StubRendererServiceOperations implements RendererServiceOperations
 
     @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) {
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererCompliancyCheck.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererCompliancyCheck.java
new file mode 100644 (file)
index 0000000..1fe514c
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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;
+    }
+}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubrendererImpl.java
new file mode 100644 (file)
index 0000000..ccdf7d3
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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();
+    }
+}