Adapt TransportPCE code to Sulfur
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / validation / ServiceCreateValidationTest.java
index 5ec1362dc191b46dfd70f7edc0f3d2030b585fff..6c0f0a9611ef8aec8acd43e6bc5890d39cc1aaa9 100644 (file)
@@ -7,18 +7,20 @@
  */
 package org.opendaylight.transportpce.servicehandler.validation;
 
-import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
-import org.opendaylight.transportpce.servicehandler.validation.checks.CheckCoherencyHardSoft;
-import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerTxRxCheck;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.CoRoutingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraintsBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraintsBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.CoRoutingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co.routing.ServiceIdentifierListBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraintsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.SoftConstraintsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
 
 
 public class ServiceCreateValidationTest {
@@ -27,7 +29,8 @@ public class ServiceCreateValidationTest {
     public void validateServiceCreateRequestIfCommonIdNull() {
         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
             .setCommonId(null).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(true, result.isSuccess());
     }
 
@@ -35,23 +38,27 @@ public class ServiceCreateValidationTest {
     public void validateServiceCreateRequestIfConstraintsNotNull() {
         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
             .setHardConstraints(new HardConstraintsBuilder()
-                .setCoRoutingOrGeneral(new CoRoutingBuilder()
-                    .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
-                        .constrains.rev161014.constraints.co.routing.or.general.co.routing
-                        .CoRoutingBuilder().setExistingService(
-                        Arrays.asList("Some existing-service")).build())
+                .setCoRouting(new CoRoutingBuilder()
+                    .setServiceIdentifierList(Map.of(
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210
+                            .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
+                        new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service")
+                            .build()))
                     .build())
-                .setCustomerCode(Arrays.asList("Some customer-code"))
-                .build()).setSoftConstraints(new SoftConstraintsBuilder()
-                .setCoRoutingOrGeneral(new CoRoutingBuilder()
-                    .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
-                        .constrains.rev161014.constraints.co.routing.or.general.co.routing
-                        .CoRoutingBuilder().setExistingService(
-                        Arrays.asList("Some existing-service")).build())
+                .setCustomerCode(Set.of("Some customer-code"))
+                .build())
+            .setSoftConstraints(new SoftConstraintsBuilder()
+                .setCoRouting(new CoRoutingBuilder()
+                    .setServiceIdentifierList(Map.of(
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210
+                            .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
+                        new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service")
+                            .build()))
                     .build())
-                .setCustomerCode(Arrays.asList("Some customer-code"))
+                .setCustomerCode(Set.of("Some customer-code"))
                 .build()).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(false, result.isSuccess());
     }
 
@@ -59,7 +66,8 @@ public class ServiceCreateValidationTest {
     public void validateServiceCreateRequestIfConstraintsNull() {
         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
             .setSoftConstraints(null).setHardConstraints(null).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(true, result.isSuccess());
     }
 
@@ -67,15 +75,17 @@ public class ServiceCreateValidationTest {
     public void validateServiceCreateRequestIfHardConstraintsNull() {
         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
             .setSoftConstraints(new SoftConstraintsBuilder()
-                .setCoRoutingOrGeneral(new CoRoutingBuilder()
-                    .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
-                        .constrains.rev161014.constraints.co.routing.or.general.co.routing
-                        .CoRoutingBuilder().setExistingService(
-                        Arrays.asList("Some existing-service")).build())
+                .setCoRouting(new CoRoutingBuilder()
+                    .setServiceIdentifierList(Map.of(
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210
+                            .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
+                        new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service")
+                            .build()))
                     .build())
-                .setCustomerCode(Arrays.asList("Some customer-code"))
+                .setCustomerCode(Set.of("Some customer-code"))
                 .build()).setHardConstraints(null).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(true, result.isSuccess());
     }
 
@@ -83,33 +93,17 @@ public class ServiceCreateValidationTest {
     public void validateServiceCreateRequestIfSoftConstraintsNull() {
         ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
             .setSoftConstraints(null).setHardConstraints(new HardConstraintsBuilder()
-                .setCoRoutingOrGeneral(new CoRoutingBuilder()
-                    .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
-                        .constrains.rev161014.constraints.co.routing.or.general.co.routing
-                        .CoRoutingBuilder().setExistingService(
-                        Arrays.asList("Some existing-service")).build())
+                .setCoRouting(new CoRoutingBuilder()
+                    .setServiceIdentifierList(Map.of(
+                        new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210
+                            .constraints.co.routing.ServiceIdentifierListKey("Some existing-service"),
+                        new ServiceIdentifierListBuilder().setServiceIdentifier("Some existing-service")
+                            .build()))
                     .build())
-                .setCustomerCode(Arrays.asList("Some customer-code"))
+                .setCustomerCode(Set.of("Some customer-code"))
                 .build()).build();
-        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        OperationResult result =
+                ServiceCreateValidation.validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceCreate);
         Assert.assertEquals(true, result.isSuccess());
     }
-
-    @Test
-    public void constructServicehandlerTxRxCheck() {
-        ServicehandlerTxRxCheck servicehandlerTxRxCheck = new ServicehandlerTxRxCheck();
-        Assert.assertEquals(ServicehandlerTxRxCheck.class, servicehandlerTxRxCheck.getClass());
-    }
-
-    @Test
-    public void constructCheckCoherencyHardSoft() {
-        CheckCoherencyHardSoft checkCoherencyHardSoft = new  CheckCoherencyHardSoft();
-        Assert.assertEquals(CheckCoherencyHardSoft.class, checkCoherencyHardSoft.getClass());
-    }
-
-    @Test
-    public void constructServiceCreateValidation() {
-        ServiceCreateValidation serviceCreateValidation = new  ServiceCreateValidation();
-        Assert.assertEquals(ServiceCreateValidation.class, serviceCreateValidation.getClass());
-    }
 }