ServiceHandler unit testing update 85/74285/2
authordoha.khaled <dkhaled.ext@orange.com>
Thu, 12 Jul 2018 10:55:29 +0000 (12:55 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Sat, 28 Jul 2018 23:16:07 +0000 (01:16 +0200)
The Complete unit testing for the ServiceHandler module

Change-Id: Ica4bbba4e94bd46c8c44d965071fe0409abd4637

pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/MappingConstraintsTest.java [new file with mode: 0644]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtilsTest.java [new file with mode: 0644]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/ServiceEndpointTypeTest.java [new file with mode: 0644]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServiceHandlerImplTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listensers/PceListenserImplTest.java [new file with mode: 0644]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImplTest.java [new file with mode: 0644]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/utils/ServiceDataUtils.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/ServiceCreateValidationTest.java [new file with mode: 0644]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/checks/ComplianceCheckResultTest.java [new file with mode: 0644]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/checks/ServicehandlerCompliancyCheckTest.java [new file with mode: 0644]

index 83a324e13bf7a349ef180c5fbab37c056d3df64a..b7bc6b424fe7c82f85db2d35e54c073c7f61bb08 100644 (file)
@@ -104,6 +104,7 @@ public class PathComputationServiceImpl implements PathComputationService {
                     .setResponseCode("Path not calculated")
                     .setResponseMessage(check.getMessage());
 
+
             output.setConfigurationResponseCommon(configurationResponseCommon.build())
                     .setResponseParameters(null);
 
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/MappingConstraintsTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/MappingConstraintsTest.java
new file mode 100644 (file)
index 0000000..883821d
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler;
+
+import java.util.Arrays;
+import org.junit.Assert;
+import org.junit.Test;
+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.HardConstraints;
+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.SoftConstraints;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraintsBuilder;
+
+
+
+public class MappingConstraintsTest {
+
+    private MappingConstraints mappingConstraints;
+    private HardConstraints hardConstraints;
+    private SoftConstraints softConstraints;
+
+
+    public MappingConstraintsTest() {
+        this.hardConstraints = 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())
+        .build())
+        .setCustomerCode(Arrays.asList("Some customer-code"))
+        .build();
+
+        this.softConstraints = 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())
+                .build())
+            .setCustomerCode(Arrays.asList("Some customer-code"))
+            .build();
+
+        this.mappingConstraints = new MappingConstraints(hardConstraints, softConstraints);
+    }
+
+    @Test
+    public void serviceToServicePathConstarintsNullHardConstraints() {
+        this.mappingConstraints = new MappingConstraints(null, softConstraints);
+        this.mappingConstraints.serviceToServicePathConstarints();
+        Assert.assertEquals(null, this.mappingConstraints.getServiceHardConstraints());
+        Assert.assertEquals(null, this.mappingConstraints.getServicePathHardConstraints());
+    }
+
+    @Test
+    public void serviceToServicePathConstarintsNullSoftConstraints() {
+        this.mappingConstraints = new MappingConstraints(hardConstraints, null);
+        this.mappingConstraints.serviceToServicePathConstarints();
+        Assert.assertEquals(null, this.mappingConstraints.getServiceSoftConstraints());
+        Assert.assertEquals(null, this.mappingConstraints.getServicePathSoftConstraints());
+    }
+
+    @Test
+    public void serviceToServicePathConstarintsNullConstraints() {
+        this.mappingConstraints = new MappingConstraints(hardConstraints, softConstraints);
+        this.mappingConstraints.setServiceHardConstraints(null);
+        this.mappingConstraints.setServiceSoftConstraints(null);
+        this.mappingConstraints.serviceToServicePathConstarints();
+        Assert.assertEquals(null, this.mappingConstraints.getServiceHardConstraints());
+        Assert.assertEquals(null, this.mappingConstraints.getServicePathHardConstraints());
+        Assert.assertEquals(null, this.mappingConstraints.getServiceSoftConstraints());
+        Assert.assertEquals(null, this.mappingConstraints.getServicePathSoftConstraints());
+    }
+
+    @Test
+    public void serviceToServicePathConstarintsNotNullConstraints() {
+        this.mappingConstraints = new MappingConstraints(hardConstraints, softConstraints);
+        this.mappingConstraints.serviceToServicePathConstarints();
+        Assert.assertEquals(this.hardConstraints.getCoRoutingOrGeneral(), this.mappingConstraints
+            .getServiceHardConstraints().getCoRoutingOrGeneral());
+        Assert.assertEquals(softConstraints, this.mappingConstraints.getServiceSoftConstraints());
+        Assert.assertEquals(null, this.mappingConstraints.getServicePathSoftConstraints());
+    }
+
+    @Test
+    public void serviceToServicePathConstarintsParameterizedConstructor() {
+        this.mappingConstraints = new MappingConstraints(
+            new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
+            .routing.constraints.rev170426.routing.constraints.sp.HardConstraintsBuilder()
+            .setCustomerCode(Arrays.asList("Some customer-code"))
+            .setCoRoutingOrGeneral(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
+                .constraints.rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder()
+                .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
+                    .constraints.rev170426.constraints.sp.co.routing.or.general.co.routing.CoRoutingBuilder()
+                    .setExistingService(Arrays.asList("Some existing-service"))
+                    .build())
+                .build()).build(),
+            new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
+                .routing.constraints.rev170426.routing.constraints.sp.SoftConstraintsBuilder()
+                .setCustomerCode(Arrays.asList("Some customer-code"))
+                .setCoRoutingOrGeneral(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
+                    .constraints.rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder()
+                    .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
+                        .constraints.rev170426.constraints.sp.co.routing.or.general.co.routing.CoRoutingBuilder()
+                        .setExistingService(Arrays.asList("Some existing-service"))
+                        .build())
+                    .build()).build());
+
+        this.mappingConstraints.serviceToServicePathConstarints();
+        Assert.assertEquals(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
+            .constraints.rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder()
+            .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
+                .constraints.rev170426.constraints.sp.co.routing.or.general.co.routing.CoRoutingBuilder()
+                .setExistingService(Arrays.asList("Some existing-service"))
+                .build())
+            .build(), this.mappingConstraints.getServicePathHardConstraints().getCoRoutingOrGeneral());
+        Assert.assertEquals(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
+            .routing.constraints.rev170426.routing.constraints.sp.SoftConstraintsBuilder()
+            .setCustomerCode(Arrays.asList("Some customer-code"))
+            .setCoRoutingOrGeneral(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
+                .constraints.rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder()
+                .setCoRouting(new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
+                    .constraints.rev170426.constraints.sp.co.routing.or.general.co.routing.CoRoutingBuilder()
+                    .setExistingService(Arrays.asList("Some existing-service"))
+                    .build())
+                .build()).build(), this.mappingConstraints.getServicePathSoftConstraints());
+
+    }
+
+}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtilsTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtilsTest.java
new file mode 100644 (file)
index 0000000..8aedcda
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler;
+
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
+import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
+import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
+import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
+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.ServiceReconfigureInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePaths;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+
+
+public class ModelMappingUtilsTest extends AbstractTest {
+
+    private PathComputationRequestOutput pathComputationRequestOutput;
+    private ServiceReconfigureInput serviceReconfigureInput;
+    private PCEServiceWrapper pceServiceWrapper;
+
+    public ModelMappingUtilsTest() {
+        NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
+        PathComputationService pathComputationService = new PathComputationServiceImpl(getDataBroker(),
+            notificationPublishService);
+        pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
+        this.pathComputationRequestOutput = pceServiceWrapper.performPCE(ServiceDataUtils.buildServiceCreateInput(),
+            true);
+        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
+        OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
+        OffsetDateTime offsetDateTime2 = offsetDateTime.plusDays(10);
+        this.serviceReconfigureInput = new ServiceReconfigureInputBuilder().setNewServiceName("service 1")
+        .setServiceName("service 1").setCommonId("common id").setConnectionType(ConnectionType.Service)
+        .setCustomer("customer").setCustomerContact("customer contact").setDueDate(new DateAndTime(
+            dtf.format(offsetDateTime)))
+        .setEndDate(new DateAndTime(dtf.format(offsetDateTime2)))
+        .setNcCode("nc node").setNciCode("nci node").setSecondaryNciCode("secondry").setOperatorContact("operator")
+        .setServiceAEnd(ServiceDataUtils.getServiceAEndBuildReconfigure().build())
+        .setServiceZEnd(ServiceDataUtils.getServiceZEndBuildReconfigure().build())
+        .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())
+                .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())
+                .build())
+            .setCustomerCode(Arrays.asList("Some customer-code"))
+            .build())
+        .build();
+
+    }
+
+    @Test
+    public void mappingServicesNullServiceCreateInput() {
+        Services services = ModelMappingUtils.mappingServices(null, null,
+            this.pathComputationRequestOutput);
+        Assert.assertEquals(new ServicesBuilder().build(), services);
+    }
+
+    @Test
+    public void mappingServiceNotNullServiceReconfigureInput() {
+        Services services = ModelMappingUtils.mappingServices(null, serviceReconfigureInput,
+            this.pathComputationRequestOutput);
+        Assert.assertEquals("service 1", services.getServiceName());
+    }
+
+    @Test
+    public void mappingServiceValid() {
+        Services services = ModelMappingUtils.mappingServices(ServiceDataUtils.buildServiceCreateInput(),
+            serviceReconfigureInput,
+            this.pathComputationRequestOutput);
+        Assert.assertEquals("service 1", services.getServiceName());
+    }
+
+    @Test
+    public void mappingServicesPathNullServiceCreateInput() {
+        ServicePaths services = ModelMappingUtils.mappingServicePaths(null, null,
+            this.pathComputationRequestOutput);
+        Assert.assertEquals(new ServicePathsBuilder().build(), services);
+    }
+
+    /*@Test
+    public void mappingServicePathsValid() {
+        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())
+                    .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())
+                    .build())
+                .setCustomerCode(Arrays.asList("Some customer-code"))
+                .build()).build();
+        ServicePaths servicePaths = ModelMappingUtils.mappingServicePaths(input, serviceReconfigureInput,
+            this.pathComputationRequestOutput);
+        Assert.assertEquals("service 1", servicePaths.getServicePathName());
+    }*/
+
+}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/ServiceEndpointTypeTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/ServiceEndpointTypeTest.java
new file mode 100644 (file)
index 0000000..c320952
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ServiceEndpointTypeTest {
+
+    @Test
+    public void testgetIntValue() {
+        Assert.assertEquals(1, ServiceEndpointType.SERVICEAEND.getIntValue());
+        Assert.assertEquals(2, ServiceEndpointType.SERVICEZEND.getIntValue());
+    }
+
+    @Test
+    public void testForValue() {
+        Assert.assertEquals(ServiceEndpointType.SERVICEAEND, ServiceEndpointType.forValue(1));
+        Assert.assertEquals(ServiceEndpointType.SERVICEZEND, ServiceEndpointType.forValue(2));
+    }
+
+}
index cccc875a502d35c96ab14e3139f49ddba0cf0356..1967a8ba950bfd0cb420f292ad76c6a597c7e7a8 100644 (file)
@@ -985,13 +985,4 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals("Success", result.getStatusMessage());
 
     }
