import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
int[] pos = findTheLongestSubstring(nodeID, tpID);
//TODO: do not rely on nodeId to be integer
int id = Integer.parseInt(sortId);
- treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
+ treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
} else if (resourceType.equals("Link")) {
LOG.info("The type is link");
} else {
int[] pos = findTheLongestSubstring(nodeID, tpID);
//TODO: do not rely on nodeId to be integer
int id = Integer.parseInt(sortId);
- treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
+ treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
} else if (resourceType.equals("Link")) {
LOG.info("The type is link");
} else {
}
@Parameterized.Parameters
- public static Collection primeNumbers() {
+ public static Collection createParameters() {
List<Object[]> parameters = new ArrayList<>();
PathDescription pathDescription =
@Test
public void freeWavelengthsTest() throws ExecutionException, InterruptedException {
- WaveLengthServiceUtils.putTerminationPoint1ToDatastore("node1", "node1-" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ WaveLengthServiceUtils.putTerminationPoint1ToDatastore("node1" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ OpenRoadmInterfacesImpl.TTP_TOKEN,
this.terminationPoint1, this.deviceTransactionManager);
- WaveLengthServiceUtils.putNode1ToDatastore("node1", this.node1, this.deviceTransactionManager);
+ WaveLengthServiceUtils.putNode1ToDatastore("node1" + OpenRoadmInterfacesImpl.TTP_TOKEN, this.node1,
+ this.deviceTransactionManager);
this.networkModelWavelengthService.freeWavelengths(this.pathDescription);
- Node1 updatedNode1 = WaveLengthServiceUtils.getNode1FromDatastore("node1", this.deviceTransactionManager);
- TerminationPoint1 updatedTerminationPoint1 = WaveLengthServiceUtils.getTerminationPoint1FromDatastore("node1",
- "node1-" + OpenRoadmInterfacesImpl.TTP_TOKEN, this.deviceTransactionManager);
+ Node1 updatedNode1 = WaveLengthServiceUtils.getNode1FromDatastore("node1" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ this.deviceTransactionManager);
+ TerminationPoint1 updatedTerminationPoint1 =
+ WaveLengthServiceUtils.getTerminationPoint1FromDatastore("node1" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ OpenRoadmInterfacesImpl.TTP_TOKEN, this.deviceTransactionManager);
switch (updatedTerminationPoint1.getTpType()) {
case DEGREETXRXCTP:
case DEGREETXCTP:
}
@Parameterized.Parameters
- public static Collection primeNumbers() {
+ public static Collection createParameters() {
List<Object[]> parameters = new ArrayList<>();
PathDescription pathDescription =
@Test
public void freeWavelengthsTest() throws ExecutionException, InterruptedException {
WaveLengthServiceUtils
- .putTerminationPoint1ToDatastore("node1", "node1-" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ .putTerminationPoint1ToDatastore("node1" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ OpenRoadmInterfacesImpl.TTP_TOKEN,
this.terminationPoint1, this.deviceTransactionManager);
- WaveLengthServiceUtils.putNode1ToDatastore("node1", this.node1, this.deviceTransactionManager);
+ WaveLengthServiceUtils.putNode1ToDatastore("node1" + OpenRoadmInterfacesImpl.TTP_TOKEN, this.node1,
+ this.deviceTransactionManager);
this.networkModelWavelengthService.useWavelengths(this.pathDescription);
- Node1 updatedNode1 = WaveLengthServiceUtils.getNode1FromDatastore("node1", this.deviceTransactionManager);
+ Node1 updatedNode1 = WaveLengthServiceUtils.getNode1FromDatastore("node1" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ this.deviceTransactionManager);
TerminationPoint1 updatedTerminationPoint1 = WaveLengthServiceUtils
- .getTerminationPoint1FromDatastore("node1", "node1-" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ .getTerminationPoint1FromDatastore("node1" + OpenRoadmInterfacesImpl.TTP_TOKEN,
+ OpenRoadmInterfacesImpl.TTP_TOKEN,
this.deviceTransactionManager);
switch (updatedTerminationPoint1.getTpType()) {
}
@Parameterized.Parameters
- public static Collection primeNumbers() {
+ public static Collection nodes() {
NodeIdPair same = new NodeIdPair("nodeS", "CLIENT");
return Arrays.asList(new Object[][] {
{ new NodeIdPair("",""), null, false },
@Test
public void equalityTest() {
Assert.assertEquals(this.equality, firstPair.equals(this.secondPair));
- if (this.secondPair != null && this.firstPair.getClass().equals(this.secondPair.getClass())) {
+ if ((this.secondPair != null) && this.firstPair.getClass().equals(this.secondPair.getClass())) {
Assert.assertEquals(this.equality, this.firstPair.hashCode() == this.secondPair.hashCode());
}
}
--- /dev/null
+/*
+ * Copyright © 2018 Orange Systems, 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.renderer.provisiondevice;
+
+import java.util.ArrayList;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.common.mapping.PortMappingImpl;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
+import org.opendaylight.transportpce.renderer.stub.MountPointServiceStub;
+import org.opendaylight.transportpce.renderer.utils.CreateOtsOmsDataUtils;
+import org.opendaylight.transportpce.renderer.utils.MountPointUtils;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.CreateOtsOmsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.CreateOtsOmsOutput;
+
+public class DeviceRendererServiceImplCreateOtsOmsTest extends AbstractTest {
+
+ private DeviceRendererService deviceRendererService;
+ private CrossConnect crossConnect;
+ private OpenRoadmInterfaces openRoadmInterfaces;
+ private OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
+ private DeviceTransactionManager deviceTransactionManager;
+
+ private void setMountPoint(MountPoint mountPoint) {
+ MountPointService mountPointService = new MountPointServiceStub(mountPoint);
+ this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
+ this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(this.deviceTransactionManager);
+ this.openRoadmInterfaces = Mockito.spy(this.openRoadmInterfaces);
+ PortMapping portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager,
+ this.openRoadmInterfaces);
+ this.openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(portMapping,
+ this.openRoadmInterfaces);
+ this.crossConnect = new CrossConnectImpl(this.deviceTransactionManager);
+ this.crossConnect = Mockito.spy(this.crossConnect);
+ this.deviceRendererService = new DeviceRendererServiceImpl(this.getDataBroker(),
+ this.deviceTransactionManager, this.openRoadmInterfaceFactory, this.openRoadmInterfaces,
+ this.crossConnect, portMapping);
+ }
+
+ @Test
+ public void testCreateOtsOmsWhenDeviceIsNotMounted() throws OpenRoadmInterfaceException {
+ setMountPoint(null);
+ CreateOtsOmsInput input = CreateOtsOmsDataUtils.buildCreateOtsOms();
+ CreateOtsOmsOutput result = this.deviceRendererService.createOtsOms(input);
+ Assert.assertFalse(result.isSuccess());
+ Assert.assertEquals("node 1 is not mounted on the controller",
+ result.getResult());
+ }
+
+ @Test
+ public void testCreateOtsOmsWhenDeviceIsMountedWithNoMapping() throws OpenRoadmInterfaceException {
+ setMountPoint(MountPointUtils.getMountPoint(new ArrayList<>(), getDataBroker()));
+ CreateOtsOmsInput input = CreateOtsOmsDataUtils.buildCreateOtsOms();
+ CreateOtsOmsOutput result = this.deviceRendererService.createOtsOms(input);
+ Assert.assertFalse(result.isSuccess());
+ }
+
+ @Test
+ public void testCreateOtsOmsWhenDeviceIsMountedWithMapping() throws OpenRoadmInterfaceException {
+ setMountPoint(MountPointUtils.getMountPoint(new ArrayList<>(), getDataBroker()));
+ CreateOtsOmsInput input = CreateOtsOmsDataUtils.buildCreateOtsOms();
+ writePortMapping(input);
+ CreateOtsOmsOutput result = this.deviceRendererService.createOtsOms(input);
+ Assert.assertTrue(result.isSuccess());
+ }
+
+ private void writePortMapping(CreateOtsOmsInput input) {
+ MountPointUtils.writeMapping(
+ input.getNodeId(),
+ input.getLogicalConnectionPoint(),
+ this.deviceTransactionManager
+ );
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © 2018 Orange Systems, 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.renderer.provisiondevice;
+
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.common.mapping.PortMappingImpl;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthServiceImpl;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
+import org.opendaylight.transportpce.renderer.stub.MountPointServiceStub;
+import org.opendaylight.transportpce.renderer.stub.MountPointStub;
+import org.opendaylight.transportpce.renderer.stub.OlmServiceStub;
+import org.opendaylight.transportpce.renderer.utils.ServiceDeleteDataUtils;
+import org.opendaylight.transportpce.renderer.utils.TransactionUtils;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServicePathList;
+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.http.org.transportpce.b.c._interface.servicepath.rev170426.service.path.list.ServicePathsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.OlmService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownOutputBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+public class RendererServiceOperationsImplDeleteTest extends AbstractTest {
+
+ private static final int NUMBER_OF_THREADS = 4;
+ private DeviceTransactionManager deviceTransactionManager;
+ private RendererServiceOperationsImpl rendererServiceOperations;
+ private OpenRoadmInterfaces openRoadmInterfaces;
+ private DeviceRendererService deviceRenderer;
+ private PortMapping portMapping;
+ private CrossConnect crossConnect;
+ private NetworkModelWavelengthService networkModelWavelengthService;
+ private OlmService olmService;
+
+ private void setMountPoint(MountPoint mountPoint) {
+ MountPointService mountPointService = new MountPointServiceStub(mountPoint);
+ this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
+ this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(this.deviceTransactionManager);
+ this.portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager,
+ openRoadmInterfaces);
+ OpenRoadmInterfaceFactory openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(portMapping,
+ openRoadmInterfaces);
+ this.crossConnect = new CrossConnectImpl(this.deviceTransactionManager);
+ this.crossConnect = Mockito.spy(crossConnect);
+ this.deviceRenderer = new DeviceRendererServiceImpl(this.getDataBroker(),
+ this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect,
+ this.portMapping);
+ }
+
+ @Before
+ public void setUp() {
+ setMountPoint(new MountPointStub(getDataBroker()));
+ this.olmService = new OlmServiceStub();
+ this.olmService = Mockito.spy(this.olmService);
+ ListeningExecutorService executor =
+ MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
+ this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
+ this.rendererServiceOperations = new RendererServiceOperationsImpl(this.deviceRenderer, olmService,
+ getDataBroker(), this.networkModelWavelengthService);
+
+ }
+
+
+ @Test
+ public void serviceDeleteOperationPp() throws ExecutionException, InterruptedException {
+ writePathDescription();
+ ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder();
+ serviceDeleteInputBuilder.setServiceName("service 1");
+ serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder())
+ .setRequestId("request1").build());
+ Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString());
+ ServiceDeleteOutput serviceDeleteOutput
+ = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build());
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK,
+ serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
+ Mockito.verify(this.crossConnect, Mockito.times(2)).deleteCrossConnect(Mockito.any(), Mockito.any());
+ }
+
+ @Test
+ public void serviceDeleteOperationNoDescription() {
+ ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder();
+ serviceDeleteInputBuilder.setServiceName("service 1");
+ ServiceDeleteOutput serviceDeleteOutput
+ = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build());
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
+ serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
+ Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.any(), Mockito.any());
+ }
+
+ @Test
+ public void serviceDeleteOperationTearDownFailedAtoZ() throws ExecutionException, InterruptedException {
+ Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString());
+ Mockito.doReturn(RpcResultBuilder.success((new ServicePowerTurndownOutputBuilder())
+ .setResult("Failed").build()).buildFuture()).when(this.olmService).servicePowerTurndown(Mockito.any());
+
+ writePathDescription();
+ ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder();
+ serviceDeleteInputBuilder.setServiceName("service 1");
+ serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder())
+ .setRequestId("request1").build());
+ ServiceDeleteOutput serviceDeleteOutput
+ = this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build());
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
+ serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
+ Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.eq("node1"), Mockito.any());
+ Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.eq("node2"), Mockito.any());
+ }
+
+ @Test
+ public void serviceDeleteOperationTearDownFailedZtoA() throws ExecutionException, InterruptedException {
+ Mockito.doReturn(true).when(this.crossConnect).deleteCrossConnect(Mockito.anyString(), Mockito.anyString());
+ Mockito.when(this.olmService.servicePowerTurndown(Mockito.any()))
+ .thenReturn(RpcResultBuilder.success((new ServicePowerTurndownOutputBuilder())
+ .setResult("Success").build()).buildFuture())
+ .thenReturn(RpcResultBuilder.success((new ServicePowerTurndownOutputBuilder())
+ .setResult("Failed").build()).buildFuture());
+
+ writePathDescription();
+ ServiceDeleteInputBuilder serviceDeleteInputBuilder = new ServiceDeleteInputBuilder();
+ serviceDeleteInputBuilder.setServiceName("service 1");
+ serviceDeleteInputBuilder.setServiceHandlerHeader((new ServiceHandlerHeaderBuilder())
+ .setRequestId("request1").build());
+ ServiceDeleteOutput serviceDeleteOutput =
+ this.rendererServiceOperations.serviceDelete(serviceDeleteInputBuilder.build());
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
+ serviceDeleteOutput.getConfigurationResponseCommon().getResponseCode());
+ Mockito.verify(this.olmService, Mockito.times(2)).servicePowerTurndown(Mockito.any());
+ Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.eq("node1"), Mockito.any());
+ Mockito.verify(this.crossConnect, Mockito.times(0)).deleteCrossConnect(Mockito.eq("node2"), Mockito.any());
+ }
+
+ private void writePathDescription() throws ExecutionException, InterruptedException {
+ ServicePathsBuilder servicePathsBuilder = new ServicePathsBuilder();
+ servicePathsBuilder.setPathDescription(ServiceDeleteDataUtils
+ .createTransactionPathDescription(OpenRoadmInterfacesImpl.PP_TOKEN));
+ servicePathsBuilder.setServiceAEnd(ServiceDeleteDataUtils.getServiceAEndBuild().build())
+ .setServiceZEnd(ServiceDeleteDataUtils.getServiceZEndBuild().build());
+ servicePathsBuilder.withKey(new ServicePathsKey("service 1"));
+ servicePathsBuilder.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder().setRequestId("Request 1")
+ .build());
+ InstanceIdentifier<ServicePaths> servicePathsInstanceIdentifier = InstanceIdentifier.create(
+ ServicePathList.class).child(ServicePaths.class, new ServicePathsKey("service 1"));
+ TransactionUtils.writeTransaction(
+ this.deviceTransactionManager,
+ "node1" + OpenRoadmInterfacesImpl.PP_TOKEN,
+ LogicalDatastoreType.OPERATIONAL,
+ servicePathsInstanceIdentifier,
+ servicePathsBuilder.build());
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2018 Orange Systems, 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.renderer.provisiondevice;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.common.mapping.PortMappingImpl;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthServiceImpl;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
+import org.opendaylight.transportpce.renderer.stub.MountPointServiceStub;
+import org.opendaylight.transportpce.renderer.stub.MountPointStub;
+import org.opendaylight.transportpce.renderer.stub.OlmServiceStub;
+import org.opendaylight.transportpce.renderer.utils.MountPointUtils;
+import org.opendaylight.transportpce.renderer.utils.ServiceDataUtils;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.get.pm.input.ResourceIdentifierBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.GetPmInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.GetPmInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.GetPmOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.GetPmOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.OlmService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.get.pm.output.Measurements;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.get.pm.output.MeasurementsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathOutputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+public class RendererServiceOperationsImplTest extends AbstractTest {
+
+ private MountPointService mountPointService;
+ private DeviceTransactionManager deviceTransactionManager;
+ private RendererServiceOperationsImpl rendererServiceOperations;
+ private OpenRoadmInterfaces openRoadmInterfaces;
+ private DeviceRendererService deviceRenderer;
+ private PortMapping portMapping;
+ private OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
+ private CrossConnect crossConnect;
+ private OlmService olmService;
+ private NetworkModelWavelengthService networkModelWavelengthService;
+
+ private void setMountPoint(MountPoint mountPoint) {
+ this.mountPointService = new MountPointServiceStub(mountPoint);
+ this.deviceTransactionManager = new DeviceTransactionManagerImpl(this.mountPointService, 3000);
+ this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(this.deviceTransactionManager);
+ this.openRoadmInterfaces = Mockito.spy(this.openRoadmInterfaces);
+ this.portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager,
+ openRoadmInterfaces);
+ this.openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(portMapping,
+ openRoadmInterfaces);
+ this.crossConnect = new CrossConnectImpl(this.deviceTransactionManager);
+ }
+
+ @Before
+ public void setUp() throws OpenRoadmInterfaceException {
+ setMountPoint(new MountPointStub(getDataBroker()));
+ this.olmService = new OlmServiceStub();
+ this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
+ this.deviceRenderer = new DeviceRendererServiceImpl(this.getDataBroker(),
+ this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect, portMapping);
+ Mockito.doNothing().when(this.openRoadmInterfaces).postEquipmentState(Mockito.anyString(),
+ Mockito.anyString(), Mockito.anyBoolean());
+
+ this.olmService = Mockito.spy(this.olmService);
+ this.deviceRenderer = Mockito.spy(this.deviceRenderer);
+ this.rendererServiceOperations = new RendererServiceOperationsImpl(this.deviceRenderer, this.olmService,
+ getDataBroker(), this.networkModelWavelengthService);
+
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
+ .setSuccess(true);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+ }
+
+ @Test
+ public void serviceImplementationTerminationPointAsResourceTtp() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.TTP_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.TTP_TOKEN);
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
+ .setSuccess(true);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationTerminationPointAsResourceTtp2() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.TTP_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.TTP_TOKEN);
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
+ .setSuccess(true);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+ Mockito.doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService)
+ .servicePowerSetup(Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationTerminationPointAsResourcePp() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.PP_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.PP_TOKEN);
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
+ .setSuccess(true);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationTerminationPointAsResourceNetwork() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
+ .setSuccess(true);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationTerminationPointAsResourceClient() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.CLIENT_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.CLIENT_TOKEN);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+ }
+
+ @Test
+ public void serviceImplementationTerminationPointAsResourceNoMapping() {
+
+ String[] interfaceTokens = {
+ OpenRoadmInterfacesImpl.NETWORK_TOKEN,
+ OpenRoadmInterfacesImpl.CLIENT_TOKEN,
+ OpenRoadmInterfacesImpl.TTP_TOKEN,
+ OpenRoadmInterfacesImpl.PP_TOKEN
+ };
+
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("failed")
+ .setSuccess(false);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+
+ for (String tpToken : interfaceTokens) {
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(tpToken);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
+ result.getConfigurationResponseCommon().getResponseCode());
+ }
+ }
+
+ private void writePortMapping(ServiceImplementationRequestInput input, String tpToken) {
+ MountPointUtils.writeMapping(
+ input.getServiceAEnd().getNodeId(),
+ input.getServiceAEnd().getNodeId() + "-" + tpToken,
+ this.deviceTransactionManager
+ );
+ MountPointUtils.writeMapping(
+ input.getServiceZEnd().getNodeId(),
+ input.getServiceZEnd().getNodeId() + "-"
+ + input.getServiceAEnd().getNodeId() + "-" + tpToken,
+ this.deviceTransactionManager
+ );
+ MountPointUtils.writeMapping(
+ input.getServiceAEnd().getNodeId(),
+ input.getServiceAEnd().getNodeId() + "-"
+ + input.getServiceZEnd().getNodeId() + "-" + tpToken,
+ this.deviceTransactionManager
+ );
+ MountPointUtils.writeMapping(
+ input.getServiceZEnd().getNodeId(),
+ input.getServiceZEnd().getNodeId() + "-" + tpToken,
+ this.deviceTransactionManager
+ );
+ }
+
+ @Test
+ public void serviceImplementationRollbackAllNecessary() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Mockito.doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService)
+ .servicePowerSetup(Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ private GetPmInput createGetPmInput(String nodeId, String tp) {
+ GetPmInputBuilder getPmIpBldr = new GetPmInputBuilder();
+ getPmIpBldr.setNodeId(nodeId);
+ getPmIpBldr.setGranularity(PmGranularity._15min);
+ ResourceIdentifierBuilder rsrcBldr = new ResourceIdentifierBuilder();
+ rsrcBldr.setResourceName(tp + "-OTU");
+ getPmIpBldr.setResourceIdentifier(rsrcBldr.build());
+ getPmIpBldr.setResourceType(ResourceTypeEnum.Interface);
+ return getPmIpBldr.build();
+ }
+
+ @Test
+ public void serviceImplementationServiceInActive() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks")
+ .setPmparameterValue("1").build();
+ List<Measurements> measurementsList = new ArrayList<Measurements>();
+ measurementsList.add(measurements);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(measurementsList).build();
+ Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
+ .getPm(Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceInActive2() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks")
+ .setPmparameterValue("1").build();
+ List<Measurements> measurementsList = new ArrayList<Measurements>();
+ measurementsList.add(measurements);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(measurementsList).build();
+ GetPmOutput getPmOutput2 = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
+
+ Mockito.when(this.olmService.getPm(Mockito.any()))
+ .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceInActive3() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks")
+ .setPmparameterValue("1").build();
+ List<Measurements> measurementsList = new ArrayList<Measurements>();
+ measurementsList.add(measurements);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(measurementsList).build();
+ GetPmOutput getPmOutput2 = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
+
+ GetPmInput getPmInputZ = createGetPmInput("XPONDER-2-3",
+ OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ GetPmInput getPmInputA = createGetPmInput("XPONDER-1-2",
+ OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputZ)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput2).buildFuture());
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputA)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceActive() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
+ GetPmOutput getPmOutput1 = null;
+ Mockito.when(this.olmService.getPm(Mockito.any())).thenReturn(RpcResultBuilder.success(getPmOutput1)
+ .buildFuture());
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
+ .setSuccess(true);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceActive2() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder().setMeasurements(new ArrayList<>()).build();
+ Mockito.when(this.olmService.getPm(Mockito.any())).thenReturn(RpcResultBuilder.success(getPmOutput)
+ .buildFuture());
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
+ .setSuccess(true);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceInActive4() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Measurements measurements = new MeasurementsBuilder().setPmparameterName("preFECCorrectedErrors")
+ .setPmparameterValue("1").build();
+ List<Measurements> measurementsList = new ArrayList<Measurements>();
+ measurementsList.add(measurements);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(measurementsList).build();
+
+ Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
+ .getPm(Mockito.any());
+ ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
+ .setSuccess(true);
+ Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
+ Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceInActive5() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Measurements measurements = new MeasurementsBuilder().setPmparameterName("preFECCorrectedErrors")
+ .setPmparameterValue("112000000000d").build();
+ List<Measurements> measurementsList = new ArrayList<Measurements>();
+ measurementsList.add(measurements);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(measurementsList).build();
+
+ Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
+ .getPm(Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2018 Orange Systems, 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.renderer.utils;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.CreateOtsOmsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.CreateOtsOmsInputBuilder;
+
+public final class CreateOtsOmsDataUtils {
+
+ private CreateOtsOmsDataUtils() {
+
+ }
+
+ public static CreateOtsOmsInput buildCreateOtsOms() {
+ CreateOtsOmsInputBuilder builder = new CreateOtsOmsInputBuilder()
+ .setLogicalConnectionPoint("logical point")
+ .setNodeId("node 1");
+ return builder.build();
+ }
+}
}
private MountPointUtils() {
+
}
}
ServiceImplementationRequestInputBuilder builder = new ServiceImplementationRequestInputBuilder()
.setServiceName("service 1").setPathDescription(createPathDescriptionTerminationPointResource(tpId))
.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder().setRequestId("Request 1").build())
- .setServiceAEnd(getServiceAEndBuild().build())
- .setServiceZEnd(getServiceZEndBuild().build());
+ .setServiceAEnd(getServiceAEndBuild(tpId).build())
+ .setServiceZEnd(getServiceZEndBuild(tpId).build());
return builder.build();
}
- public static ServiceImplementationRequestInput buildServiceImplementationRequestInputInvalidResource() {
+ /*public static ServiceImplementationRequestInput buildServiceImplementationRequestInputInvalidResource() {
ServiceImplementationRequestInputBuilder builder = new ServiceImplementationRequestInputBuilder()
.setServiceName("service 1").setPathDescription(createPathDescriptionInvalidResource())
.setServiceHandlerHeader(new ServiceHandlerHeaderBuilder().setRequestId("Request 1").build())
.setServiceAEnd(getServiceAEndBuild().build())
.setServiceZEnd(getServiceZEndBuild().build());
return builder.build();
- }
+ }*/
private static PathDescription createPathDescriptionInvalidResource() {
List<AToZ> atoZList = new ArrayList<AToZ>();
for (String nodeId : nodeIds) {
for (String otherNodeId : nodeIds) {
TerminationPoint terminationPoint = terminationPointBuilder
- .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId(nodeId)
- .setTpId((nodeId.equals(otherNodeId) ? "" : nodeId + "-") + otherNodeId + "-" + tpId).build())
+ .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId(nodeId + '-'
+ + tpId)
+ .setTpId(tpId).build())
.build();
AToZ atoZ = new AToZBuilder().setId(atozId.toString())
.withKey(new AToZKey(atozId.toString())).setResource(new ResourceBuilder()
for (String nodeId : nodeIds) {
for (String otherNodeId : nodeIds) {
TerminationPoint terminationPoint = terminationPointBuilder
- .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId(nodeId)
- .setTpId((nodeId.equals(otherNodeId) ? "" : nodeId + "-") + otherNodeId + "-" + tpId).build())
+ .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId(nodeId + '-'
+ + tpId)
+ .setTpId(tpId).build())
.build();
ZToA ztoA = new ZToABuilder().setId(ztoaId.toString())
.withKey(new ZToAKey(ztoaId.toString())).setResource(new ResourceBuilder()
return builder.build();
}
- public static ServiceAEndBuilder getServiceAEndBuild() {
+ public static ServiceAEndBuilder getServiceAEndBuild(String tpId) {
return new ServiceAEndBuilder()
- .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
+ .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2-"
+ + tpId)
.setTxDirection(
new TxDirectionBuilder()
.setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
.build());
}
- public static ServiceZEndBuilder getServiceZEndBuild() {
+ public static ServiceZEndBuilder getServiceZEndBuild(String tpId) {
return new ServiceZEndBuilder()
- .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-2-3")
+ .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-2-3-"
+ + tpId)
.setTxDirection(
new TxDirectionBuilder()
.setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
List<AToZ> atoZList = new ArrayList<AToZ>();
TerminationPointBuilder terminationPointBuilder = new TerminationPointBuilder();
TerminationPoint terminationPoint = terminationPointBuilder
- .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId("node2")
- .setTpId("node2-" + tpId).build()).build();
+ .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId("node2" + tpId)
+ .setTpId(tpId).build()).build();
TerminationPoint terminationPoint2 = terminationPointBuilder
- .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId("node1")
- .setTpId("node1-" + tpId).build()).build();
+ .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId("node1" + tpId)
+ .setTpId(tpId).build()).build();
AToZ atoZ = new AToZBuilder().setId("1").withKey(new AToZKey("1")).setResource(new ResourceBuilder()
.setResource(terminationPoint).build()).build();
AToZ atoZ2 = new AToZBuilder().setId("2").withKey(new AToZKey("2")).setResource(new ResourceBuilder()