equal
deleted
inserted
replaced
83 getAllSubNetworkInterfaces(sni, result); |
83 getAllSubNetworkInterfaces(sni, result); |
84 } |
84 } |
85 } |
85 } |
86 |
86 |
87 private Stream<NetworkInterface> allNetworkInterfaces() throws SocketException { |
87 private Stream<NetworkInterface> allNetworkInterfaces() throws SocketException { |
88 return NetworkInterface.networkInterfaces().flatMap(this::allSubNetworkInterfaces); |
88 return NetworkInterface.networkInterfaces() |
|
89 .filter(ni -> isIncluded(ni)) |
|
90 .flatMap(this::allSubNetworkInterfaces); |
89 } |
91 } |
90 |
92 |
91 private Stream<NetworkInterface> allSubNetworkInterfaces(NetworkInterface ni) { |
93 private Stream<NetworkInterface> allSubNetworkInterfaces(NetworkInterface ni) { |
92 return Stream.concat( |
94 return Stream.concat( |
93 Stream.of(ni), |
95 Stream.of(ni), |
94 ni.subInterfaces().flatMap(this::allSubNetworkInterfaces)); |
96 ni.subInterfaces().filter(sni -> isIncluded(sni)).flatMap(this::allSubNetworkInterfaces)); |
95 } |
97 } |
96 |
98 |
97 @Test |
99 @Test |
98 public void testSubNetworkInterfaces() throws SocketException { |
100 public void testSubNetworkInterfaces() throws SocketException { |
99 Supplier<Stream<NetworkInterface>> ss = () -> { |
101 Supplier<Stream<NetworkInterface>> ss = () -> { |
127 }; |
129 }; |
128 |
130 |
129 Collection<NetworkInterface> nis = Collections.list(NetworkInterface.getNetworkInterfaces()); |
131 Collection<NetworkInterface> nis = Collections.list(NetworkInterface.getNetworkInterfaces()); |
130 Collection<InetAddress> expected = new ArrayList<>(); |
132 Collection<InetAddress> expected = new ArrayList<>(); |
131 for (NetworkInterface ni : nis) { |
133 for (NetworkInterface ni : nis) { |
132 expected.addAll(Collections.list(ni.getInetAddresses())); |
134 if (isIncluded(ni)) { |
|
135 expected.addAll(Collections.list(ni.getInetAddresses())); |
|
136 } |
133 } |
137 } |
134 withData(TestData.Factory.ofSupplier("All inet addresses", ss)) |
138 withData(TestData.Factory.ofSupplier("All inet addresses", ss)) |
135 .stream(s -> s) |
139 .stream(s -> s) |
136 .expectedResult(expected) |
140 .expectedResult(expected) |
137 .exercise(); |
141 .exercise(); |