-
-    /*@Test(expected = ReadFailedException.class)
-    public void rerouteServiceThrowsException() throws ReadFailedException, InterruptedException, ExecutionException{
-        ServiceCreateInput createInput = buildServiceCreateInput();
-        ServiceCreateOutput createOutput = serviceHandler.serviceCreate(createInput).get().getResult();
-        ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
-        Mockito.when(dataStoreService.checkedGet()).thenThrow(InterruptedException.class);
-        ServiceRerouteOutput result = serviceHandler.serviceReroute(input).get().getResult();
-    }*/
 }
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listensers/PceListenserImplTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/listensers/PceListenserImplTest.java
new file mode 100644 (file)
index 0000000..7e576cc
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.listensers;
+
+import org.junit.Test;
+import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
+import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.ServicePathRpcResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.ServicePathRpcResultBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes;
+
+public class PceListenserImplTest {
+
+    private PceListenerImpl pceListener;
+    private ServicePathRpcResult servicePathRpcResult = null;
+
+    public PceListenserImplTest() {
+        this.pceListener = new PceListenerImpl();
+        this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
+    }
+
+    @Test
+    public void onServicePathRpcResultInitial() {
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+    }
+
+    @Test
+    public void onServicePathRpcResultRepeat() {
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+    }
+
+    @Test
+    public void onServicePathRpcResultRepeatFailed() {
+        this.servicePathRpcResult = ServiceDataUtils.buildFailedServicePathRpcResult();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+    }
+
+    @Test
+    public void onServicePathRpcResultRepeatFailedCompareCase1() {
+        this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+        this.servicePathRpcResult = new ServicePathRpcResultBuilder(this.servicePathRpcResult)
+            .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve).build();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+    }
+
+    @Test
+    public void onServicePathRpcResultRepeatFailedCompareCase2() {
+        this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+        this.servicePathRpcResult = new ServicePathRpcResultBuilder(this.servicePathRpcResult)
+            .setServiceName("service 2").build();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+    }
+
+    @Test
+    public void onServicePathRpcResultRepeatFailedCompareCase3() {
+        this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+        this.servicePathRpcResult = new ServicePathRpcResultBuilder(this.servicePathRpcResult)
+            .setStatus(RpcStatusEx.Failed).build();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+    }
+
+    @Test
+    public void onServicePathRpcResultRepeatFailedCompareCase4() {
+        this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+        this.servicePathRpcResult = new ServicePathRpcResultBuilder(this.servicePathRpcResult)
+            .setStatusMessage("failed").build();
+        this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
+    }
+}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImplTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImplTest.java
new file mode 100644 (file)
index 0000000..9ec0a65
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
+import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
+import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
+import org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl;
+import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
+import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+
+
+public class ServiceDataStoreOperationsImplTest extends AbstractTest {
+
+    private ServiceDataStoreOperationsImpl serviceDataStoreOperations;
+    private PCEServiceWrapper pceServiceWrapper;
+    private ServicehandlerImpl serviceHandler;
+    private RendererServiceOperations rendererServiceOperations;
+
+    public ServiceDataStoreOperationsImplTest() {
+        NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
+        PathComputationService pathComputationService = new PathComputationServiceImpl(getDataBroker(),
+            notificationPublishService);
+        this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
+        this.rendererServiceOperations = new StubRendererServiceOperations(notificationPublishService);
+        this.serviceHandler = new ServicehandlerImpl(getDataBroker(), pathComputationService,
+            this.rendererServiceOperations);
+    }
+
+
+    @Before
+    public void init() {
+        this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(this.getDataBroker());
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void modifyIfServiceNotPresent() {
+        OperationResult result = this.serviceDataStoreOperations.modifyService("service 1",
+            State.InService, State.InService);
+        Assert.assertEquals("Service " + "service 1" + " is not present!", result.getResultMessage());
+    }
+
+    @Test
+    public void writeOrModifyOrDeleteServiceListNotPresentWithNoWriteChoice() {
+
+        ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
+        PathComputationRequestOutput pathComputationRequestOutput = this.pceServiceWrapper.performPCE(createInput,
+            true);
+        String result = serviceDataStoreOperations.writeOrModifyOrDeleteServiceList("serviceCreateInput",
+            createInput, pathComputationRequestOutput, 3);
+
+        Assert.assertEquals("Service is not present ! ", result);
+
+    }
+
+    @Test
+    public void writeOrModifyOrDeleteServiceListNotPresentWithWriteChoice() {
+
+        ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
+        PathComputationRequestOutput pathComputationRequestOutput = this.pceServiceWrapper.performPCE(createInput,
+            true);
+        String result = serviceDataStoreOperations.writeOrModifyOrDeleteServiceList("service 1",
+            createInput, pathComputationRequestOutput, 2);
+
+        Assert.assertEquals(null, result);
+
+    }
+
+    @Test
+    public void writeOrModifyOrDeleteServiceListPresentWithModifyChoice() {
+        ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
+        PathComputationRequestOutput pathComputationRequestOutput = this.pceServiceWrapper.performPCE(createInput,
+            true);
+        OperationResult createOutput = this.serviceDataStoreOperations.createService(createInput,
+            pathComputationRequestOutput);
+        String result = serviceDataStoreOperations.writeOrModifyOrDeleteServiceList("service 1",
+            createInput, pathComputationRequestOutput, 0);
+        Assert.assertEquals(null, result);
+
+    }
+
+    @Test
+    public void writeOrModifyOrDeleteServiceListPresentWithDeleteChoice() {
+        ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
+        PathComputationRequestOutput pathComputationRequestOutput = this.pceServiceWrapper.performPCE(createInput,
+            true);
+        OperationResult createOutput = this.serviceDataStoreOperations.createService(createInput,
+            pathComputationRequestOutput);
+        String result = serviceDataStoreOperations.writeOrModifyOrDeleteServiceList("service 1",
+            createInput, pathComputationRequestOutput, 1);
+        Assert.assertEquals(null, result);
+
+    }
+
+    @Test
+    public void writeOrModifyOrDeleteServiceListPresentWithNoValidChoice() {
+        ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
+        PathComputationRequestOutput pathComputationRequestOutput = this.pceServiceWrapper.performPCE(createInput,
+            true);
+        OperationResult createOutput = this.serviceDataStoreOperations.createService(createInput,
+            pathComputationRequestOutput);
+        String result = serviceDataStoreOperations.writeOrModifyOrDeleteServiceList("service 1",
+            createInput, pathComputationRequestOutput, 2);
+        Assert.assertEquals(null, result);
+
+    }
+}
\ No newline at end of file
index 5bd8d24612d2a965fc8ebff0b32a58b74c424151..8342588c22c50ce25ef9b3e45bc5e9b4eaed1d09 100644 (file)
@@ -10,6 +10,10 @@ package org.opendaylight.transportpce.servicehandler.utils;
 import java.time.OffsetDateTime;
 import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.ServicePathRpcResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.ServicePathRpcResultBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.service.path.rpc.result.PathDescriptionBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
@@ -24,6 +28,12 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfo;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
 
 public class ServiceDataUtils {
@@ -147,4 +157,102 @@ public class ServiceDataUtils {
         builder.setServiceName("service 1");
         return builder.build();
     }
+
+    public static ServicePathRpcResult buildServicePathRpcResult() {
+        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
+        OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
+        DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
+        ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
+        builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.PathComputationRequest)
+            .setPathDescription(createPathDescription(0,1, 0, 1))
+            .setServiceName("service 1")
+            .setStatus(RpcStatusEx.Successful).setStatusMessage("success");
+        return builder.build();
+    }
+
+    public static ServicePathRpcResult buildFailedServicePathRpcResult() {
+        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
+        OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
+        DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
+        ServicePathRpcResultBuilder builder = new ServicePathRpcResultBuilder();
+        builder.setActualDate(datetime).setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest)
+            .setPathDescription(createPathDescription(0,1, 0, 1))
+            .setServiceName("service 1")
+            .setStatus(RpcStatusEx.Failed).setStatusMessage("success");
+        return builder.build();
+    }
+
+    private static PathDescription createPathDescription(long azRate, long azWaveLength, long zaRate,
+        long zaWaveLength) {
+        AToZDirection atozDirection = new AToZDirectionBuilder()
+            .setRate(azRate)
+            .setAToZWavelengthNumber(azWaveLength)
+            .setAToZ(null)
+            .build();
+        ZToADirection ztoaDirection = new ZToADirectionBuilder()
+            .setRate(zaRate)
+            .setZToAWavelengthNumber(zaWaveLength)
+            .setZToA(null)
+            .build();
+        PathDescription pathDescription = new PathDescriptionBuilder()
+            .setAToZDirection(atozDirection)
+            .setZToADirection(ztoaDirection)
+            .build();
+        return pathDescription;
+    }
+
+    public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
+        .ServiceAEndBuilder getServiceAEndBuildReconfigure() {
+        return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
+            .ServiceAEndBuilder()
+            .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
+            .setTxDirection(
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+                    .endpoint.TxDirectionBuilder()
+                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
+                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
+                        .setPortSubSlot("port subslot").setPortType("port type").build())
+                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
+                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
+                        .setLgxPortShelf("lgx port shelf").build())
+                    .build())
+            .setRxDirection(
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+                    .endpoint.RxDirectionBuilder()
+                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
+                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
+                        .setPortSubSlot("port subslot").setPortType("port type").build())
+                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
+                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
+                        .setLgxPortShelf("lgx port shelf").build())
+                    .build());
+    }
+
+    public static org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
+        .ServiceZEndBuilder getServiceZEndBuildReconfigure() {
+        return new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.reconfigure.input
+            .ServiceZEndBuilder()
+            .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
+            .setTxDirection(
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+                    .endpoint.TxDirectionBuilder()
+                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
+                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
+                        .setPortSubSlot("port subslot").setPortType("port type").build())
+                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
+                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
+                        .setLgxPortShelf("lgx port shelf").build())
+                    .build())
+            .setRxDirection(
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service
+                    .endpoint.RxDirectionBuilder()
+                    .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
+                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
+                        .setPortSubSlot("port subslot").setPortType("port type").build())
+                    .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
+                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
+                        .setLgxPortShelf("lgx port shelf").build())
+                    .build());
+    }
+
 }
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/ServiceCreateValidationTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/ServiceCreateValidationTest.java
new file mode 100644 (file)
index 0000000..5ec1362
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.validation;
+
+import java.util.Arrays;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.transportpce.common.OperationResult;
+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;
+
+
+public class ServiceCreateValidationTest {
+
+    @Test
+    public void validateServiceCreateRequestIfCommonIdNull() {
+        ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
+            .setCommonId(null).build();
+        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        Assert.assertEquals(true, result.isSuccess());
+    }
+
+    @Test
+    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())
+                    .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())
+                    .build())
+                .setCustomerCode(Arrays.asList("Some customer-code"))
+                .build()).build();
+        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        Assert.assertEquals(false, result.isSuccess());
+    }
+
+    @Test
+    public void validateServiceCreateRequestIfConstraintsNull() {
+        ServiceCreateInput input = new ServiceCreateInputBuilder(ServiceDataUtils.buildServiceCreateInput())
+            .setSoftConstraints(null).setHardConstraints(null).build();
+        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        Assert.assertEquals(true, result.isSuccess());
+    }
+
+    @Test
+    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())
+                    .build())
+                .setCustomerCode(Arrays.asList("Some customer-code"))
+                .build()).setHardConstraints(null).build();
+        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        Assert.assertEquals(true, result.isSuccess());
+    }
+
+    @Test
+    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())
+                    .build())
+                .setCustomerCode(Arrays.asList("Some customer-code"))
+                .build()).build();
+        OperationResult result = ServiceCreateValidation.validateServiceCreateRequest(input);
+        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());
+    }
+}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/checks/ComplianceCheckResultTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/checks/ComplianceCheckResultTest.java
new file mode 100644 (file)
index 0000000..0c6e44d
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.validation.checks;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ComplianceCheckResultTest {
+
+    @Test
+    public void constructComplianceCheckResult() {
+        ComplianceCheckResult checkResult = new ComplianceCheckResult(true);
+        Assert.assertEquals(true, checkResult.hasPassed());
+
+        checkResult = new ComplianceCheckResult(false);
+        Assert.assertEquals(false, checkResult.hasPassed());
+    }
+}
diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/checks/ServicehandlerCompliancyCheckTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/validation/checks/ServicehandlerCompliancyCheckTest.java
new file mode 100644 (file)
index 0000000..1ea15d6
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.servicehandler.validation.checks;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
+
+public class ServicehandlerCompliancyCheckTest {
+
+    public ServicehandlerCompliancyCheckTest(){
+    }
+
+    @Test
+    public void checkFalseSdncRequest() {
+        ComplianceCheckResult result = ServicehandlerCompliancyCheck.check("service 1",
+            new SdncRequestHeaderBuilder().setRequestId("1").setRequestSystemId("1").setNotificationUrl("1")
+            .setRpcAction(RpcActions.ServiceCreate).build(),
+            ConnectionType.Service,RpcActions.ServiceCreate, true, false);
+
+        Assert.assertEquals("", result.getMessage());
+        Assert.assertEquals(true, result.hasPassed());
+    }
+
+    @Test
+    public void constructServicehandlerCompliancyCheck() {
+        ServicehandlerCompliancyCheck servicehandlerCompliancyCheck = new ServicehandlerCompliancyCheck();
+        Assert.assertEquals(ServicehandlerCompliancyCheck.class, servicehandlerCompliancyCheck.getClass());
+    }
+}