*.class
+*.iml
**/target
bin/
dist
</dependency>
<!-- Testing Dependencies -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>test-common</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
+ <version>2.19.0</version>
<scope>test</scope>
</dependency>
</dependencies>
import java.util.TreeMap;
import java.util.concurrent.Future;
+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;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
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(pos[0], pos[1]), tpID));
} else if (resourceType.equals("Link")) {
LOG.info("The type is link");
} else {
if (tpID.contains("CTP") || tpID.contains("CP")) {
continue;
}
- if (!tpID.contains("TTP") && !tpID.contains("PP") && !tpID.contains("NETWORK")
- && !tpID.contains("CLIENT")) {
+ if (!tpID.contains(OpenRoadmInterfacesImpl.TTP_TOKEN)
+ && !tpID.contains(OpenRoadmInterfacesImpl.PP_TOKEN)
+ && !tpID.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)
+ && !tpID.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
continue;
}
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(pos[0], pos[1]), tpID));
} else if (resourceType.equals("Link")) {
LOG.info("The type is link");
} else {
String logicalConnPoint) throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format("Unable to get mapping from PortMapping for node % and"
+ throw new OpenRoadmInterfaceException(String.format("Unable to get mapping from PortMapping for node %s and"
+ " logical connection port %s", nodeId, logicalConnPoint));
}
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format("Unable to get mapping from PortMapping for node % and"
+ throw new OpenRoadmInterfaceException(String.format("Unable to get mapping from PortMapping for node %s and"
+ " logical connection port %s", nodeId, logicalConnPoint));
}
InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(portMap, OtnOdu.class,
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format("Unable to get mapping from PortMapping for node % and"
+ throw new OpenRoadmInterfaceException(String.format("Unable to get mapping from PortMapping for node %s and"
+ " logical connection port %s", nodeId, logicalConnPoint));
}
// Create generic interface
String circuitPackName = "";
String portName = "";
- int id = this.a2zTopologyList.size();
+ int id = this.z2aTopologyList.size();
DeviceBuilder deviceBldr = new DeviceBuilder();
deviceBldr.setNodeId(nodeId);
}
+ //update Topology
+ this.serviceTopology.setZToA(this.z2aTopologyList);
+
}
public Topology getTopology() {
rollbackProcessor.addTask(new TestRollbackTask("task1", false));
rollbackProcessor.addTask(new TestRollbackTask("task2", false));
rolledBack = rollbackProcessor.rollbackAllIfNecessary();
- Assert.assertTrue(rolledBack == 0);
+ Assert.assertEquals(0, rolledBack);
rollbackProcessor.addTask(new TestRollbackTask("task3", true));
rollbackProcessor.addTask(new TestRollbackTask("task4", false));
rolledBack = rollbackProcessor.rollbackAllIfNecessary();
- Assert.assertTrue(rolledBack == 4);
+ Assert.assertEquals(4, rolledBack);
rolledBack = rollbackProcessor.rollbackAllIfNecessary();
- Assert.assertTrue(rolledBack == 0);
+ Assert.assertEquals(0, rolledBack);
}
@Test
rollbackProcessor.addTask(new TestRollbackTask("task4", false));
int rolledBack = -1;
rolledBack = rollbackProcessor.rollbackAll();
- Assert.assertTrue(rolledBack == 4);
+ Assert.assertEquals(4, rolledBack);
rolledBack = rollbackProcessor.rollbackAll();
- Assert.assertTrue(rolledBack == 0);
+ Assert.assertEquals(0, rolledBack);
}
}
--- /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 java.util.concurrent.ExecutionException;
+import org.junit.Assert;
+import org.junit.Test;
+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.OpenRoadmInterfaces;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
+import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
+import org.opendaylight.transportpce.renderer.stub.MountPointServiceStub;
+import org.opendaylight.transportpce.renderer.stub.MountPointStub;
+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.transportpce.common.types.rev170907.node.interfaces.NodeInterface;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.node.interfaces.NodeInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.node.interfaces.NodeInterfaceKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathOutput;
+
+public class DeviceRendererServiceImplTest extends AbstractTest {
+
+ private MountPointService mountPointService;
+
+ private DeviceTransactionManager deviceTransactionManager;
+
+ private DeviceRendererService deviceRendererService;
+
+ private void setMountPoint(MountPoint mountPoint) {
+ this.mountPointService = new MountPointServiceStub(mountPoint);
+ this.deviceTransactionManager = new DeviceTransactionManagerImpl(this.mountPointService, 3000);
+ OpenRoadmInterfaces openRoadmInterfaces = new OpenRoadmInterfacesImpl(this.deviceTransactionManager);
+ PortMapping portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager,
+ openRoadmInterfaces);
+ OpenRoadmInterfaceFactory openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(portMapping,
+ openRoadmInterfaces);
+ CrossConnect crossConnect = new CrossConnectImpl(this.deviceTransactionManager);
+ this.deviceRendererService = new DeviceRendererServiceImpl(this.getDataBroker(),
+ this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect);
+ }
+
+ @Test
+ public void testSetupServiceWhenDeviceIsNotMounted() {
+ setMountPoint(null);
+ ServicePathInput servicePathInput = ServiceDataUtils.buildServicePathInputs();
+ for (ServicePathDirection servicePathDirection : ServicePathDirection.values()) {
+ ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
+ servicePathDirection);
+ Assert.assertFalse(servicePathOutput.isSuccess());
+ Assert.assertEquals("node1 is not mounted on the controller",
+ servicePathOutput.getResult());
+ }
+ }
+
+ @Test
+ public void testSetupServiceUsingCrossConnectEmptyPorts() throws ExecutionException, InterruptedException {
+ setMountPoint(MountPointUtils.getMountPoint(new ArrayList<>(), getDataBroker()));
+ testSetupService(true);
+ }
+
+ @Test
+ public void testSetupServiceUsingCrossConnectWithPorts() throws ExecutionException, InterruptedException {
+ setMountPoint(MountPointUtils.getMountPoint(new ArrayList<>(), getDataBroker()));
+ testSetupService(true);
+ }
+
+ @Test
+ public void testSetupServiceWithoutCrossConnect() throws ExecutionException, InterruptedException {
+ setMountPoint(new MountPointStub(getDataBroker()));
+
+ testSetupService(false);
+ }
+
+ private void testSetupService(boolean crossConnect) throws ExecutionException, InterruptedException {
+ String [] interfaceTokens = {
+ OpenRoadmInterfacesImpl.NETWORK_TOKEN,
+ OpenRoadmInterfacesImpl.CLIENT_TOKEN,
+ OpenRoadmInterfacesImpl.TTP_TOKEN,
+ OpenRoadmInterfacesImpl.PP_TOKEN,
+ ""
+ };
+
+ String nodeId = "node1";
+
+ for (String srcToken : interfaceTokens) {
+ String srcTP = "src-" + srcToken;
+ MountPointUtils.writeMapping(nodeId, srcTP, this.deviceTransactionManager);
+ for (String dstToken : interfaceTokens) {
+ String dstTp = "dst-" + dstToken;
+ MountPointUtils.writeMapping(nodeId, dstTp, this.deviceTransactionManager);
+
+ boolean connectingUsingCrossConnect = true;
+ if (OpenRoadmInterfacesImpl.NETWORK_TOKEN.equals(srcToken)
+ || OpenRoadmInterfacesImpl.CLIENT_TOKEN.equals(srcToken)) {
+ connectingUsingCrossConnect = false;
+ }
+ if (OpenRoadmInterfacesImpl.NETWORK_TOKEN.equals(dstToken)
+ || OpenRoadmInterfacesImpl.CLIENT_TOKEN.equals(dstToken)) {
+ connectingUsingCrossConnect = false;
+ }
+
+ if (connectingUsingCrossConnect != crossConnect) {
+ continue;
+ }
+
+ List<Nodes> nodes = new ArrayList<>();
+ nodes.add(ServiceDataUtils.createNode(nodeId, srcTP, dstTp));
+ ServicePathInput servicePathInput = ServiceDataUtils.buildServicePathInputs(nodes);
+
+ for (ServicePathDirection servicePathDirection : ServicePathDirection.values()) {
+ ServicePathOutput servicePathOutput = deviceRendererService.setupServicePath(servicePathInput,
+ servicePathDirection);
+ Assert.assertTrue(servicePathOutput.isSuccess());
+ String expectedResult = "Roadm-connection successfully created for nodes: ";
+ if (crossConnect) {
+ expectedResult = expectedResult + nodeId;
+ }
+ Assert.assertEquals(expectedResult, servicePathOutput.getResult());
+ Assert.assertEquals(1, servicePathOutput.getNodeInterface().size());
+ Assert.assertEquals(nodeId, servicePathOutput.getNodeInterface().get(0).getNodeId());
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testRollbackEmptyInterface() {
+ setMountPoint(new MountPointStub(getDataBroker()));
+ RendererRollbackInput rendererRollbackInput = ServiceDataUtils.buildRendererRollbackInput();
+ RendererRollbackOutput rendererRollbackOutput =
+ this.deviceRendererService.rendererRollback(rendererRollbackInput);
+ Assert.assertTrue(rendererRollbackOutput.isSuccess());
+ Assert.assertTrue(rendererRollbackOutput.getFailedToRollback().isEmpty());
+ }
+
+ @Test
+ public void testRollbackConnectionIdNotExist() {
+ setMountPoint(new MountPointStub(getDataBroker()));
+
+ NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder();
+ nodeInterfaceBuilder.setNodeId("node1");
+ nodeInterfaceBuilder.setKey(new NodeInterfaceKey("node1"));
+ List<String> connectionID = new ArrayList<>();
+ connectionID.add("node1-PP");
+ nodeInterfaceBuilder.setConnectionId(connectionID);
+ List<NodeInterface> nodeInterfaces = new ArrayList<>();
+ nodeInterfaces.add(nodeInterfaceBuilder.build());
+ RendererRollbackInputBuilder rendererRollbackInputBuilder = new RendererRollbackInputBuilder();
+ rendererRollbackInputBuilder.setNodeInterface(nodeInterfaces);
+
+ RendererRollbackOutput rendererRollbackOutput =
+ this.deviceRendererService.rendererRollback(rendererRollbackInputBuilder.build());
+ Assert.assertFalse(rendererRollbackOutput.isSuccess());
+ Assert.assertEquals(1, rendererRollbackOutput.getFailedToRollback().size());
+ Assert.assertEquals("node1", rendererRollbackOutput.getFailedToRollback().get(0).getNodeId());
+ }
+}
--- /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.Executors;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+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.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.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.urn.opendaylight.params.xml.ns.yang.olm.rev170418.OlmService;
+
+
+
+public class RendererServiceOperationsImplTest extends AbstractTest {
+
+ private static final int NUMBER_OF_THREADS = 4;
+ 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 ListeningExecutorService executor;
+ 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.portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager,
+ openRoadmInterfaces);
+ this.openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(portMapping,
+ openRoadmInterfaces);
+ this.crossConnect = new CrossConnectImpl(this.deviceTransactionManager);
+ this.deviceRenderer = new DeviceRendererServiceImpl(this.getDataBroker(),
+ this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect);
+ }
+
+ @Before
+ public void setUp() {
+ setMountPoint(new MountPointStub(getDataBroker()));
+ this.olmService = new OlmServiceStub();
+ this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
+ this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
+ this.rendererServiceOperations = new RendererServiceOperationsImpl(this.deviceRenderer, this.olmService,
+ getDataBroker(), this.networkModelWavelengthService);
+
+ }
+
+
+ @Test
+ public void serviceImplementationTerminationPointAsResourceTtp() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.TTP_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.TTP_TOKEN);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationTerminationPointAsResourcePp() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.PP_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.PP_TOKEN);
+ 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);
+ 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
+ };
+ 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() + "-" + tpToken,
+ this.deviceTransactionManager
+ );
+ }
+
+ /*@Test
+ public void serviceImplementationLinkAsResource() {
+ ServiceImplementationRequestInput input = ServiceDataUtils.buildServiceImplementationRequestInputLinkResource();
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+ }*/
+
+ /*@Test
+ public void serviceImplementtionInvalidResource() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputInvalidResource();
+ 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.stub;
+
+import com.google.common.base.Optional;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MountPointServiceStub implements MountPointService {
+
+ MountPoint returnedMountPoint;
+
+ public MountPointServiceStub(MountPoint usedMountPoint) {
+ this.returnedMountPoint = usedMountPoint;
+ }
+
+ @Override
+ public Optional<MountPoint> getMountPoint(InstanceIdentifier<?> mountPoint) {
+ if (returnedMountPoint == null) {
+ return Optional.absent();
+ }
+ return Optional.of(returnedMountPoint);
+ }
+
+ @Override
+ public <T extends MountPointListener> ListenerRegistration<T> registerListener(InstanceIdentifier<?> path,
+ T listener) {
+ return null;
+ }
+}
--- /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.stub;
+
+import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.BindingService;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MountPointStub implements MountPoint {
+
+ private DataBroker dataBroker;
+
+ private RpcConsumerRegistry rpcConsumerRegistry;
+
+ public MountPointStub(DataBroker dataBroker) {
+
+ this.dataBroker = dataBroker;
+ }
+
+ public void setRpcConsumerRegistry(RpcConsumerRegistry rpcConsumerRegistry) {
+ this.rpcConsumerRegistry = rpcConsumerRegistry;
+ }
+
+ @Override
+ public <T extends BindingService> Optional<T> getService(Class<T> service) {
+ if (service.isInstance(dataBroker)) {
+ return Optional.fromNullable((T)dataBroker);
+ }
+ if (service.isInstance(rpcConsumerRegistry)) {
+ return Optional.fromNullable((T)rpcConsumerRegistry);
+ }
+ return Optional.absent();
+ }
+
+ @Nonnull
+ @Override
+ public InstanceIdentifier<?> getIdentifier() {
+ return null;
+ }
+}
--- /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.stub;
+
+import java.util.ArrayList;
+import java.util.concurrent.Future;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossBaseInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossBaseOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossCurrentInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossCurrentOutput;
+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.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.ServicePowerResetInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerResetOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownOutput;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+public class OlmServiceStub implements OlmService {
+
+ @Override public Future<RpcResult<CalculateSpanlossCurrentOutput>> calculateSpanlossCurrent(
+ CalculateSpanlossCurrentInput input) {
+ return null;
+ }
+
+ @Override public Future<RpcResult<GetPmOutput>> getPm(GetPmInput input) {
+ GetPmOutput output = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
+ return RpcResultBuilder.success(
+ output).buildFuture();
+ }
+
+ @Override public Future<RpcResult<ServicePowerTurndownOutput>> servicePowerTurndown(
+ ServicePowerTurndownInput input) {
+ return null;
+ }
+
+ @Override public Future<RpcResult<CalculateSpanlossBaseOutput>> calculateSpanlossBase(
+ CalculateSpanlossBaseInput input) {
+ return null;
+ }
+
+ @Override public Future<RpcResult<ServicePowerResetOutput>> servicePowerReset(ServicePowerResetInput input) {
+ return null;
+ }
+
+ @Override public Future<RpcResult<ServicePowerSetupOutput>> servicePowerSetup(ServicePowerSetupInput input) {
+ return RpcResultBuilder.success(new ServicePowerSetupOutputBuilder().build()).buildFuture();
+ }
+}
--- /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 java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.transportpce.common.Timeouts;
+import org.opendaylight.transportpce.common.device.DeviceTransaction;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.transportpce.renderer.stub.MountPointStub;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.OpticalControlMode;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceService;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.connection.DestinationBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.connection.SourceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.get.connection.port.trail.output.Ports;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.Network;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.NodesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.MappingKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+public class MountPointUtils {
+
+ public static MountPointStub getMountPoint(List<Ports> ports, DataBroker dataBroker) {
+ RpcConsumerRegistry rpcConsumerRegistry = Mockito.spy(RpcConsumerRegistry.class);
+ OrgOpenroadmDeviceService orgOpenroadmDeviceService = Mockito.spy(OrgOpenroadmDeviceService.class);
+ GetConnectionPortTrailOutputBuilder getConnectionPortTrailOutputBuilder =
+ new GetConnectionPortTrailOutputBuilder();
+ getConnectionPortTrailOutputBuilder.setPorts(ports);
+ RpcResultBuilder<GetConnectionPortTrailOutput> rpcResultBuilder =
+ RpcResultBuilder.success(getConnectionPortTrailOutputBuilder.build());
+ Future<RpcResult<GetConnectionPortTrailOutput>> rpcResultFuture =
+ CompletableFuture.completedFuture(rpcResultBuilder.build());
+ Mockito.doReturn(rpcResultFuture).when(orgOpenroadmDeviceService).getConnectionPortTrail(Mockito.any());
+ Mockito.doReturn(orgOpenroadmDeviceService).when(rpcConsumerRegistry).getRpcService(Mockito.any());
+ MountPointStub mountPoint = new MountPointStub(dataBroker);
+ mountPoint.setRpcConsumerRegistry(rpcConsumerRegistry);
+ return mountPoint;
+ }
+
+ public static boolean writeMapping(String nodeId, String logicalConnPoint,
+ DeviceTransactionManager deviceTransactionManager) {
+ try {
+ MappingBuilder mappingBuilder = new MappingBuilder();
+ mappingBuilder.setKey(new MappingKey(logicalConnPoint));
+ mappingBuilder.setLogicalConnectionPoint(logicalConnPoint);
+ mappingBuilder.setSupportingOms("OMS");
+ mappingBuilder.setSupportingPort("8080");
+ mappingBuilder.setSupportingCircuitPackName("circuit1");
+ Future<Optional<DeviceTransaction>> deviceTxFuture =
+ deviceTransactionManager.getDeviceTransaction(nodeId);
+ if (!deviceTxFuture.get().isPresent()) {
+ return false;
+ }
+ InstanceIdentifier<Mapping> portMappingIID =
+ InstanceIdentifier.builder(Network.class).child(Nodes.class, new NodesKey(nodeId))
+ .child(Mapping.class, new MappingKey(logicalConnPoint)).build();
+ DeviceTransaction deviceTx = deviceTxFuture.get().get();
+ deviceTx.put(LogicalDatastoreType.CONFIGURATION, portMappingIID, mappingBuilder.build(), true);
+ deviceTx.submit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT).get();
+ } catch (ExecutionException | InterruptedException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean writeConnection(String nodeId, String srcTp, String destTp, Long waveNumber,
+ DeviceTransactionManager deviceTransactionManager) {
+ try {
+ RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder();
+ String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
+ rdmConnBldr.setConnectionNumber(connectionNumber);
+ rdmConnBldr.setWavelengthNumber(waveNumber);
+ rdmConnBldr.setOpticalControlMode(OpticalControlMode.Off);
+ rdmConnBldr.setSource(new SourceBuilder().setSrcIf(srcTp + "-" + waveNumber.toString()).build());
+ rdmConnBldr.setDestination(new DestinationBuilder().setDstIf(destTp + "-" + waveNumber.toString()).build());
+
+ Future<Optional<DeviceTransaction>> deviceTxFuture =
+ deviceTransactionManager.getDeviceTransaction(nodeId);
+ if (!deviceTxFuture.get().isPresent()) {
+ return false;
+ }
+ DeviceTransaction deviceTx = deviceTxFuture.get().get();
+ InstanceIdentifier<RoadmConnections> connectionID =
+ InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(RoadmConnections.class, new RoadmConnectionsKey(connectionNumber));
+ deviceTx.put(LogicalDatastoreType.CONFIGURATION, connectionID, rdmConnBldr.build(), true);
+ deviceTx.submit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT).get();
+ } catch (ExecutionException | InterruptedException e) {
+ return false;
+ }
+ return true;
+ }
+}
--- /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 java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
+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.pathdescription.rev170426.path.description.atoz.direction.AToZ;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToA;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToABuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToAKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.ResourceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.Link;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.LinkBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.NodeBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.TerminationPoint;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.TerminationPointBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.link.LinkIdentifierBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.node.NodeIdentifierBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.termination.point.TerminationPointIdentifierBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirectionBuilder;
+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.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation.request.input.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation.request.input.PathDescriptionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation.request.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.implementation.request.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.NodesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathInputBuilder;
+
+
+public class ServiceDataUtils {
+
+ public static Nodes createNode(String nodeId, String srcTp, String dstTp) {
+ return new NodesBuilder().setNodeId(nodeId).setKey(new NodesKey(nodeId)).setSrcTp(srcTp)
+ .setDestTp(dstTp).build();
+ }
+
+ public static ServicePathInput buildServicePathInputs(List<Nodes> nodes) {
+ ServicePathInputBuilder servicePathInputBuilder = new ServicePathInputBuilder();
+ servicePathInputBuilder.setNodes(nodes);
+ servicePathInputBuilder.setServiceName("Service 1").setWaveNumber(20L);
+ return servicePathInputBuilder.build();
+ }
+
+ public static ServicePathInput buildServicePathInputs() {
+ ServicePathInputBuilder servicePathInputBuilder = new ServicePathInputBuilder();
+ List<Nodes> nodes = new ArrayList<>();
+ nodes.add(ServiceDataUtils.createNode("node1", "src", "dst"));
+ servicePathInputBuilder.setNodes(nodes);
+ servicePathInputBuilder.setServiceName("Service 1").setWaveNumber(20L);
+ return servicePathInputBuilder.build();
+ }
+
+ public static RendererRollbackInput buildRendererRollbackInput() {
+ RendererRollbackInputBuilder rendererRollbackInputBuilder = new RendererRollbackInputBuilder();
+ rendererRollbackInputBuilder.setNodeInterface(new ArrayList<>());
+ return rendererRollbackInputBuilder.build();
+ }
+
+ public static ServiceImplementationRequestInput buildServiceImplementationRequestInputTerminationPointResource(
+ String tpId) {
+ ServiceImplementationRequestInputBuilder builder = new ServiceImplementationRequestInputBuilder()
+ .setServiceName("service 1").setPathDescription(createPathDescriptionTerminationPointResource(tpId))
+ .setServiceHandlerHeader(new ServiceHandlerHeaderBuilder().setRequestId("Request 1").build())
+ .setServiceAEnd(getServiceAEndBuild().build())
+ .setServiceZEnd(getServiceZEndBuild().build());
+ return builder.build();
+ }
+
+ 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();
+ }
+
+ public static ServiceImplementationRequestInput buildServiceImplementationRequestInputLinkResource() {
+ ServiceImplementationRequestInputBuilder builder = new ServiceImplementationRequestInputBuilder()
+ .setServiceName("service 1").setPathDescription(createPathDescriptionLinkResource())
+ .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>();
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource
+ .resource.resource.NodeBuilder nodesBuilder = new NodeBuilder();
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource
+ .resource.resource.Node node1 = nodesBuilder.setNodeIdentifier(new NodeIdentifierBuilder()
+ .setNodeId("XPONDER-1-2").build()).build();
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource
+ .resource.resource.Node node2 = nodesBuilder.setNodeIdentifier(new NodeIdentifierBuilder()
+ .setNodeId("XPONDER-1-2").build()).build();
+ AToZ atoZ = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder()
+ .setResource(node1).build()).build();
+ AToZ atoZ2 = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder()
+ .setResource(node2).build()).build();
+ atoZList.add(atoZ);
+ atoZList.add(atoZ2);
+ AToZDirection atozDirection = new AToZDirectionBuilder()
+ .setRate(20L)
+ .setAToZWavelengthNumber(20L)
+ .setAToZ(atoZList)
+ .build();
+ List<ZToA> ztoAList = new ArrayList<ZToA>();
+ ZToA ztoA = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder()
+ .setResource(node1).build()).build();
+ ZToA ztoA2 = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder()
+ .setResource(node2).build()).build();
+ ztoAList.add(ztoA);
+ ztoAList.add(ztoA2);
+ ZToADirection ztoaDirection = new ZToADirectionBuilder()
+ .setRate(20L)
+ .setZToAWavelengthNumber(20L)
+ .setZToA(ztoAList)
+ .build();
+ PathDescriptionBuilder builder = new PathDescriptionBuilder()
+ .setAToZDirection(atozDirection)
+ .setZToADirection(ztoaDirection);
+ return builder.build();
+ }
+
+ public static PathDescription createPathDescriptionTerminationPointResource(String tpId) {
+ List<AToZ> atoZList = new ArrayList<AToZ>();
+ TerminationPointBuilder terminationPointBuilder = new TerminationPointBuilder();
+ TerminationPoint terminationPoint = terminationPointBuilder
+ .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId("XPONDER-1-2")
+ .setTpId("XPONDER-1-2-" + tpId).build()).build();
+ TerminationPoint terminationPoint2 = terminationPointBuilder
+ .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId("XPONDER-1-2")
+ .setTpId("XPONDER-1-2-" + tpId).build()).build();
+ AToZ atoZ = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder()
+ .setResource(terminationPoint).build()).build();
+ AToZ atoZ2 = new AToZBuilder().setId("2").setKey(new AToZKey("2")).setResource(new ResourceBuilder()
+ .setResource(terminationPoint2).build()).build();
+ atoZList.add(atoZ);
+ atoZList.add(atoZ2);
+ AToZDirection atozDirection = new AToZDirectionBuilder()
+ .setRate(20L)
+ .setAToZWavelengthNumber(20L)
+ .setAToZ(atoZList)
+ .build();
+ List<ZToA> ztoAList = new ArrayList<ZToA>();
+ ZToA ztoA = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder()
+ .setResource(terminationPoint).build()).build();
+ ZToA ztoA2 = new ZToABuilder().setId("2").setKey(new ZToAKey("2")).setResource(new ResourceBuilder()
+ .setResource(terminationPoint).build()).build();
+ ztoAList.add(ztoA);
+ ztoAList.add(ztoA2);
+ ZToADirection ztoaDirection = new ZToADirectionBuilder()
+ .setRate(20L)
+ .setZToAWavelengthNumber(20L)
+ .setZToA(ztoAList)
+ .build();
+ PathDescriptionBuilder builder = new PathDescriptionBuilder()
+ .setAToZDirection(atozDirection)
+ .setZToADirection(ztoaDirection);
+ return builder.build();
+ }
+
+ private static PathDescription createPathDescriptionLinkResource() {
+ List<AToZ> atoZList = new ArrayList<AToZ>();
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource
+ .resource.resource.NodeBuilder nodesBuilder = new NodeBuilder();
+ Link link1 = new LinkBuilder().setLinkIdentifier(new LinkIdentifierBuilder().setLinkId("link 1").build())
+ .build();
+ Link link2 = new LinkBuilder().setLinkIdentifier(new LinkIdentifierBuilder().setLinkId("link 2").build())
+ .build();
+ AToZ atoZ = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder()
+ .setResource(link1).build()).build();
+ AToZ atoZ2 = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder()
+ .setResource(link2).build()).build();
+ atoZList.add(atoZ);
+ atoZList.add(atoZ2);
+ AToZDirection atozDirection = new AToZDirectionBuilder()
+ .setRate(20L)
+ .setAToZWavelengthNumber(20L)
+ .setAToZ(atoZList)
+ .build();
+ List<ZToA> ztoAList = new ArrayList<ZToA>();
+ ZToA ztoA = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder()
+ .setResource(link1).build()).build();
+ ZToA ztoA2 = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder()
+ .setResource(link2).build()).build();
+ ztoAList.add(ztoA);
+ ztoAList.add(ztoA2);
+ ZToADirection ztoaDirection = new ZToADirectionBuilder()
+ .setRate(20L)
+ .setZToAWavelengthNumber(20L)
+ .setZToA(ztoAList)
+ .build();
+ PathDescriptionBuilder builder = new PathDescriptionBuilder()
+ .setAToZDirection(atozDirection)
+ .setZToADirection(ztoaDirection);
+ return builder.build();
+ }
+
+ public static ServiceAEndBuilder getServiceAEndBuild() {
+ return new ServiceAEndBuilder()
+ .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
+ .setTxDirection(
+ new 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())
+ .build())
+ .setRxDirection(
+ new 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())
+ .build());
+ }
+
+ public static ServiceZEndBuilder getServiceZEndBuild() {
+ return new ServiceZEndBuilder()
+ .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate((long) 1).setNodeId("XPONDER-1-2")
+ .setTxDirection(
+ new 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())
+ .build())
+ .setRxDirection(
+ new 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())
+ .build());
+ }
+
+}