Yuta HIGUCHI

bugfix Function input is Nullable

Change-Id: Ie492fd070e300bbe6a2796805ba5f2c8a50c7248
......@@ -12,8 +12,12 @@ public final class ControllerNodeToNodeId
@Override
public NodeId apply(ControllerNode input) {
if (input == null) {
return null;
} else {
return input.id();
}
}
/**
* Returns a Function to convert ControllerNode to NodeId.
......
package org.onlab.onos.cluster;
import static com.google.common.base.Predicates.notNull;
import static org.junit.Assert.*;
import static org.onlab.onos.cluster.ControllerNodeToNodeId.toNodeId;
......@@ -30,12 +31,13 @@ public class ControllerNodeToNodeIdTest {
@Test
public final void testToNodeId() {
final Iterable<ControllerNode> nodes = Arrays.asList(CN1, CN2, CN3);
final Iterable<ControllerNode> nodes = Arrays.asList(CN1, CN2, CN3, null);
final List<NodeId> nodeIds = Arrays.asList(NID1, NID2, NID3);
assertEquals(nodeIds,
FluentIterable.from(nodes)
.transform(toNodeId())
.filter(notNull())
.toList());
}
......