clean some compilation warnings
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / validation / ServiceCreateValidationTest.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.validation;
9
10 import java.util.Arrays;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.transportpce.common.OperationResult;
14 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.CoRoutingBuilder;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraintsBuilder;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraintsBuilder;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
20
21
22 public class ServiceCreateValidationTest {
23
24     @Test
25     public void validateServiceCreateRequestIfCommonIdNull() {
26         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
27             .setCommonId(null).build();
28         OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
29         Assert.assertEquals(true, result.isSuccess());
30     }
31
32     @Test
33     public void validateServiceCreateRequestIfConstraintsNotNull() {
34         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
35             .setHardConstraints(new HardConstraintsBuilder()
36                 .setCoRoutingOrGeneral(new CoRoutingBuilder()
37                     .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
38                         .constrains.rev161014.constraints.co.routing.or.general.co.routing
39                         .CoRoutingBuilder().setExistingService(
40                         Arrays.asList("Some existing-service")).build())
41                     .build())
42                 .setCustomerCode(Arrays.asList("Some customer-code"))
43                 .build()).setSoftConstraints(new SoftConstraintsBuilder()
44                 .setCoRoutingOrGeneral(new CoRoutingBuilder()
45                     .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
46                         .constrains.rev161014.constraints.co.routing.or.general.co.routing
47                         .CoRoutingBuilder().setExistingService(
48                         Arrays.asList("Some existing-service")).build())
49                     .build())
50                 .setCustomerCode(Arrays.asList("Some customer-code"))
51                 .build()).build();
52         OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
53         Assert.assertEquals(false, result.isSuccess());
54     }
55
56     @Test
57     public void validateServiceCreateRequestIfConstraintsNull() {
58         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
59             .setSoftConstraints(null).setHardConstraints(null).build();
60         OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
61         Assert.assertEquals(true, result.isSuccess());
62     }
63
64     @Test
65     public void validateServiceCreateRequestIfHardConstraintsNull() {
66         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
67             .setSoftConstraints(new SoftConstraintsBuilder()
68                 .setCoRoutingOrGeneral(new CoRoutingBuilder()
69                     .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
70                         .constrains.rev161014.constraints.co.routing.or.general.co.routing
71                         .CoRoutingBuilder().setExistingService(
72                         Arrays.asList("Some existing-service")).build())
73                     .build())
74                 .setCustomerCode(Arrays.asList("Some customer-code"))
75                 .build()).setHardConstraints(null).build();
76         OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
77         Assert.assertEquals(true, result.isSuccess());
78     }
79
80     @Test
81     public void validateServiceCreateRequestIfSoftConstraintsNull() {
82         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
83             .setSoftConstraints(null).setHardConstraints(new HardConstraintsBuilder()
84                 .setCoRoutingOrGeneral(new CoRoutingBuilder()
85                     .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
86                         .constrains.rev161014.constraints.co.routing.or.general.co.routing
87                         .CoRoutingBuilder().setExistingService(
88                         Arrays.asList("Some existing-service")).build())
89                     .build())
90                 .setCustomerCode(Arrays.asList("Some customer-code"))
91                 .build()).build();
92         OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
93         Assert.assertEquals(true, result.isSuccess());
94     }
95 }