Yuta HIGUCHI | dc7374c | 2014-10-10 11:11:09 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cluster; |
| 2 | |
| 3 | import static org.junit.Assert.*; |
| 4 | import static org.onlab.onos.cluster.ControllerNodeToNodeId.toNodeId; |
| 5 | |
| 6 | import java.util.Arrays; |
| 7 | import java.util.List; |
| 8 | |
| 9 | import org.junit.Test; |
| 10 | import org.onlab.packet.IpPrefix; |
| 11 | |
| 12 | import com.google.common.collect.FluentIterable; |
| 13 | |
| 14 | |
| 15 | public class ControllerNodeToNodeIdTest { |
| 16 | |
| 17 | private static final NodeId NID1 = new NodeId("foo"); |
| 18 | private static final NodeId NID2 = new NodeId("bar"); |
| 19 | private static final NodeId NID3 = new NodeId("buz"); |
| 20 | |
| 21 | private static final IpPrefix IP1 = IpPrefix.valueOf("127.0.0.1"); |
| 22 | private static final IpPrefix IP2 = IpPrefix.valueOf("127.0.0.2"); |
| 23 | private static final IpPrefix IP3 = IpPrefix.valueOf("127.0.0.3"); |
| 24 | |
| 25 | private static final ControllerNode CN1 = new DefaultControllerNode(NID1, IP1); |
| 26 | private static final ControllerNode CN2 = new DefaultControllerNode(NID2, IP2); |
| 27 | private static final ControllerNode CN3 = new DefaultControllerNode(NID3, IP3); |
| 28 | |
| 29 | |
| 30 | @Test |
| 31 | public final void testToNodeId() { |
| 32 | |
| 33 | final Iterable<ControllerNode> nodes = Arrays.asList(CN1, CN2, CN3); |
| 34 | final List<NodeId> nodeIds = Arrays.asList(NID1, NID2, NID3); |
| 35 | |
| 36 | assertEquals(nodeIds, |
| 37 | FluentIterable.from(nodes) |
| 38 | .transform(toNodeId()) |
| 39 | .toList()); |
| 40 | } |
| 41 | |
| 42 | } |