Refactor transportpce-routing-constraint model
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / ModelMappingUtilsTest.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;
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.Arrays;
17 import java.util.concurrent.CountDownLatch;
18 import java.util.concurrent.ExecutionException;
19 import java.util.concurrent.Executors;
20 import org.junit.After;
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.opendaylight.transportpce.common.ResponseCodes;
25 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
26 import org.opendaylight.transportpce.test.AbstractTest;
27 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestOutput;
28 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestOutputBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.configuration.response.common.ConfigurationResponseCommon;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.configuration.response.common.ConfigurationResponseCommonBuilder;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev190531.RpcStatus;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.constraints.co.routing.or.general.CoRoutingBuilder;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.HardConstraintsBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev190329.routing.constraints.SoftConstraintsBuilder;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInputBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateOutput;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInput;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInputBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteOutput;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInput;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInputBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckOutput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInputBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesKey;
59 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParameters;
62 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
65 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsKey;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
68 import org.opendaylight.yangtools.yang.common.RpcResult;
69 import org.opendaylight.yangtools.yang.common.Uint32;
70
71 public class ModelMappingUtilsTest extends AbstractTest {
72
73     private ListeningExecutorService executorService;
74     private CountDownLatch endSignal;
75     private static final int NUM_THREADS = 5;
76
77     @Before
78     public void setUp() {
79         executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
80         endSignal = new CountDownLatch(1);
81     }
82
83     @After
84     public void tearDown() {
85         executorService.shutdownNow();
86     }
87
88     private ServiceReconfigureInput buildServiceConfigurationInput() {
89         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
90         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
91         OffsetDateTime offsetDateTime2 = offsetDateTime.plusDays(10);
92         return new ServiceReconfigureInputBuilder().setNewServiceName("service 1")
93             .setServiceName("service 1").setCommonId("common id").setConnectionType(ConnectionType.Service)
94             .setCustomer("customer").setCustomerContact("customer contact").setDueDate(new DateAndTime(
95                     dtf.format(offsetDateTime)))
96             .setEndDate(new DateAndTime(dtf.format(offsetDateTime2)))
97             .setNcCode("nc node").setNciCode("nci node").setSecondaryNciCode("secondry").setOperatorContact("operator")
98             .setServiceAEnd(ServiceDataUtils.getServiceAEndBuildReconfigure().build())
99             .setServiceZEnd(ServiceDataUtils.getServiceZEndBuildReconfigure().build())
100             .setHardConstraints(new HardConstraintsBuilder()
101                         .setCoRoutingOrGeneral(new CoRoutingBuilder()
102                                 .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
103                                         .constrains.rev190329.constraints.co.routing.or.general.co.routing
104                                         .CoRoutingBuilder().setExistingService(
105                                         Arrays.asList("Some existing-service")).build())
106                                 .build())
107                         .setCustomerCode(Arrays.asList("Some customer-code"))
108                         .build())
109                 .setSoftConstraints(new SoftConstraintsBuilder()
110                         .setCoRoutingOrGeneral(new CoRoutingBuilder()
111                                 .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
112                                         .constrains.rev190329.constraints.co.routing.or.general.co.routing
113                                         .CoRoutingBuilder().setExistingService(
114                                         Arrays.asList("Some existing-service")).build())
115                                 .build())
116                         .setCustomerCode(Arrays.asList("Some customer-code"))
117                         .build())
118                 .build();
119     }
120
121     private PathComputationRequestOutput buildPathComputationOutput() {
122         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
123                 .setRequestId("request 1").setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO)
124                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("PCE calculation in progress").build();
125         ResponseParameters responseParameters = new ResponseParametersBuilder()
126             .setPathDescription(new PathDescriptionBuilder()
127                 .setAToZDirection(new AToZDirectionBuilder().setAToZWavelengthNumber(Uint32.valueOf(1))
128                     .setRate(Uint32.valueOf(1)).build())
129                 .setZToADirection(new ZToADirectionBuilder().setZToAWavelengthNumber(Uint32.valueOf(1))
130                     .setRate(Uint32.valueOf(1)).build()).build())
131             .build();
132         return new PathComputationRequestOutputBuilder().setConfigurationResponseCommon(configurationResponseCommon)
133             .setResponseParameters(responseParameters).build();
134     }
135
136     @Test
137     //TODO : is this unit test relevant ?
138     public void mappingServicesNullServiceCreateInput() {
139         Services services = ModelMappingUtils.mappingServices(null, null);
140         Assert.assertEquals(new ServicesBuilder().withKey(new ServicesKey("unknown")).build(), services);
141     }
142
143     @Test
144     public void mappingServiceNotNullServiceReconfigureInput() {
145         Services services = ModelMappingUtils.mappingServices(null, buildServiceConfigurationInput());
146         Assert.assertEquals("service 1", services.getServiceName());
147     }
148
149     @Test
150     public void mappingServiceValid() {
151         Services services = ModelMappingUtils.mappingServices(ServiceDataUtils.buildServiceCreateInput(),
152                 null);
153         Assert.assertEquals("service 1", services.getServiceName());
154     }
155
156     @Test
157     //TODO : is this unit test relevant ?
158     public void mappingServicesPathNullServiceCreateInput() {
159         ServicePaths services = ModelMappingUtils.mappingServicePaths(null, buildPathComputationOutput());
160         Assert.assertEquals(new ServicePathsBuilder().withKey(new ServicePathsKey("unknown")).build(), services);
161     }
162
163     @Test
164     public void mappingServicePathWithServiceInputWithHardConstraints() {
165         ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInputWithHardConstraints();
166         ServiceInput serviceInput = new ServiceInput(createInput);
167         ServicePaths services = ModelMappingUtils.mappingServicePaths(serviceInput, buildPathComputationOutput());
168         Assert.assertEquals(serviceInput.getServiceName(), services.getServicePathName());
169         Assert.assertNotNull(services.getHardConstraints());
170     }
171
172     @Test
173     public void mappingServicePathWithServiceInputWithSoftConstraints() {
174         ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInputWithSoftConstraints();
175         ServiceInput serviceInput = new ServiceInput(createInput);
176         ServicePaths services = ModelMappingUtils.mappingServicePaths(serviceInput, buildPathComputationOutput());
177         Assert.assertEquals(serviceInput.getServiceName(), services.getServicePathName());
178         Assert.assertNotNull(services.getSoftConstraints());
179     }
180
181     @Test
182     public void createServiceDeleteInputWithServiceRerouteInput() {
183         ServiceRerouteInput serviceRerouteinput = new ServiceRerouteInputBuilder().setServiceName("reroute").build();
184         Services services = new ServicesBuilder()
185                 .withKey(new ServicesKey("reroute"))
186                 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("123").build()).build();
187         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput
188             serviceDeleteInput =
189                     ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, services);
190         Assert.assertEquals("reroute", serviceDeleteInput.getServiceName());
191         Assert.assertEquals("123", serviceDeleteInput.getServiceHandlerHeader().getRequestId());
192     }
193
194     @Test
195     public void  createServiceDeleteInputWithServiceReconfigureInput() {
196         ServiceReconfigureInput serviceReconfigureInput = new  ServiceReconfigureInputBuilder()
197                 .setServiceName("reconf").build();
198         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput
199             serviceDeleteInput =
200                     ModelMappingUtils.createServiceDeleteInput(serviceReconfigureInput);
201         Assert.assertEquals("reconf", serviceDeleteInput.getServiceName());
202         Assert.assertEquals("reconf-reconfigure", serviceDeleteInput.getServiceHandlerHeader().getRequestId());
203     }
204
205     @Test
206     public void createServiceDeleteInputWithServiceRestorationInput() {
207         Services services = new ServicesBuilder()
208                 .withKey(new ServicesKey("rest"))
209                 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("123").build()).build();
210         ServiceRestorationInput serviceRestorationInput =
211             new ServiceRestorationInputBuilder().setServiceName("rest").build();
212         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput
213             serviceDeleteInput =
214                     ModelMappingUtils.createServiceDeleteInput(serviceRestorationInput, services);
215         Assert.assertEquals("rest", serviceDeleteInput.getServiceName());
216         Assert.assertEquals("123", serviceDeleteInput.getServiceHandlerHeader().getRequestId());
217     }
218
219     @Test
220     public void createDeleteServiceReplyWithServiceDeleteInputWithSdncHeader()
221         throws ExecutionException, InterruptedException  {
222         ServiceDeleteInput input = new ServiceDeleteInputBuilder()
223                 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("12").build()).build();
224         ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDeleteOutputF =
225             ModelMappingUtils.createDeleteServiceReply(input, "ack", "message", "200");
226         serviceDeleteOutputF.addListener(new Runnable() {
227             @Override
228             public void run() {
229                 endSignal.countDown();
230             }
231         }, executorService);
232
233         endSignal.await();
234         RpcResult<ServiceDeleteOutput> serviceDeleteOutput = serviceDeleteOutputF.get();
235         Assert.assertEquals("200", serviceDeleteOutput.getResult().getConfigurationResponseCommon().getResponseCode());
236         Assert.assertEquals(
237             "ack", serviceDeleteOutput.getResult().getConfigurationResponseCommon().getAckFinalIndicator());
238         Assert.assertEquals(
239             "message", serviceDeleteOutput.getResult().getConfigurationResponseCommon().getResponseMessage());
240         Assert.assertEquals("12", serviceDeleteOutput.getResult().getConfigurationResponseCommon().getRequestId());
241     }
242
243     @Test
244     public void createDeleteServiceReplyWithServiceDeleteInputWithoutSdncHeader()
245             throws ExecutionException, InterruptedException  {
246         ServiceDeleteInput input = new ServiceDeleteInputBuilder().build();
247         ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDeleteOutputF =
248             ModelMappingUtils.createDeleteServiceReply(input, "ack", "message", "200");
249         serviceDeleteOutputF.addListener(new Runnable() {
250             @Override
251             public void run() {
252                 endSignal.countDown();
253             }
254         }, executorService);
255
256         endSignal.await();
257         RpcResult<ServiceDeleteOutput> serviceDeleteOutput = serviceDeleteOutputF.get();
258         Assert.assertEquals("200", serviceDeleteOutput.getResult().getConfigurationResponseCommon().getResponseCode());
259         Assert.assertEquals(
260             "ack", serviceDeleteOutput.getResult().getConfigurationResponseCommon().getAckFinalIndicator());
261         Assert.assertEquals(
262             "message", serviceDeleteOutput.getResult().getConfigurationResponseCommon().getResponseMessage());
263         Assert.assertNull(serviceDeleteOutput.getResult().getConfigurationResponseCommon().getRequestId());
264     }
265
266     @Test
267     public void createCreateServiceReplyWithServiceCreatInputWithSdncRequestHeader()
268             throws ExecutionException, InterruptedException {
269         ServiceCreateInput input =
270             new ServiceCreateInputBuilder()
271                 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("12").build()).build();
272         ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreatOutputF =
273             ModelMappingUtils.createCreateServiceReply(input, "ack", "message", "200");
274         serviceCreatOutputF.addListener(new Runnable() {
275             @Override
276             public void run() {
277                 endSignal.countDown();
278             }
279         }, executorService);
280
281         endSignal.await();
282         RpcResult<ServiceCreateOutput> serviceCreatOutput = serviceCreatOutputF.get();
283         Assert.assertEquals("200", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseCode());
284         Assert.assertEquals(
285             "ack", serviceCreatOutput.getResult().getConfigurationResponseCommon().getAckFinalIndicator());
286         Assert.assertEquals(
287             "message", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseMessage());
288         Assert.assertEquals("12", serviceCreatOutput.getResult().getConfigurationResponseCommon().getRequestId());
289     }
290
291     @Test
292     public void createCreateServiceReplyWithServiceCreatInputWithoutSdncRequestHeader()
293         throws ExecutionException, InterruptedException {
294         ServiceCreateInput input = new ServiceCreateInputBuilder().build();
295         ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreatOutputF =
296             ModelMappingUtils.createCreateServiceReply(input, "ack", "message", "200");
297         serviceCreatOutputF.addListener(new Runnable() {
298             @Override
299             public void run() {
300                 endSignal.countDown();
301             }
302         }, executorService);
303
304         endSignal.await();
305         RpcResult<ServiceCreateOutput> serviceCreatOutput = serviceCreatOutputF.get();
306         Assert.assertEquals("200", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseCode());
307         Assert.assertEquals(
308             "ack", serviceCreatOutput.getResult().getConfigurationResponseCommon().getAckFinalIndicator());
309         Assert.assertEquals(
310             "message", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseMessage());
311         Assert.assertNull(serviceCreatOutput.getResult().getConfigurationResponseCommon().getRequestId());
312     }
313
314     @Test
315     public void createCreateServiceReplyWithTempServiceCreatInputWithSdncRequestHeader()
316         throws ExecutionException, InterruptedException {
317         TempServiceCreateInput input =
318             new TempServiceCreateInputBuilder()
319                 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("12").build()).build();
320         ListenableFuture<RpcResult<TempServiceCreateOutput>> serviceCreatOutputF =
321             ModelMappingUtils.createCreateServiceReply(input, "ack", "message", "200");
322         serviceCreatOutputF.addListener(new Runnable() {
323             @Override
324             public void run() {
325                 endSignal.countDown();
326             }
327         }, executorService);
328
329         endSignal.await();
330         RpcResult<TempServiceCreateOutput> serviceCreatOutput = serviceCreatOutputF.get();
331         Assert.assertEquals("200", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseCode());
332         Assert.assertEquals(
333             "ack", serviceCreatOutput.getResult().getConfigurationResponseCommon().getAckFinalIndicator());
334         Assert.assertEquals(
335             "message", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseMessage());
336         Assert.assertEquals("12", serviceCreatOutput.getResult().getConfigurationResponseCommon().getRequestId());
337     }
338
339     @Test
340     public void createCreateServiceReplyWithTempServiceCreatInputWithoutSdncRequestHeader()
341         throws ExecutionException, InterruptedException {
342         TempServiceCreateInput input = new TempServiceCreateInputBuilder().build();
343         ListenableFuture<RpcResult<TempServiceCreateOutput>> serviceCreatOutputF =
344             ModelMappingUtils.createCreateServiceReply(input, "ack", "message", "200");
345         serviceCreatOutputF.addListener(new Runnable() {
346             @Override
347             public void run() {
348                 endSignal.countDown();
349             }
350         }, executorService);
351
352         endSignal.await();
353         RpcResult<TempServiceCreateOutput> serviceCreatOutput = serviceCreatOutputF.get();
354         Assert.assertEquals("200", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseCode());
355         Assert.assertEquals(
356             "ack", serviceCreatOutput.getResult().getConfigurationResponseCommon().getAckFinalIndicator());
357         Assert.assertEquals(
358             "message", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseMessage());
359         Assert.assertNull(serviceCreatOutput.getResult().getConfigurationResponseCommon().getRequestId());
360     }
361
362     @Test
363     public void createCreateServiceReplyWithServiceFeasibilityCheckInputWithSdncRequestHeader()
364         throws ExecutionException, InterruptedException {
365         ServiceFeasibilityCheckInput input =
366             new ServiceFeasibilityCheckInputBuilder()
367                 .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("12").build()).build();
368         ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceCreatOutputF =
369             ModelMappingUtils.createCreateServiceReply(input, "ack", "message", "200");
370         serviceCreatOutputF.addListener(new Runnable() {
371             @Override
372             public void run() {
373                 endSignal.countDown();
374             }
375         }, executorService);
376
377         endSignal.await();
378         RpcResult<ServiceFeasibilityCheckOutput> serviceCreatOutput = serviceCreatOutputF.get();
379         Assert.assertEquals("200", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseCode());
380         Assert.assertEquals(
381             "ack", serviceCreatOutput.getResult().getConfigurationResponseCommon().getAckFinalIndicator());
382         Assert.assertEquals(
383             "message", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseMessage());
384         Assert.assertEquals("12", serviceCreatOutput.getResult().getConfigurationResponseCommon().getRequestId());
385     }
386
387     @Test
388     public void createCreateServiceReplyWithServiceFeasibilityCheckInputWithoutSdncRequestHeader()
389         throws ExecutionException, InterruptedException {
390         ServiceFeasibilityCheckInput input = new ServiceFeasibilityCheckInputBuilder().build();
391         ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceCreatOutputF =
392             ModelMappingUtils.createCreateServiceReply(input, "ack", "message", "200");
393         serviceCreatOutputF.addListener(new Runnable() {
394             @Override
395             public void run() {
396                 endSignal.countDown();
397             }
398         }, executorService);
399
400         endSignal.await();
401         RpcResult<ServiceFeasibilityCheckOutput> serviceCreatOutput = serviceCreatOutputF.get();
402         Assert.assertEquals("200", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseCode());
403         Assert.assertEquals(
404             "ack", serviceCreatOutput.getResult().getConfigurationResponseCommon().getAckFinalIndicator());
405         Assert.assertEquals(
406             "message", serviceCreatOutput.getResult().getConfigurationResponseCommon().getResponseMessage());
407         Assert.assertNull(serviceCreatOutput.getResult().getConfigurationResponseCommon().getRequestId());
408     }
409
410     @Test
411     public void testCreateRestoreServiceReply() throws ExecutionException, InterruptedException {
412         ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestorationOutputF =
413             ModelMappingUtils.createRestoreServiceReply("message", RpcStatus.Failed);
414         serviceRestorationOutputF.addListener(new Runnable() {
415             @Override
416             public void run() {
417                 endSignal.countDown();
418             }
419         }, executorService);
420
421         endSignal.await();
422         RpcResult<ServiceRestorationOutput> serviceRestorationOutput = serviceRestorationOutputF.get();
423         Assert.assertEquals("message", serviceRestorationOutput.getResult().getStatusMessage());
424     }
425 }