.setResponseCode("Path not calculated")
.setResponseMessage(check.getMessage());
+
output.setConfigurationResponseCommon(configurationResponseCommon.build())
.setResponseParameters(null);
--- /dev/null
+/*
+ * 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());
+
+ }
+
+}
--- /dev/null
+/*
+ * 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());
+ }*/
+
+}
--- /dev/null
+/*
+ * 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));
+ }
+
+}
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();
- }*/
}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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
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;
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 {
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());
+ }
+
}
--- /dev/null
+/*
+ * 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());
+ }
+}
--- /dev/null
+/*
+ * 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());
+ }
+}
--- /dev/null
+/*
+ * 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());
+ }
+}