Path description YANG update
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / utils / ServiceDataUtils.java
1 /*
2  * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.servicehandler.utils;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import com.google.common.util.concurrent.ListeningExecutorService;
12 import com.google.common.util.concurrent.MoreExecutors;
13 import java.time.OffsetDateTime;
14 import java.time.ZoneOffset;
15 import java.time.format.DateTimeFormatter;
16 import java.util.Map;
17 import java.util.concurrent.Callable;
18 import java.util.concurrent.Executors;
19 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestInput;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestInputBuilder;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.ServicePathRpcResult;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.ServicePathRpcResultBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescription;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescriptionBuilder;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSp;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSpBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultSh;
29 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultShBuilder;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ServiceNotificationTypes;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeader;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeaderBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.RxDirection;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.RxDirectionKey;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.TxDirection;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.endpoint.TxDirectionKey;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.lgx.LgxBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.port.PortBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraintsBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.SoftConstraintsBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput.Option;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfo;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.feasibility.check.inputs.ServiceAEnd;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.feasibility.check.inputs.ServiceAEndBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.feasibility.check.inputs.ServiceZEnd;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.feasibility.check.inputs.ServiceZEndBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection;
69 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirection;
71 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.PceMetric;
73 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx;
74 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.ServicePathNotificationTypes;
75 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.handler.header.ServiceHandlerHeaderBuilder;
76 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
77 import org.opendaylight.yangtools.yang.common.Uint32;
78 import org.opendaylight.yangtools.yang.common.Uint8;
79
80 public final class ServiceDataUtils {
81
82     public static ServiceCreateInput buildServiceCreateInput() {
83
84         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
85             .ServiceAEnd serviceAEnd = getServiceAEndBuild()
86             .build();
87         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
88             .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service
89             .create.input.ServiceZEndBuilder()
90             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
91             .setNodeId(new NodeIdType("XPONDER-3-2"))
92             .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
93             .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
94             .build();
95
96         ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
97             .setCommonId("commonId")
98             .setConnectionType(ConnectionType.Service)
99             .setCustomer("Customer")
100             .setServiceName("service 1")
101             .setServiceAEnd(serviceAEnd)
102             .setServiceZEnd(serviceZEnd)
103             .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
104                 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build());
105
106         return builtInput.build();
107     }
108
109     public static ServiceCreateInput buildServiceCreateInputWithHardConstraints() {
110
111         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
112                 .ServiceAEnd serviceAEnd = getServiceAEndBuild()
113                 .build();
114         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
115                 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service
116                 .create.input.ServiceZEndBuilder()
117                 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
118                 .setNodeId(new NodeIdType("XPONDER-3-2"))
119                 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
120                 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
121                 .build();
122
123         ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
124             .setCommonId("commonId")
125             .setConnectionType(ConnectionType.Service)
126             .setCustomer("Customer")
127             .setServiceName("service 1")
128             .setServiceAEnd(serviceAEnd)
129             .setServiceZEnd(serviceZEnd)
130             .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
131                 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build())
132             .setHardConstraints(new HardConstraintsBuilder().build());
133
134         return builtInput.build();
135     }
136
137     public static ServiceCreateInput buildServiceCreateInputWithSoftConstraints() {
138
139         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
140                 .ServiceAEnd serviceAEnd = getServiceAEndBuild()
141                 .build();
142         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
143                 .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service
144                 .create.input.ServiceZEndBuilder()
145                 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
146                 .setNodeId(new NodeIdType("XPONDER-3-2"))
147                 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
148                 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
149                 .build();
150
151         ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder()
152             .setCommonId("commonId")
153             .setConnectionType(ConnectionType.Service)
154             .setCustomer("Customer")
155             .setServiceName("service 1")
156             .setServiceAEnd(serviceAEnd)
157             .setServiceZEnd(serviceZEnd)
158             .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
159                 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").build())
160             .setSoftConstraints(new SoftConstraintsBuilder().build());
161
162         return builtInput.build();
163     }
164
165     public static PathComputationRequestInput createPceRequestInput(ServiceCreateInput input) {
166         ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
167         SdncRequestHeader serviceHandler = input.getSdncRequestHeader();
168         if (serviceHandler != null) {
169             serviceHandlerHeader.setRequestId(serviceHandler.getRequestId());
170         }
171         return new PathComputationRequestInputBuilder()
172             .setServiceName(input.getServiceName())
173             .setResourceReserve(true)
174             .setServiceHandlerHeader(serviceHandlerHeader.build())
175             .setHardConstraints(input.getHardConstraints())
176             .setSoftConstraints(input.getSoftConstraints())
177             .setPceRoutingMetric(PceMetric.TEMetric)
178             .setServiceAEnd(ModelMappingUtils.createServiceAEnd(input.getServiceAEnd()))
179             .setServiceZEnd(ModelMappingUtils.createServiceZEnd(input.getServiceZEnd()))
180             .build();
181     }
182
183     public static TempServiceCreateInput buildTempServiceCreateInput() {
184
185         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.create.input
186             .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp
187                 .service.create.input.ServiceAEndBuilder()
188             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
189             .setNodeId(new NodeIdType("XPONDER-1-2"))
190             .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
191             .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
192             .build();
193         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.create.input
194             .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp
195             .service.create.input.ServiceZEndBuilder()
196             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
197             .setNodeId(new NodeIdType("XPONDER-3-2"))
198             .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
199             .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
200             .build();
201
202         TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder()
203             .setCommonId("commonId")
204             .setConnectionType(ConnectionType.Service)
205             .setCustomer("Customer")
206             .setServiceAEnd(serviceAEnd)
207             .setServiceZEnd(serviceZEnd)
208             .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
209                 .setRpcAction(RpcActions.TempServiceCreate).setNotificationUrl("notification url").build());
210
211         return builtInput.build();
212     }
213
214     public static ServiceFeasibilityCheckInput buildServiceFeasibilityCheckInput() {
215
216         ServiceAEnd serviceAEnd = new ServiceAEndBuilder()
217                     .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
218                     .setNodeId(new NodeIdType("XPONDER-1-2"))
219                     .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
220                     .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection())).build();
221         ServiceZEnd serviceZEnd = new ServiceZEndBuilder()
222                     .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
223                     .setNodeId(new NodeIdType("XPONDER-3-2"))
224                     .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
225                     .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection())).build();
226
227         ServiceFeasibilityCheckInputBuilder builtInput = new ServiceFeasibilityCheckInputBuilder()
228             .setCommonId("commonId")
229             .setConnectionType(ConnectionType.Service)
230             .setCustomer("Customer")
231             .setServiceAEnd(serviceAEnd)
232             .setServiceZEnd(serviceZEnd)
233             .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request 1")
234                 .setRpcAction(RpcActions.ServiceFeasibilityCheck).setNotificationUrl("notification url").build());
235         return builtInput.build();
236     }
237
238     public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
239         .ServiceAEndBuilder getServiceAEndBuild() {
240         return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
241             .ServiceAEndBuilder()
242             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
243             .setNodeId(new NodeIdType("XPONDER-1-2"))
244             .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
245             .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()));
246     }
247
248     public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
249         .ServiceZEndBuilder getServiceZEndBuild() {
250         return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input
251             .ServiceZEndBuilder()
252             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
253             .setNodeId(new NodeIdType("XPONDER-1-2"))
254             .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
255             .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()));
256     }
257
258     private static TxDirection getTxDirection() {
259         return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service
260                 .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name")
261                         .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf")
262                         .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build())
263                         .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name")
264                                 .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build())
265                         .setIndex(Uint8.ZERO)
266                         .build();
267     }
268
269     private static RxDirection getRxDirection() {
270         return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service
271                 .endpoint.RxDirectionBuilder()
272                     .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
273                         .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
274                         .setPortSubSlot("port subslot").setPortType("port type").build())
275                     .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
276                         .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
277                         .setLgxPortShelf("lgx port shelf").build())
278                     .setIndex(Uint8.ZERO)
279                     .build();
280     }
281
282     public static ServiceDeleteInput buildServiceDeleteInput() {
283
284         ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder();
285         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
286         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
287         DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
288         deleteInputBldr.setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("service 1")
289             .setDueDate(datetime).setTailRetention(ServiceDeleteReqInfo.TailRetention.No).build());
290         SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
291             .setNotificationUrl("notification url")
292             .setRequestId("request 1")
293             .setRequestSystemId("request system 1")
294             .setRpcAction(RpcActions.ServiceDelete);
295         deleteInputBldr.setSdncRequestHeader(sdncBuilder.build());
296         return deleteInputBldr.build();
297     }
298
299     public static TempServiceDeleteInput buildTempServiceDeleteInput() {
300         TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder()
301             .setCommonId("service 1");
302         return deleteInputBldr.build();
303     }
304
305     public static TempServiceDeleteInput buildTempServiceDeleteInput(String commonId) {
306         TempServiceDeleteInputBuilder deleteInputBldr = new TempServiceDeleteInputBuilder()
307             .setCommonId(commonId);
308         return deleteInputBldr.build();
309     }
310
311     public static ServiceRerouteInput buildServiceRerouteInput() {
312         ServiceRerouteInputBuilder builder = new ServiceRerouteInputBuilder()
313             .setServiceName("service 1");
314         return builder.build();
315     }
316
317     public static ServiceRestorationInput buildServiceRestorationInput() {
318         ServiceRestorationInputBuilder builder = new ServiceRestorationInputBuilder()
319             .setServiceName("service 1")
320             .setOption(Option.Permanent);
321         return builder.build();
322     }
323
324     public static ServiceReconfigureInput buildServiceReconfigureInput() {
325
326         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.reconfigure.input
327             .ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service
328                 .reconfigure.input.ServiceAEndBuilder()
329                 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
330                 .setNodeId(new NodeIdType("XPONDER-1-2"))
331                 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
332                 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
333                 .build();
334         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.reconfigure.input
335             .ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service
336                 .reconfigure.input.ServiceZEndBuilder()
337                 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
338                 .setNodeId(new NodeIdType("XPONDER-3-2"))
339                 .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
340                 .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()))
341                 .build();
342
343         ServiceReconfigureInputBuilder builtInput = new ServiceReconfigureInputBuilder()
344             .setCommonId("commonId")
345             .setConnectionType(ConnectionType.Service)
346             .setCustomer("Customer")
347             .setServiceName("service 1")
348             .setServiceAEnd(serviceAEnd)
349             .setServiceZEnd(serviceZEnd);
350         return builtInput.build();
351     }
352
353     public static ServicePathRpcResult buildServicePathRpcResult() {
354         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
355         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
356         DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
357         ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
358         builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
359             .setPathDescription(createPathDescription(0,1, 0, 1))
360             .setServiceName("service 1")
361             .setStatus(RpcStatusEx.Successful).setStatusMessage("success");
362         return builder.build();
363     }
364
365     public static ServicePathRpcResult buildServicePathRpcResult(
366             ServicePathNotificationTypes servicePathNotificationTypes, String serviceName, RpcStatusEx rpcStatusEx,
367             String message, Boolean pathDescription) {
368         ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
369         builder.setNotificationType(servicePathNotificationTypes)
370                 .setServiceName(serviceName)
371                 .setStatus(rpcStatusEx).setStatusMessage(message);
372         if (pathDescription) {
373             builder.setPathDescription(createPathDescription(0L, 5L, 0L, 5L));
374         }
375         return builder.build();
376     }
377
378     public static ServicePathRpcResult buildFailedPceServicePathRpcResult() {
379         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
380         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
381         DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
382         ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
383         builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
384                 .setPathDescription(createPathDescription(0, 1, 0, 1)).setServiceName("service 1")
385                 .setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
386         return builder.build();
387     }
388
389     public static ServicePathRpcResult buildFailedServicePathRpcResult() {
390         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
391         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
392         DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
393         ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
394         builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
395             .setPathDescription(createPathDescription(0,1, 0, 1))
396             .setServiceName("service 1")
397                 .setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
398         return builder.build();
399     }
400
401     public static RendererRpcResultSp buildRendererRpcResultSp() {
402         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
403         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
404         DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
405         RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
406         builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
407                 .setServiceName("service 1").setStatus(RpcStatusEx.Successful).setStatusMessage("success");
408         return builder.build();
409     }
410
411     public static RendererRpcResultSp buildRendererRpcResultSp(
412             ServicePathNotificationTypes servicePathNotificationTypes,
413             String serviceName, RpcStatusEx rpcStatusEx, String message) {
414         RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
415         builder.setNotificationType(servicePathNotificationTypes).setServiceName(serviceName)
416                 .setStatus(rpcStatusEx).setStatusMessage(message);
417         return builder.build();
418     }
419
420     public static ServiceRpcResultSh buildServiceRpcResultSh(
421             ServiceNotificationTypes serviceNotificationTypes,
422             String serviceName,
423             org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx
424                 rpcStatusEx,
425             String message) {
426         ServiceRpcResultShBuilder builder = new ServiceRpcResultShBuilder();
427         builder.setNotificationType(serviceNotificationTypes).setServiceName(serviceName)
428                 .setStatus(rpcStatusEx).setStatusMessage(message);
429         return builder.build();
430     }
431
432     public static RendererRpcResultSp buildFailedRendererRpcResultSp() {
433         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
434         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
435         DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
436         RendererRpcResultSpBuilder builder = new RendererRpcResultSpBuilder();
437         builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
438                 .setServiceName("service 1").setStatus(RpcStatusEx.Failed).setStatusMessage("failed");
439         return builder.build();
440     }
441
442     public static PathDescription createPathDescription(long azRate, long azWaveLength, long zaRate,
443         long zaWaveLength) {
444         AToZDirection atozDirection = new AToZDirectionBuilder()
445             .setRate(Uint32.valueOf(azRate))
446             .setAToZWavelengthNumber(Uint32.valueOf(azWaveLength))
447             .build();
448         ZToADirection ztoaDirection = new ZToADirectionBuilder()
449             .setRate(Uint32.valueOf(zaRate))
450             .setZToAWavelengthNumber(Uint32.valueOf(zaWaveLength))
451             .build();
452         PathDescription pathDescription = new PathDescriptionBuilder()
453             .setAToZDirection(atozDirection)
454             .setZToADirection(ztoaDirection)
455             .build();
456         return pathDescription;
457     }
458
459     public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.reconfigure.input
460         .ServiceAEndBuilder getServiceAEndBuildReconfigure() {
461         return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.reconfigure.input
462             .ServiceAEndBuilder()
463             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
464             .setNodeId(new NodeIdType("XPONDER-1-2"))
465             .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
466             .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()));
467     }
468
469     public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.reconfigure.input
470         .ServiceZEndBuilder getServiceZEndBuildReconfigure() {
471         return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.reconfigure.input
472             .ServiceZEndBuilder()
473             .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
474             .setNodeId(new NodeIdType("XPONDER-1-2"))
475             .setTxDirection(Map.of(new TxDirectionKey(getTxDirection().key()),getTxDirection()))
476             .setRxDirection(Map.of(new RxDirectionKey(getRxDirection().key()), getRxDirection()));
477     }
478
479     public static <T> ListenableFuture<T> returnFuture(T output) {
480         final ListeningExecutorService executor =
481                 MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1));
482         return executor.submit(new Callable<T>() {
483             @Override
484             public T call() throws Exception {
485                 return output;
486             }
487         });
488     }
489
490     private ServiceDataUtils() {
491     }
492
493 }