- replaced Long with BigInteger in order to capture value greater then maxLong
- added unit test for that
Change-Id: I17d8b0c54c5c084d428883f33aa0972e3dd986ed
Signed-off-by: Michal Rehak <mirehak@cisco.com>
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import org.opendaylight.controller.sal.common.util.Arguments;
import org.opendaylight.controller.sal.core.AdvertisedBandwidth;
import org.opendaylight.controller.sal.core.Bandwidth;
import org.opendaylight.controller.sal.common.util.Arguments;
import org.opendaylight.controller.sal.core.AdvertisedBandwidth;
import org.opendaylight.controller.sal.core.Bandwidth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
+ * @return nodeId as long
- private static Long openflowFullNodeIdToLong(String adNodeId) {
+ @VisibleForTesting
+ public static Long openflowFullNodeIdToLong(String adNodeId) {
if (adNodeId == null) {
return null;
}
if (adNodeId == null) {
return null;
}
- return Long.valueOf(adNodeId.replaceFirst("^.*:", ""));
+ return new BigInteger(adNodeId.replaceFirst("^.*:", "")).longValue();
}
public static NodeId toNodeId(final InstanceIdentifier<?> id) {
}
public static NodeId toNodeId(final InstanceIdentifier<?> id) {
Assert.assertEquals("openflow:1", observedNodeConnectorId);
}
Assert.assertEquals("openflow:1", observedNodeConnectorId);
}
+ /**
+ * Test method for
+ * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#openflowFullNodeIdToLong(String)}
+ * .
+ * @throws ConstructionException
+ */
+ @Test
+ public void testOpenflowFullNodeIdToLong() throws ConstructionException {
+ Assert.assertEquals(42L, NodeMapping.openflowFullNodeIdToLong("42").longValue());
+ Assert.assertEquals(0xCC4E241C4A000000L, NodeMapping.openflowFullNodeIdToLong("14721743935839928320").longValue());
+ }
+
/**
* @param nodeId
* @param portId
/**
* @param nodeId
* @param portId