f7c40796ced1d097dc18639744ec6c752391857a
[transportpce.git] / tests / SH_stubs.diff
1 diff --git a/servicehandler/pom.xml b/servicehandler/pom.xml
2 index 43085f6..8a9699a 100644
3 --- a/servicehandler/pom.xml
4 +++ b/servicehandler/pom.xml
5 @@ -67,6 +67,11 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
6        <artifactId>transportpce-pce</artifactId>
7        <version>${project.version}</version>
8      </dependency>
9 +    <dependency>
10 +      <groupId>${project.groupId}</groupId>
11 +      <artifactId>transportpce-stubrenderer</artifactId>
12 +      <version>${project.version}</version>
13 +    </dependency>
14  
15      <!-- Testing Dependencies -->
16      <dependency>
17 diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java
18 index 6e385ca..d13f52b 100644
19 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java
20 +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java
21 @@ -7,8 +7,6 @@
22   */
23  package org.opendaylight.transportpce.servicehandler;
24  
25 -import java.util.ArrayList;
26 -import java.util.List;
27  import java.util.concurrent.Future;
28  import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
29  import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceAEnd;
30 @@ -18,8 +16,6 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev17
31  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
32  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
33  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.response.parameters.ResponseParametersBuilder;
34 -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.Topology;
35 -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder;
36  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.LifecycleState;
37  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
38  import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
39 @@ -31,12 +27,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
40  import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
41  import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
42  import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
43 -import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ;
44 -import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZBuilder;
45 -import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZKey;
46 -import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToA;
47 -import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToABuilder;
48 -import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToAKey;
49  import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraintsBuilder;
50  import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraintsBuilder;
51  import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirection;
52 @@ -238,42 +228,6 @@ public final class ModelMappingUtils {
53                  .setSoftConstraints(serviceReconfigureInput.getSoftConstraints())
54                  .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend);
55          }
56 -
57 -        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response
58 -                .parameters.sp.ResponseParameters responseParameters = output.getResponseParameters();
59 -        if (responseParameters != null) {
60 -            // service.setPceMetric(responseParameters.getPceMetric());
61 -            org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426
62 -                .response.parameters.sp.response.parameters.PathDescription pathDescription =
63 -                responseParameters.getPathDescription();
64 -            if (pathDescription != null) {
65 -                List<AToZ> atozList = new ArrayList<>();
66 -                List<ZToA> ztoaList = new ArrayList<>();
67 -
68 -                for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
69 -                    .path.description.atoz.direction.AToZ tmp : pathDescription.getAToZDirection().getAToZ()) {
70 -
71 -                    AToZKey key = new AToZKey(tmp.getKey().getId());
72 -                    AToZ atoz = new AToZBuilder().setId(tmp.getId()).setKey(key)
73 -                            // .setResource(tmp.getResource())
74 -                            .build();
75 -                    atozList.add(atoz);
76 -                }
77 -
78 -                for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426
79 -                        .path.description.ztoa.direction.ZToA
80 -                        tmp : pathDescription.getZToADirection().getZToA()) {
81 -                    ZToAKey key = new ZToAKey(tmp.getKey().getId());
82 -                    ZToA ztoa = new ZToABuilder().setId(tmp.getId()).setKey(key)
83 -                            // .setResource(tmp.getResource())
84 -                            .build();
85 -                    ztoaList.add(ztoa);
86 -                }
87 -
88 -                Topology topology = new TopologyBuilder().setAToZ(atozList).setZToA(ztoaList).build();
89 -                service.setTopology(topology);
90 -            }
91 -        }
92          return service.build();
93      }
94  
95 diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
96 index 8ad06b2..139b68d 100644
97 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
98 +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
99 @@ -27,6 +27,7 @@ import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOper
100  import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
101  import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
102  import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerCompliancyCheck;
103 +import org.opendaylight.transportpce.stubrenderer.SendingRendererRPCs;
104  import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
105  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
106  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
107 @@ -89,6 +90,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
108      private ServiceDataStoreOperations serviceDataStoreOperations;
109      private RendererServiceOperations rendererServiceOperations;
110      private PCEServiceWrapper pceServiceWrapper;
111 +    private SendingRendererRPCs stubrendererService;
112  
113      //TODO: remove private request fields as they are in global scope
114  
115 @@ -145,8 +147,12 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
116  
117          ServiceImplementationRequestInput serviceImplementationRequest =
118                  ModelMappingUtils.createServiceImplementationRequest(input, pceResponse);
119 +//        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
120 +//            .ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
121 +//            .serviceImplementation(serviceImplementationRequest);
122 +        this.stubrendererService = new SendingRendererRPCs();
123          org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
124 -            .ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.rendererServiceOperations
125 +        .ServiceImplementationRequestOutput serviceImplementationRequestOutput = this.stubrendererService
126              .serviceImplementation(serviceImplementationRequest);
127          if (ResponseCodes.RESPONSE_OK
128                  .equals(serviceImplementationRequestOutput.getConfigurationResponseCommon().getResponseCode())) {
129 @@ -215,9 +221,11 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
130          LOG.debug("Service '{}' present in datastore !", serviceName);
131          org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput
132                  serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(input);
133 +//        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
134 +//            .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
135 +        this.stubrendererService = new SendingRendererRPCs();
136          org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
137 -            .ServiceDeleteOutput output = this.rendererServiceOperations.serviceDelete(serviceDeleteInput);
138 -
139 +            .ServiceDeleteOutput output = this.stubrendererService.serviceDelete(serviceDeleteInput);
140          if (!ResponseCodes.RESPONSE_OK
141                  .equals(output.getConfigurationResponseCommon().getResponseCode())) {
142              message = "Service delete failed!";
143 @@ -320,13 +328,14 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
144                      .setStatusMessage("Success");
145                  return RpcResultBuilder.success(output).buildFuture();
146              }
147 -        } catch (InterruptedException | ExecutionException e) {
148 +        } catch (InterruptedException | ExecutionException | NullPointerException e) {
149              LOG.info("Exception caught" , e);
150          }
151          ServiceRerouteOutputBuilder output = new ServiceRerouteOutputBuilder()
152              .setHardConstraints(null).setSoftConstraints(null).setStatus(RpcStatus.Failed).setStatusMessage("Failure");
153  
154          return RpcResultBuilder.success(output).buildFuture();
155 +        // return null;
156      }
157  
158      @Override
159 diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubRendererServiceOperations.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubRendererServiceOperations.java
160 index 6db468c..76e4a26 100644
161 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubRendererServiceOperations.java
162 +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/stub/StubRendererServiceOperations.java
163 @@ -9,13 +9,8 @@ package org.opendaylight.transportpce.servicehandler.stub;
164  
165  import java.util.concurrent.ExecutionException;
166  import java.util.concurrent.Future;
167 -
168  import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
169  import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
170 -import org.opendaylight.transportpce.servicehandler.mappers.ServiceDeleteInputConverter;
171 -import org.opendaylight.transportpce.servicehandler.mappers.ServiceDeleteOutputConverter;
172 -import org.opendaylight.transportpce.servicehandler.mappers.ServiceImplementationRequestInputConverter;
173 -import org.opendaylight.transportpce.servicehandler.mappers.ServiceImplementationRequestOutputConverter;
174  import org.opendaylight.transportpce.stubrenderer.impl.StubrendererImpl;
175  import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput;
176  import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput;
177 @@ -30,16 +25,15 @@ public class StubRendererServiceOperations implements RendererServiceOperations
178      private StubrendererImpl stubrenderer;
179  
180      public StubRendererServiceOperations(NotificationPublishService notificationPublishService) {
181 -        this.stubrenderer = new StubrendererImpl(notificationPublishService);
182 +        this.stubrenderer = new StubrendererImpl();
183      }
184  
185      @Override
186      public ServiceImplementationRequestOutput serviceImplementation(ServiceImplementationRequestInput input) {
187 -        Future<RpcResult<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426
188 -            .ServiceImplementationRequestOutput>> rpcResultFuture = this.stubrenderer
189 -                .serviceImplementationRequest(ServiceImplementationRequestInputConverter.getStub(input));
190 +        Future<RpcResult<ServiceImplementationRequestOutput>> rpcResultFuture = this.stubrenderer
191 +                .serviceImplementationRequest(input);
192          try {
193 -            return ServiceImplementationRequestOutputConverter.getConcrete(rpcResultFuture.get().getResult());
194 +            return rpcResultFuture.get().getResult();
195          } catch (InterruptedException e) {
196              LOG.error("RPC serviceImplementation failed !",e);
197          } catch (ExecutionException e) {
198 @@ -50,11 +44,10 @@ public class StubRendererServiceOperations implements RendererServiceOperations
199  
200      @Override
201      public ServiceDeleteOutput serviceDelete(ServiceDeleteInput input) {
202 -        Future<RpcResult<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426
203 -            .ServiceDeleteOutput>> rpcResultFuture = this.stubrenderer
204 -                .serviceDelete(ServiceDeleteInputConverter.getStub(input));
205 +        Future<RpcResult<ServiceDeleteOutput>> rpcResultFuture = this.stubrenderer
206 +                .serviceDelete(input);
207          try {
208 -            return ServiceDeleteOutputConverter.getConcrete(rpcResultFuture.get().getResult());
209 +            return rpcResultFuture.get().getResult();
210          } catch (InterruptedException e) {
211              LOG.error("RPC serviceDelete failed !",e);
212          } catch (ExecutionException e) {
213 diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java
214 index cdcdc0e..7c7a825 100644
215 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java
216 +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/SendingRendererRPCs.java
217 @@ -8,16 +8,18 @@
218  
219  package org.opendaylight.transportpce.stubrenderer;
220  
221 -import com.google.common.util.concurrent.ListenableFuture;
222 -import com.google.common.util.concurrent.ListeningExecutorService;
223 -
224  import java.util.ArrayList;
225  import java.util.List;
226 -import java.util.concurrent.Callable;
227 -
228 +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
229  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder;
230  import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ;
231  import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToA;
232 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput;
233 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput;
234 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutputBuilder;
235 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
236 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput;
237 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder;
238  import org.slf4j.Logger;
239  import org.slf4j.LoggerFactory;
240  
241 @@ -41,73 +43,78 @@ public class SendingRendererRPCs {
242      private List<AToZ> atoz;
243      private List<ZToA> ztoa;
244      private String error;
245 -    private final ListeningExecutorService executor;
246  
247 -    public SendingRendererRPCs(ListeningExecutorService executor) {
248 -        success = true;
249 +    public SendingRendererRPCs() {
250 +        this.success = true;
251          setTopology(null);
252 -        this.executor = executor;
253          setError("");
254      }
255  
256      private void buildAtoZ() {
257 -        atoz = new ArrayList<AToZ>();
258 +        this.atoz = new ArrayList<AToZ>();
259      }
260  
261      private void buildZtoA() {
262 -        ztoa = new ArrayList<ZToA>();
263 +        this.ztoa = new ArrayList<ZToA>();
264      }
265  
266 -    public ListenableFuture<Boolean> serviceDelete() {
267 +    public ServiceDeleteOutput serviceDelete(ServiceDeleteInput input) {
268 +        String message = "Service deleted !";
269 +        String responseCode = "200";
270          LOG.info("ServiceDelete request ...");
271 -        success = false;
272 -        return executor.submit(new Callable<Boolean>() {
273 -            @Override
274 -            public Boolean call() throws Exception {
275 -                Boolean output = true;
276 -                LOG.info("Wait for 10s til beginning the Renderer serviceDelete request");
277 -                try {
278 -                    Thread.sleep(10000); //sleep for 10s
279 -                } catch (InterruptedException e) {
280 -                    output = false;
281 -                    LOG.error("Thread.sleep failed : {}", e.toString());
282 -                }
283 -                buildAtoZ();
284 -                buildZtoA();
285 -                success = true;
286 -                return output;
287 -            }
288 -        });
289 +        LOG.info("Wait for 10s til beginning the Renderer serviceDelete request");
290 +        try {
291 +            Thread.sleep(1000); //sleep for 10s
292 +        } catch (InterruptedException e) {
293 +            message = "deleting service failed !";
294 +            LOG.error(message);
295 +            responseCode = "500";
296 +            setError(message);
297 +        }
298 +        ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
299 +                .setAckFinalIndicator("yes")
300 +                .setRequestId(input.getServiceHandlerHeader().getRequestId())
301 +                .setResponseCode(responseCode)
302 +                .setResponseMessage(message);
303 +        ServiceDeleteOutput output =  new ServiceDeleteOutputBuilder()
304 +                .setConfigurationResponseCommon(configurationResponseCommon.build())
305 +                .build();
306 +        return output;
307      }
308  
309 -    public ListenableFuture<Boolean> serviceImplementation() {
310 +    public ServiceImplementationRequestOutput serviceImplementation(ServiceImplementationRequestInput input) {
311 +        String message = "Service implemented !";
312 +        String responseCode = "200";
313 +        setSuccess(true);
314          LOG.info("serviceImplementation request ...");
315 -        success = false;
316 -        return executor.submit(new Callable<Boolean>() {
317 -            @Override
318 -            public Boolean call() throws Exception {
319 -                Boolean output = true;
320 -                LOG.info("Wait for 10s til beginning the Renderer serviceDelete request");
321 -                try {
322 -                    Thread.sleep(10000); //sleep for 10s
323 -                } catch (InterruptedException e) {
324 -                    output = false;
325 -                    LOG.error("Thread.sleep failed : {}", e.toString());
326 -                }
327 -                buildAtoZ();
328 -                buildZtoA();
329 -                setTopology(new TopologyBuilder()
330 -                        .setAToZ(atoz)
331 -                        .setZToA(ztoa));
332 -                output = true;
333 -                success = true;
334 -                return output;
335 -            }
336 -        });
337 +        LOG.info("Wait for 10s til beginning the Renderer serviceDelete request");
338 +        try {
339 +            Thread.sleep(2000); //sleep for 1s
340 +        } catch (InterruptedException e) {
341 +            message = "implementing service failed !";
342 +            LOG.error(message);
343 +            setError(message);
344 +            responseCode = "500";
345 +            setSuccess(false);
346 +        }
347 +        buildAtoZ();
348 +        buildZtoA();
349 +        setTopology(new TopologyBuilder()
350 +                .setAToZ(SendingRendererRPCs.this.atoz)
351 +                .setZToA(SendingRendererRPCs.this.ztoa));
352 +        ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
353 +                .setAckFinalIndicator("yes")
354 +                .setRequestId(input.getServiceHandlerHeader().getRequestId())
355 +                .setResponseCode(responseCode)
356 +                .setResponseMessage(message);
357 +        ServiceImplementationRequestOutput output =  new ServiceImplementationRequestOutputBuilder()
358 +                .setConfigurationResponseCommon(configurationResponseCommon.build())
359 +                .build();
360 +        return output;
361      }
362  
363      public Boolean getSuccess() {
364 -        return success;
365 +        return this.success;
366      }
367  
368      public void setSuccess(Boolean success) {
369 @@ -115,7 +122,7 @@ public class SendingRendererRPCs {
370      }
371  
372      public TopologyBuilder getTopology() {
373 -        return topology;
374 +        return this.topology;
375      }
376  
377      public void setTopology(TopologyBuilder topo) {
378 @@ -123,7 +130,7 @@ public class SendingRendererRPCs {
379      }
380  
381      public String getError() {
382 -        return error;
383 +        return this.error;
384      }
385  
386      public void setError(String error) {
387 diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java
388 index 23ae976..4187f96 100644
389 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java
390 +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java
391 @@ -9,33 +9,21 @@
392  
393  package org.opendaylight.transportpce.stubrenderer.impl;
394  
395 -import com.google.common.util.concurrent.FutureCallback;
396 -import com.google.common.util.concurrent.Futures;
397 -import com.google.common.util.concurrent.ListenableFuture;
398 -import com.google.common.util.concurrent.ListeningExecutorService;
399 -import com.google.common.util.concurrent.MoreExecutors;
400 -
401 -import java.util.concurrent.Executors;
402  import java.util.concurrent.Future;
403 -
404 -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
405  import org.opendaylight.transportpce.stubrenderer.SendingRendererRPCs;
406  import org.opendaylight.transportpce.stubrenderer.StubrendererCompliancyCheck;
407 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInput;
408 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutput;
409 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutputBuilder;
410 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInput;
411 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput;
412 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutputBuilder;
413 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceRpcResultSp;
414 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceRpcResultSpBuilder;
415 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService;
416 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.rpc.result.sp.PathTopology;
417 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.rpc.result.sp.PathTopologyBuilder;
418  import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
419 -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder;
420 -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx;
421 -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes;
422 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveInput;
423 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveOutput;
424 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestInput;
425 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestOutput;
426 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput;
427 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput;
428 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutputBuilder;
429 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
430 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput;
431 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder;
432 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService;
433  import org.opendaylight.yangtools.yang.common.RpcResult;
434  import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
435  import org.slf4j.Logger;
436 @@ -48,21 +36,12 @@ import org.slf4j.LoggerFactory;
437   * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
438   *
439   */
440 -public class StubrendererImpl implements StubrendererService {
441 +public class StubrendererImpl implements TransportpceServicepathService {
442      /** Logging. */
443      private static final Logger LOG = LoggerFactory.getLogger(StubrendererImpl.class);
444 -    /** send notification. */
445 -    private NotificationPublishService notificationPublishService;
446 -    private ServiceRpcResultSp notification;
447 -    private final ListeningExecutorService executor = MoreExecutors
448 -            .listeningDecorator(Executors.newFixedThreadPool(10));
449      /** check service sdnc-request-header compliancy. */
450      private StubrendererCompliancyCheck compliancyCheck;
451  
452 -    public StubrendererImpl(NotificationPublishService notificationPublishService) {
453 -        this.notificationPublishService = notificationPublishService;
454 -    }
455 -
456      @Override
457      public Future<RpcResult<ServiceImplementationRequestOutput>> serviceImplementationRequest(
458              ServiceImplementationRequestInput input) {
459 @@ -71,121 +50,37 @@ public class StubrendererImpl implements StubrendererService {
460          String message = "";
461          ConfigurationResponseCommonBuilder configurationResponseCommon = null;
462  
463 -        compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader());
464 -        if (compliancyCheck.check(false, true)) {
465 +        this.compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader());
466 +        if (this.compliancyCheck.check(false, true)) {
467              LOG.info("Service compliant !");
468              /**
469               * If compliant, service-request parameters are verified in order to
470               * check if there is no missing parameter that prevents calculating
471               * a path and implement a service.
472               */
473 -
474 -            notification = new ServiceRpcResultSpBuilder()
475 -                    .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
476 -                    .setServiceName(input.getServiceName())
477 -                    .setStatus(RpcStatusEx.Pending)
478 -                    .setStatusMessage("Service compliant, submitting serviceImplementation Request ...")
479 -                    .build();
480 -            try {
481 -                notificationPublishService.putNotification(notification);
482 -            } catch (InterruptedException e) {
483 -                LOG.info("notification offer rejected : {}", e);
484 +            SendingRendererRPCs sendingRenderer = new SendingRendererRPCs();
485 +            sendingRenderer.serviceImplementation(input);
486 +            if (sendingRenderer.getSuccess()) {
487 +                message = "Service implemented !";
488 +                LOG.info(message);
489 +                responseCode = "200";
490 +            } else {
491 +                message = "Service implementation failed : " + sendingRenderer.getError();
492 +                LOG.error(message);
493 +                responseCode = "500";
494              }
495 -
496 -            SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(executor);
497 -            FutureCallback<Boolean> rendererCallback =
498 -                    new FutureCallback<Boolean>() {
499 -                String message = "";
500 -                ServiceRpcResultSp notification = null;
501 -
502 -                @Override
503 -                public void onFailure(Throwable arg0) {
504 -                    LOG.error("Failure message : {}", arg0.toString());
505 -                    LOG.error("Service implementation failed !");
506 -                    notification = new ServiceRpcResultSpBuilder()
507 -                            .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
508 -                            .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
509 -                            .setStatusMessage("PCR Request failed  : {}" + arg0.getMessage()).build();
510 -                    try {
511 -                        notificationPublishService.putNotification(notification);
512 -                    } catch (InterruptedException e) {
513 -                        LOG.info("notification offer rejected : {}", e);
514 -                    }
515 -                }
516 -
517 -                @Override
518 -                public void onSuccess(Boolean response) {
519 -                    LOG.info("response : {}", response);
520 -                    if (response) {
521 -                        message = "Service implemented !";
522 -                        TopologyBuilder topo = sendingRenderer.getTopology();
523 -                        ServiceRpcResultSpBuilder tmp = new ServiceRpcResultSpBuilder()
524 -                                .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
525 -                                .setServiceName(input.getServiceName())
526 -                                .setStatus(RpcStatusEx.Successful)
527 -                                .setStatusMessage(message);
528 -                        if (topo != null) {
529 -                            PathTopology value = new PathTopologyBuilder()
530 -                                    .setAToZ(topo.getAToZ())
531 -                                    .setZToA(topo.getZToA())
532 -                                    .build();
533 -                            tmp.setPathTopology(value);
534 -                        }
535 -                        notification = tmp.build();
536 -                    } else {
537 -                        message = "Service implementation failed : " + sendingRenderer.getError();
538 -                        notification = new ServiceRpcResultSpBuilder()
539 -                                .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
540 -                                .setServiceName("")
541 -                                .setStatus(RpcStatusEx.Failed).setStatusMessage(message)
542 -                                .build();
543 -                    }
544 -                    LOG.info(notification.toString());
545 -                    try {
546 -                        notificationPublishService.putNotification(notification);
547 -                    } catch (InterruptedException e) {
548 -                        LOG.info("notification offer rejected : {}", e);
549 -                    }
550 -                    LOG.info(message);
551 -                }
552 -            };
553 -            ListenableFuture<Boolean> renderer = sendingRenderer.serviceImplementation();
554 -            Futures.addCallback(renderer, rendererCallback, executor);
555 -            LOG.info("Service implmentation Request in progress ");
556 -            configurationResponseCommon = new ConfigurationResponseCommonBuilder()
557 -                    .setAckFinalIndicator("Yes")
558 -                    .setRequestId(input.getServiceHandlerHeader().getRequestId())
559 -                    .setResponseCode("200")
560 -                    .setResponseMessage("Service implementation Request in progress ");
561 -
562 -            ServiceImplementationRequestOutput output = new ServiceImplementationRequestOutputBuilder()
563 -                    .setConfigurationResponseCommon(configurationResponseCommon.build())
564 -                    .build();
565 -            return RpcResultBuilder.success(output).buildFuture();
566          } else {
567 -            message = compliancyCheck.getMessage();
568 +            message = "Service not compliant";
569              responseCode = "500";
570 -            LOG.info("Service not compliant caused by : {}", message);
571 -            notification = new ServiceRpcResultSpBuilder()
572 -                    .setNotificationType(ServicePathNotificationTypes.ServiceDelete)
573 -                    .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
574 -                    .setStatusMessage("Service not compliant caused by : " + message)
575 -                    .build();
576 -            try {
577 -                notificationPublishService.putNotification(notification);
578 -            } catch (InterruptedException e) {
579 -                LOG.info("notification offer rejected : {}", e);
580 -            }
581          }
582          configurationResponseCommon = new ConfigurationResponseCommonBuilder()
583 -                .setAckFinalIndicator("yes")
584 -                .setRequestId(input.getServiceHandlerHeader().getRequestId())
585 -                .setResponseCode(responseCode)
586 -                .setResponseMessage(message);
587 +            .setAckFinalIndicator("yes")
588 +            .setRequestId(input.getServiceHandlerHeader().getRequestId())
589 +            .setResponseCode(responseCode)
590 +            .setResponseMessage(message);
591          ServiceImplementationRequestOutput output = new ServiceImplementationRequestOutputBuilder()
592 -                .setConfigurationResponseCommon(configurationResponseCommon.build())
593 -                .build();
594 -
595 +            .setConfigurationResponseCommon(configurationResponseCommon.build())
596 +            .build();
597          return RpcResultBuilder.success(output).buildFuture();
598      }
599  
600 @@ -195,108 +90,55 @@ public class StubrendererImpl implements StubrendererService {
601          LOG.info("RPC serviceDelete request received");
602          String responseCode = "";
603          ConfigurationResponseCommonBuilder configurationResponseCommon = null;
604 -        compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader());
605 -        if (compliancyCheck.check(false, true)) {
606 +        this.compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader());
607 +        if (this.compliancyCheck.check(false, true)) {
608              LOG.info("Service compliant !");
609              /**
610               * If compliant, service-request parameters are verified in order to
611               * check if there is no missing parameter that prevents calculating
612               * a path and implement a service.
613               */
614 -
615 -            notification = new ServiceRpcResultSpBuilder()
616 -                    .setNotificationType(ServicePathNotificationTypes.ServiceDelete)
617 -                    .setServiceName(input.getServiceName())
618 -                    .setStatus(RpcStatusEx.Pending)
619 -                    .setStatusMessage("Service compliant, submitting serviceDelete Request ...")
620 -                    .build();
621 -            try {
622 -                notificationPublishService.putNotification(notification);
623 -            } catch (InterruptedException e) {
624 -                LOG.info("notification offer rejected : {}", e);
625 +            SendingRendererRPCs sendingRenderer = new SendingRendererRPCs();
626 +            sendingRenderer.serviceDelete(input);
627 +            if (sendingRenderer.getSuccess()) {
628 +                message = "Service deleted !";
629 +                responseCode = "200";
630 +                LOG.info(message);
631 +            } else {
632 +                message = "Service implementation failed : " + sendingRenderer.getError();
633 +                LOG.error(message);
634 +                responseCode = "500";
635              }
636 -            SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(executor);
637 -            FutureCallback<Boolean> rendererCallback = new FutureCallback<Boolean>() {
638 -                String message = "";
639 -                ServiceRpcResultSp notification = null;
640 -
641 -                @Override
642 -                public void onFailure(Throwable arg0) {
643 -                    LOG.error("Failure message : {}", arg0.toString());
644 -                    LOG.error("Service delete failed !");
645 -                    notification = new ServiceRpcResultSpBuilder()
646 -                            .setNotificationType(ServicePathNotificationTypes.ServiceDelete)
647 -                            .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
648 -                            .setStatusMessage("PCR Request failed  : " + arg0.getMessage()).build();
649 -                    try {
650 -                        notificationPublishService.putNotification(notification);
651 -                    } catch (InterruptedException e) {
652 -                        LOG.info("notification offer rejected : {}", e);
653 -                    }
654 -                }
655 -
656 -                @Override
657 -                public void onSuccess(Boolean response) {
658 -                    LOG.info("response : {}", response);
659 -                    if (response) {
660 -                        message = "Service deleted !";
661 -                        notification = new ServiceRpcResultSpBuilder()
662 -                                .setNotificationType(ServicePathNotificationTypes.ServiceDelete)
663 -                                .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Successful)
664 -                                .setStatusMessage(message).build();
665 -                    } else {
666 -                        message = "Service delete failed : " + sendingRenderer.getError();
667 -                        notification = new ServiceRpcResultSpBuilder()
668 -                                .setNotificationType(ServicePathNotificationTypes.ServiceDelete)
669 -                                .setServiceName("")
670 -                                .setStatus(RpcStatusEx.Failed).setStatusMessage(message)
671 -                                .build();
672 -                    }
673 -                    LOG.info(notification.toString());
674 -                    try {
675 -                        notificationPublishService.putNotification(notification);
676 -                    } catch (InterruptedException e) {
677 -                        LOG.info("notification offer rejected : {}", e);
678 -                    }
679 -                    LOG.info(message);
680 -                }
681 -            };
682 -            ListenableFuture<Boolean> renderer = sendingRenderer.serviceDelete();
683 -            Futures.addCallback(renderer, rendererCallback, executor);
684 -            message = "Service delete Request in progress ...";
685 -            LOG.info(message);
686 -            configurationResponseCommon = new ConfigurationResponseCommonBuilder()
687 -                    .setAckFinalIndicator("Yes")
688 -                    .setRequestId(input.getServiceHandlerHeader().getRequestId())
689 -                    .setResponseCode("200")
690 -                    .setResponseMessage(message);
691 -            ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
692 -                    .setConfigurationResponseCommon(configurationResponseCommon.build())
693 -                    .build();
694 -            return RpcResultBuilder.success(output).buildFuture();
695          } else {
696 -            message = compliancyCheck.getMessage();
697 -            LOG.info("Service not compliant caused by : {}", message);
698 +            message = "Service not compliant";
699              responseCode = "500";
700 -            notification = new ServiceRpcResultSpBuilder()
701 -                    .setNotificationType(ServicePathNotificationTypes.ServiceDelete)
702 -                    .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed)
703 -                    .setStatusMessage("Service not compliant caused by : " + message)
704 -                    .build();
705 -            try {
706 -                notificationPublishService.putNotification(notification);
707 -            } catch (InterruptedException e) {
708 -                LOG.info("notification offer rejected : {}", e);
709 -            }
710          }
711          configurationResponseCommon = new ConfigurationResponseCommonBuilder()
712 -                .setAckFinalIndicator("yes")
713 -                .setRequestId(input.getServiceHandlerHeader().getRequestId())
714 -                .setResponseCode(responseCode)
715 -                .setResponseMessage(message);
716 +            .setAckFinalIndicator("yes")
717 +            .setRequestId(input.getServiceHandlerHeader().getRequestId())
718 +            .setResponseCode(responseCode)
719 +            .setResponseMessage(message);
720          ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
721 -                .setConfigurationResponseCommon(configurationResponseCommon.build())
722 -                .build();
723 +            .setConfigurationResponseCommon(configurationResponseCommon.build())
724 +            .build();
725          return RpcResultBuilder.success(output).buildFuture();
726      }
727 +
728 +    /* (non-Javadoc)
729 +     * @see org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService#cancelResourceReserve(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveInput)
730 +     */
731 +    @Override
732 +    public Future<RpcResult<CancelResourceReserveOutput>> cancelResourceReserve(CancelResourceReserveInput input) {
733 +        // TODO Auto-generated method stub
734 +        return null;
735 +    }
736 +
737 +    /* (non-Javadoc)
738 +     * @see org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService#pathComputationRequest(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestInput)
739 +     */
740 +    @Override
741 +    public Future<RpcResult<PathComputationRequestOutput>> pathComputationRequest(PathComputationRequestInput input) {
742 +        // TODO Auto-generated method stub
743 +        return null;
744 +    }
745  }
746 diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java
747 index 0beb087..92b20f5 100644
748 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java
749 +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererProvider.java
750 @@ -13,9 +13,7 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService
751  import org.opendaylight.controller.md.sal.binding.api.NotificationService;
752  import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
753  import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
754 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener;
755 -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService;
756 -import org.opendaylight.yangtools.concepts.ListenerRegistration;
757 +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService;
758  import org.slf4j.Logger;
759  import org.slf4j.LoggerFactory;
760  
761 @@ -27,17 +25,13 @@ import org.slf4j.LoggerFactory;
762  public class StubrendererProvider {
763      private static final Logger LOG = LoggerFactory.getLogger(StubrendererProvider.class);
764      private final RpcProviderRegistry rpcRegistry;
765 -    private final NotificationPublishService notificationPublishService;
766  
767 -
768 -    private BindingAwareBroker.RpcRegistration<StubrendererService> rpcRegistration;
769 -    private ListenerRegistration<StubrendererListener> stubRendererlistenerRegistration;
770 +    private BindingAwareBroker.RpcRegistration<TransportpceServicepathService> rpcRegistration;
771  
772      public StubrendererProvider(RpcProviderRegistry rpcProviderRegistry,
773              NotificationService notificationService,
774              NotificationPublishService notificationPublishService) {
775          this.rpcRegistry = rpcProviderRegistry;
776 -        this.notificationPublishService = notificationPublishService;
777      }
778  
779      /**
780 @@ -45,8 +39,8 @@ public class StubrendererProvider {
781       */
782      public void init() {
783          LOG.info("StubrendererProvider Session Initiated");
784 -        final StubrendererImpl consumer = new StubrendererImpl(this.notificationPublishService);
785 -        this.rpcRegistration = this.rpcRegistry.addRpcImplementation(StubrendererService.class, consumer);
786 +        final StubrendererImpl consumer = new StubrendererImpl();
787 +        this.rpcRegistration = this.rpcRegistry.addRpcImplementation(TransportpceServicepathService.class, consumer);
788      }
789  
790      /**