NodeConnectorTranslatorUtil 20/17520/3
authorVaclav Demcak <vdemcak@cisco.com>
Wed, 1 Apr 2015 08:26:10 +0000 (10:26 +0200)
committermichal rehak <mirehak@cisco.com>
Thu, 2 Apr 2015 11:14:51 +0000 (11:14 +0000)
Note: we need direct translation from OFJava models to
Invenotry models from PhyPort to FlowCapableNodeConnector.

* NodeConnectorTranslatorUtil
* NodeConnectorTranslatorUtilTest

Change-Id: Ibdd9293bd473b280aabdd4201aec65673ec0fa19
Signed-off-by: Vaclav Demcak <vdemcak@cisco.com>
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/OFConstants.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/util/OpenflowVersion.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/NodeConnectorTranslatorUtil.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/common/NodeConnectorTranslatorUtilTest.java [new file with mode: 0644]

index 8e85f68909e8244f056c4d6adc3b491500083bba..1dfb4fa16d46664d0b54a7064b81dd5272ba00c0 100644 (file)
@@ -12,10 +12,10 @@ import java.math.BigInteger;
 /**
  * OFP related constants
  */
-public class OFConstants {
+public final class OFConstants {
 
     private OFConstants() {
-        //hiding implicit constructor
+        throw new UnsupportedOperationException("OF plugin Constants holder class");
     }
 
     /** reserved port: process with normal L2/L3 switching  */
@@ -31,6 +31,8 @@ public class OFConstants {
     /** openflow protocol 1.3 - version identifier */
     public static final short OFP_VERSION_1_3 = 0x04;
 
+    public final static String OF_URI_PREFIX = "openflow:";
+
     public static final Short OFPTT_ALL = 0xff;
     public static final Long ANY = Long.parseLong("ffffffff", 16);
     public static final Long OFPP_ANY = ANY;
index 7baa5a9d4d6535dfee32d901dcb56167fd2e749b..663cd09691e1c53f708806cc8d0703884e83935f 100644 (file)
@@ -1,7 +1,11 @@
 package org.opendaylight.openflowplugin.api.openflow.md.util;
 
-/** List of Openflow versions supported by the plugin
- *  Note: If you add a version here, make sure to update org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil as well.
+/**
+ * @deprecated enum in api is not something what we would like to see in case it is evolving
+ * TODO: remove class for lithium release
+ *
+ * List of Openflow versions supported by the plugin
+ * Note: If you add a version here, make sure to update {@link OpenflowPortsUtil} as well.
  * Created by kramesha on 5/2/14.
  */
 public enum OpenflowVersion {
@@ -13,19 +17,19 @@ public enum OpenflowVersion {
 
     private short version;
 
-    OpenflowVersion(short version) {
+    OpenflowVersion(final short version) {
         this.version = version;
     }
 
-    public static OpenflowVersion get(Short version) {
-        for (OpenflowVersion ofv : OpenflowVersion.values()) {
+    public static OpenflowVersion get(final Short version) {
+        for (final OpenflowVersion ofv : OpenflowVersion.values()) {
             if (ofv.version == version) {
                 return ofv;
             }
         }
         return UNSUPPORTED;
     }
-    
+
     /**
      * @return the version
      */
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/NodeConnectorTranslatorUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/NodeConnectorTranslatorUtil.java
new file mode 100644 (file)
index 0000000..9afc37e
--- /dev/null
@@ -0,0 +1,156 @@
+/**
+ * Copyright (c) 2015 Cisco 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.openflowplugin.impl.common;
+
+import com.google.common.base.Preconditions;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
+
+/**
+ * openflowplugin-impl
+ * org.opendaylight.openflowplugin.impl.common
+ *
+ * Translator helper for Translating OF java models to MD-SAL inventory models.
+ * Translator focus for {@link NodeConnector} object and relevant OF augmentation
+ * {@link FlowCapableNodeConnector}.
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Mar 31, 2015
+ */
+public final class NodeConnectorTranslatorUtil {
+
+    private NodeConnectorTranslatorUtil () {
+        throw new UnsupportedOperationException("Utility class");
+    }
+
+    /**
+     * Method translates {@link PhyPort} object directly to {@link NodeConnector} which is augmented
+     * by {@link FlowCapableNodeConnector} and contains all relevant content translated by actual OF version.
+     *
+     * @param featuresReply
+     * @return
+     */
+    public static List<NodeConnector> translateNodeConnectorFromFeaturesReply(@CheckForNull final FeaturesReply featuresReply) {
+        Preconditions.checkArgument(featuresReply != null);
+        Preconditions.checkArgument(featuresReply.getPhyPort() != null);
+        final Short version = featuresReply.getVersion();
+        final BigInteger dataPathId = featuresReply.getDatapathId();
+        final List<NodeConnector> resultList = new ArrayList<>(featuresReply.getPhyPort().size());
+        for (final PhyPort port : featuresReply.getPhyPort()) {
+            final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
+            ncBuilder.setId(makeNodeConnectorId(dataPathId, port.getName(), port.getPortNo()));
+            ncBuilder.addAugmentation(FlowCapableNodeConnector.class, translateFlowCapableNodeFromPhyPort(port, version));
+            resultList.add(ncBuilder.build());
+        }
+        return resultList;
+    }
+
+    /**
+     * Method translates {@link PhyPort} object directly to {@link FlowCapableNodeConnector} which is augmented
+     * by {@link NodeConnector} and contains all relevant content translated by actual OF version.
+     *
+     * @param port
+     * @param version
+     * @return
+     */
+    public static FlowCapableNodeConnector translateFlowCapableNodeFromPhyPort(@CheckForNull final PhyPort port, final short version) {
+        Preconditions.checkArgument(port != null);
+        final FlowCapableNodeConnectorBuilder fcncBuilder = new FlowCapableNodeConnectorBuilder();
+        fcncBuilder.setHardwareAddress(port.getHwAddr());
+        fcncBuilder.setCurrentSpeed(port.getCurrSpeed());
+        fcncBuilder.setMaximumSpeed(port.getMaxSpeed());
+        fcncBuilder.setName(port.getName());
+        fcncBuilder.setPortNumber(new PortNumberUni(port.getPortNo()));
+        if (OFConstants.OFP_VERSION_1_3 == version) {
+            fcncBuilder.setAdvertisedFeatures(translatePortFeatures(port.getAdvertisedFeatures()));
+            fcncBuilder.setConfiguration(translatePortConfig(port.getConfig()));
+            fcncBuilder.setCurrentFeature(translatePortFeatures(port.getCurrentFeatures()));
+            fcncBuilder.setPeerFeatures(translatePortFeatures(port.getPeerFeatures()));
+            fcncBuilder.setSupported(translatePortFeatures(port.getSupportedFeatures()));
+            fcncBuilder.setState(translatePortState(port.getState()));
+        } else if (OFConstants.OFP_VERSION_1_0 == version) {
+            fcncBuilder.setAdvertisedFeatures(translatePortFeatures(port.getAdvertisedFeaturesV10()));
+            fcncBuilder.setConfiguration(translatePortConfig(port.getConfigV10()));
+            fcncBuilder.setCurrentFeature(translatePortFeatures(port.getCurrentFeaturesV10()));
+            fcncBuilder.setPeerFeatures(translatePortFeatures(port.getPeerFeaturesV10()));
+            fcncBuilder.setSupported(translatePortFeatures(port.getSupportedFeaturesV10()));
+            fcncBuilder.setState(translatePortState(port.getStateV10()));
+        } else {
+            throw new IllegalArgumentException("Unknown OF version " + version);
+        }
+        return fcncBuilder.build();
+    }
+
+    private static PortConfig translatePortConfig(@CheckForNull final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig pc) {
+        Preconditions.checkArgument(pc != null);
+        return new PortConfig(pc.isNoFwd(), pc.isNoPacketIn(), pc.isNoRecv(), pc.isPortDown());
+    }
+
+    private static PortConfig translatePortConfig(@CheckForNull final PortConfigV10 pc) {
+        Preconditions.checkArgument(pc != null);
+        return new PortConfig(pc.isNoFwd(), pc.isNoPacketIn(), pc.isNoRecv(), pc.isPortDown());
+    }
+
+    private static PortFeatures translatePortFeatures(@CheckForNull final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures pf) {
+        Preconditions.checkArgument(pf != null);
+        return new PortFeatures(pf.isAutoneg(), pf.isCopper(), pf.isFiber(), pf.is_40gbFd(), pf.is_100gbFd(), pf.is_100mbFd(), pf.is_100mbHd(),
+                pf.is_1gbFd(), pf.is_1gbHd(), pf.is_1tbFd(), pf.isOther(), pf.isPause(), pf.isPauseAsym(), pf.is_10gbFd(), pf.is_10mbFd(), pf.is_10mbHd());
+    }
+
+    private static PortFeatures translatePortFeatures(@CheckForNull final PortFeaturesV10 pf) {
+        Preconditions.checkArgument(pf != null);
+        return new PortFeatures(pf.isAutoneg(), pf.isCopper(), pf.isFiber(), Boolean.FALSE, Boolean.FALSE, pf.is_100mbFd(), pf.is_100mbHd(),
+                pf.is_1gbFd(), pf.is_1gbHd(), Boolean.FALSE, Boolean.FALSE, pf.isPause(), pf.isPauseAsym(), pf.is_10gbFd(), pf.is_10mbFd(), pf.is_10mbHd());
+    }
+
+    private static State translatePortState(@CheckForNull final PortState state) {
+        Preconditions.checkArgument(state != null);
+        return new StateBuilder().setBlocked(state.isBlocked()).setLinkDown(state.isLinkDown()).setLive(state.isLive()).build();
+    }
+
+    private static State translatePortState(@CheckForNull final PortStateV10 state) {
+        Preconditions.checkArgument(state != null);
+        return new StateBuilder().setBlocked(state.isBlocked()).setLinkDown(state.isLinkDown()).setLive(state.isLive()).build();
+    }
+
+    /**
+     * Method makes NodeConnectorId with prefix  "openflow:" from dataPathId and logical name or port number
+     *
+     * @param dataPathId
+     * @param logicalName
+     * @param portNo
+     * @return
+     */
+    public static NodeConnectorId makeNodeConnectorId(@CheckForNull final BigInteger dataPathId,
+            @Nullable final String logicalName, final long portNo) {
+        Preconditions.checkArgument(dataPathId != null);
+        return new NodeConnectorId(OFConstants.OF_URI_PREFIX + dataPathId + ":" + (logicalName == null ? portNo : logicalName));
+    }
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/common/NodeConnectorTranslatorUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/common/NodeConnectorTranslatorUtilTest.java
new file mode 100644 (file)
index 0000000..8450a79
--- /dev/null
@@ -0,0 +1,280 @@
+/**
+ * Copyright (c) 2015 Cisco 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.openflowplugin.impl.common;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
+
+/**
+ * openflowplugin-impl
+ * org.opendaylight.openflowplugin.impl.common
+ *
+ * Test class for testing {@link org.opendaylight.openflowplugin.impl.common.NodeConnectorTranslatorUtil}
+ *
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ * Created: Mar 31, 2015
+ */
+public class NodeConnectorTranslatorUtilTest {
+
+    private static final String MAC_ADDRESS = "00:01:02:03:04:05";
+    private static final String NAME = "PortTranslatorTest";
+    private final Boolean[] pfBls = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
+    private final boolean[] pfV10Bls = {false, false, false, false, false, false, false, false, false, false, false, false};
+    private final boolean[] portCfgBools = {false, false, false, false};
+    private final boolean[] portCfgV10bools = {false, false, false, false, false, false, false};
+    private final boolean[] portStateBools = {false, false, false, false};
+    private final Long currentSpeed = Long.decode("4294967295");
+    private static final Long maxSpeed = Long.decode("4294967295");
+
+    /**
+     * Test method for {@link NodeConnectorTranslatorUtil#translateNodeConnectorFromFeaturesReply(FeaturesReply)}.
+     */
+    @Test
+    public void testTranslateNodeConnectorFromFeaturesReply(){
+        final FeaturesReply reply = mock(FeaturesReply.class);
+        final BigInteger dataPathId = new BigInteger("25");
+        final List<PhyPort> listPorts = Arrays.asList(mockPhyPortPort());
+        when(reply.getPhyPort()).thenReturn(listPorts);
+        when(reply.getDatapathId()).thenReturn(dataPathId);
+        when(reply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        final List<NodeConnector> nodeConnector = NodeConnectorTranslatorUtil.translateNodeConnectorFromFeaturesReply(reply);
+        Assert.assertNotNull(nodeConnector);
+        Assert.assertEquals(1, nodeConnector.size());
+    }
+
+    /**
+     * Test method for {@link NodeConnectorTranslatorUtil#translateNodeConnectorFromFeaturesReply(FeaturesReply)}.
+     * {@link IllegalArgumentException}
+     */
+    @Test(expected=IllegalArgumentException.class)
+    public void testTranslateNodeConnectorFromFeaturesReplyNullPorts(){
+        final FeaturesReply reply = mock(FeaturesReply.class);
+        when(reply.getPhyPort()).thenReturn(null);
+        NodeConnectorTranslatorUtil.translateNodeConnectorFromFeaturesReply(reply);
+    }
+
+    /**
+     * Test method for {@link NodeConnectorTranslatorUtil#translateNodeConnectorFromFeaturesReply(FeaturesReply)}.
+     * {@link IllegalArgumentException}
+     */
+    @Test(expected=IllegalArgumentException.class)
+    public void testTranslateNodeConnectorFromFeaturesReplyNullReplay(){
+        NodeConnectorTranslatorUtil.translateNodeConnectorFromFeaturesReply(null);
+    }
+
+    /**
+     * Test method for {@link NodeConnectorTranslatorUtil#translateFlowCapableNodeFromPhyPort(PhyPort, short)}.
+     */
+    @Test
+    public void testTranslateFlowCapableNodeFromPhyPortOF10(){
+        final PhyPort port = mockPhyPortPort();
+        final FlowCapableNodeConnector flowCapableNodeConnector = NodeConnectorTranslatorUtil
+                .translateFlowCapableNodeFromPhyPort(port, OFConstants.OFP_VERSION_1_0);
+        Assert.assertNotNull(flowCapableNodeConnector);
+        Assert.assertEquals(port.getName(), flowCapableNodeConnector.getName());
+        Assert.assertEquals(port.getPortNo(), flowCapableNodeConnector.getPortNumber().getUint32());
+        Assert.assertEquals(port.getHwAddr().getValue(), flowCapableNodeConnector.getHardwareAddress().getValue());
+        Assert.assertEquals(port.getCurrSpeed(), flowCapableNodeConnector.getCurrentSpeed());
+        Assert.assertEquals(port.getMaxSpeed(), flowCapableNodeConnector.getMaximumSpeed());
+        assertEqualsStateV10(port.getStateV10(), flowCapableNodeConnector.getState());
+        assertEqualsPortFeaturesV10(port.getAdvertisedFeaturesV10(), flowCapableNodeConnector.getAdvertisedFeatures());
+        assertEqualsPortFeaturesV10(port.getCurrentFeaturesV10(), flowCapableNodeConnector.getCurrentFeature());
+        assertEqualsPortFeaturesV10(port.getPeerFeaturesV10(), flowCapableNodeConnector.getPeerFeatures());
+        assertEqualsPortFeaturesV10(port.getSupportedFeaturesV10(), flowCapableNodeConnector.getSupported());
+
+    }
+
+    /**
+     * Test method for {@link NodeConnectorTranslatorUtil#translateFlowCapableNodeFromPhyPort(PhyPort, short)}.
+     */
+    @Test
+    public void testTranslateFlowCapableNodeFromPhyPortOF13(){
+        final PhyPort port = mockPhyPortPort();
+        final FlowCapableNodeConnector flowCapableNodeConnector = NodeConnectorTranslatorUtil
+                .translateFlowCapableNodeFromPhyPort(port, OFConstants.OFP_VERSION_1_3);
+        Assert.assertNotNull(flowCapableNodeConnector);
+        Assert.assertEquals(port.getName(), flowCapableNodeConnector.getName());
+        Assert.assertEquals(port.getPortNo(), flowCapableNodeConnector.getPortNumber().getUint32());
+        Assert.assertEquals(port.getHwAddr().getValue(), flowCapableNodeConnector.getHardwareAddress().getValue());
+        Assert.assertEquals(port.getCurrSpeed(), flowCapableNodeConnector.getCurrentSpeed());
+        Assert.assertEquals(port.getMaxSpeed(), flowCapableNodeConnector.getMaximumSpeed());
+        assertEqualsState(port.getState(), flowCapableNodeConnector.getState());
+        assertEqualsPortFeatures(port.getAdvertisedFeatures(), flowCapableNodeConnector.getAdvertisedFeatures());
+        assertEqualsPortFeatures(port.getCurrentFeatures(), flowCapableNodeConnector.getCurrentFeature());
+        assertEqualsPortFeatures(port.getPeerFeatures(), flowCapableNodeConnector.getPeerFeatures());
+        assertEqualsPortFeatures(port.getSupportedFeatures(), flowCapableNodeConnector.getSupported());
+    }
+
+    /**
+     * Test method for {@link NodeConnectorTranslatorUtil#makeNodeConnectorId(BigInteger, String, long)}.
+     */
+    @Test
+    public void testMakeNodeConnectorId(){
+        final BigInteger dataPathId = new BigInteger("25");
+        final String logicalName = "testPort";
+        final long portNo = 45L;
+        final NodeConnectorId nodeConnectorId = NodeConnectorTranslatorUtil.makeNodeConnectorId(dataPathId, logicalName, portNo);
+        Assert.assertNotNull(nodeConnectorId);
+        Assert.assertNotNull(nodeConnectorId.getValue());
+        Assert.assertTrue(nodeConnectorId.getValue().contains(logicalName));
+        Assert.assertTrue(nodeConnectorId.getValue().contains(dataPathId.toString()));
+        Assert.assertFalse(nodeConnectorId.getValue().contains(":" + portNo));
+    }
+
+    /**
+     * Test method for {@link NodeConnectorTranslatorUtil#makeNodeConnectorId(BigInteger, String, long)}.
+     */
+    @Test
+    public void testMakeNodeConnectorIdNullLogicalName(){
+        final BigInteger dataPathId = new BigInteger("25");
+        final long portNo = 45L;
+        final NodeConnectorId nodeConnectorId = NodeConnectorTranslatorUtil.makeNodeConnectorId(dataPathId, null, portNo);
+        Assert.assertNotNull(nodeConnectorId);
+        Assert.assertNotNull(nodeConnectorId.getValue());
+        Assert.assertTrue(nodeConnectorId.getValue().contains(dataPathId.toString()));
+        Assert.assertTrue(nodeConnectorId.getValue().contains(":" + portNo));
+    }
+
+    /**
+     * Test method for {@link NodeConnectorTranslatorUtil#makeNodeConnectorId(BigInteger, String, long)}.
+     * expect {@link IllegalArgumentException}
+     */
+    @Test(expected=IllegalArgumentException.class)
+    public void testMakeNodeConnectorIdNullDataPath(){
+        final long portNo = 45L;
+        NodeConnectorTranslatorUtil.makeNodeConnectorId(null, null, portNo);
+    }
+
+    private PhyPort mockPhyPortPort() {
+        final PhyPort phyport = mock(PhyPort.class);
+        when(phyport.getAdvertisedFeatures()).thenReturn(getPortFeatures());
+        when(phyport.getAdvertisedFeaturesV10()).thenReturn(getPortFeaturesV10());
+        when(phyport.getConfig()).thenReturn(getPortConfig());
+        when(phyport.getConfigV10()).thenReturn(getPortConfigV10());
+        when(phyport.getCurrentFeatures()).thenReturn(getPortFeatures());
+        when(phyport.getCurrentFeaturesV10()).thenReturn(getPortFeaturesV10());
+        when(phyport.getCurrSpeed()).thenReturn(currentSpeed);
+        when(phyport.getHwAddr()).thenReturn(getMacAddress());
+        when(phyport.getName()).thenReturn(NAME);
+        when(phyport.getMaxSpeed()).thenReturn(maxSpeed);
+        when(phyport.getPeerFeatures()).thenReturn(getPortFeatures());
+        when(phyport.getPeerFeaturesV10()).thenReturn(getPortFeaturesV10());
+        when(phyport.getPortNo()).thenReturn(Long.MAX_VALUE);
+        when(phyport.getState()).thenReturn(getPortState());
+        when(phyport.getStateV10()).thenReturn(getPortStateV10());
+        when(phyport.getSupportedFeatures()).thenReturn(getPortFeatures());
+        when(phyport.getSupportedFeaturesV10()).thenReturn(getPortFeaturesV10());
+        return phyport;
+    }
+
+    private PortStateV10 getPortStateV10() {
+        final PortStateV10 portState = new PortStateV10(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
+        return portState;
+    }
+
+    private PortState getPortState() {
+        final PortState portState = new PortState(portStateBools[0], portStateBools[1], portStateBools[2]);
+        return portState;
+    }
+
+    private PortFeatures getPortFeatures() {
+        return new PortFeatures(pfBls[0], pfBls[1], pfBls[2], pfBls[3], pfBls[4], pfBls[5], pfBls[6], pfBls[7], pfBls[8],
+                pfBls[9], pfBls[10], pfBls[11], pfBls[12], pfBls[13], pfBls[14], pfBls[15]);
+    }
+
+    private PortFeaturesV10 getPortFeaturesV10() {
+        return new PortFeaturesV10(pfV10Bls[0], pfV10Bls[1], pfV10Bls[2], pfV10Bls[3], pfV10Bls[4], pfV10Bls[5], pfV10Bls[6],
+                pfV10Bls[7], pfV10Bls[8], pfV10Bls[9], pfV10Bls[10], pfV10Bls[11]);
+    }
+
+    private MacAddress getMacAddress() {
+        return new MacAddress(MAC_ADDRESS);
+    }
+
+    private PortConfigV10 getPortConfigV10() {
+        return new PortConfigV10(portCfgV10bools[0], portCfgV10bools[1], portCfgV10bools[2], portCfgV10bools[3], portCfgV10bools[4], portCfgV10bools[5], portCfgV10bools[6]);
+    }
+
+    private PortConfig getPortConfig() {
+        return new PortConfig(portCfgBools[0], portCfgBools[1], portCfgBools[2], portCfgBools[3]);
+    }
+
+    private void assertEqualsStateV10(final PortStateV10 psV10, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState state) {
+        assertEquals(psV10.isBlocked(), state.isBlocked());
+        assertEquals(psV10.isLinkDown(), state.isLinkDown());
+        assertEquals(psV10.isLive(), state.isLive());
+    }
+
+    private void assertEqualsState(final PortState ps, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState state) {
+        assertEquals(ps.isBlocked(), state.isBlocked());
+        assertEquals(ps.isLinkDown(), state.isLinkDown());
+        assertEquals(ps.isLive(), state.isLive());
+    }
+
+    private void assertEqualsPortFeaturesV10(final PortFeaturesV10 apfV10, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf) {
+        assertEquals(apfV10.is_100mbFd(), npf.isHundredMbFd());
+        assertEquals(apfV10.is_100mbHd(), npf.isHundredMbHd());
+
+        assertEquals(apfV10.is_10gbFd(), npf.isTenGbFd());
+        assertEquals(apfV10.is_10mbFd(), npf.isTenMbFd());
+        assertEquals(apfV10.is_10mbHd(), npf.isTenMbHd());
+
+        assertEquals(apfV10.is_1gbFd(), npf.isOneGbFd());
+        assertEquals(apfV10.is_1gbHd(), npf.isOneGbHd());
+
+        assertEquals(apfV10.isAutoneg(), npf.isAutoeng());
+        assertEquals(apfV10.isCopper(), npf.isCopper());
+        assertEquals(apfV10.isFiber(), npf.isFiber());
+        assertEquals(apfV10.isPause(), npf.isPause());
+        assertEquals(apfV10.isPauseAsym(), npf.isPauseAsym());
+    }
+
+    private void assertEqualsPortFeatures(final PortFeatures apf, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf) {
+        assertEquals(apf.is_100gbFd(), npf.isHundredGbFd());
+        assertEquals(apf.is_100mbFd(), npf.isHundredMbFd());
+        assertEquals(apf.is_100mbHd(), npf.isHundredMbHd());
+
+        assertEquals(apf.is_10gbFd(), npf.isTenGbFd());
+        assertEquals(apf.is_10mbFd(), npf.isTenMbFd());
+        assertEquals(apf.is_10mbHd(), npf.isTenMbHd());
+
+        assertEquals(apf.is_1gbFd(), npf.isOneGbFd());
+        assertEquals(apf.is_1gbHd(), npf.isOneGbHd());
+        assertEquals(apf.is_1tbFd(), npf.isOneTbFd());
+
+        assertEquals(apf.is_40gbFd(), npf.isFortyGbFd());
+
+        assertEquals(apf.isAutoneg(), npf.isAutoeng());
+        assertEquals(apf.isCopper(), npf.isCopper());
+        assertEquals(apf.isFiber(), npf.isFiber());
+        assertEquals(apf.isOther(), npf.isOther());
+        assertEquals(apf.isPause(), npf.isPause());
+        assertEquals(apf.isPauseAsym(), npf.isPauseAsym());
+    }
+}