Skip to content

Commit

Permalink
Merge pull request #6217 from bstansberry/WFCORE-6962_take2
Browse files Browse the repository at this point in the history
[WFCORE-6962] Add another check that candidates exist
  • Loading branch information
yersan authored Oct 16, 2024
2 parents 45005b6 + 1271dac commit 759fd65
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class OverallInterfaceCriteriaUnitTestCase {
@Test
public void testBasic() throws Exception {

Assume.assumeFalse(allCandidates.size() < 1);
Assume.assumeFalse(allCandidates.isEmpty());

Map.Entry<NetworkInterface, Set<InetAddress>> correct = allCandidates.entrySet().iterator().next();

Expand All @@ -60,7 +60,7 @@ public void testBasic() throws Exception {
@Test
public void testMultipleCriteria() throws Exception {

Assume.assumeFalse(nonLoopBackInterfaces.size() < 1 || loopbackInterfaces.size() < 1);
Assume.assumeFalse(nonLoopBackInterfaces.isEmpty() || loopbackInterfaces.isEmpty());

Map<NetworkInterface, Set<InetAddress>> correct = new HashMap<NetworkInterface, Set<InetAddress>>();
for (NetworkInterface ni : loopbackInterfaces) {
Expand All @@ -69,7 +69,7 @@ public void testMultipleCriteria() throws Exception {
}
}

Assume.assumeFalse(correct.size() == 0);
Assume.assumeFalse(correct.isEmpty());

Set<InterfaceCriteria> criterias = new HashSet<InterfaceCriteria>();
criterias.add(UpInterfaceCriteria.INSTANCE);
Expand All @@ -89,11 +89,11 @@ public void testMultipleCriteria() throws Exception {
@Test
public void testMultipleMatches() throws Exception {

Assume.assumeFalse(allCandidates.size() < 1);
Assume.assumeFalse(allCandidates.isEmpty());

Map<NetworkInterface, Set<InetAddress>> correct = new HashMap<NetworkInterface, Set<InetAddress>>();
for (NetworkInterface ni : allInterfaces) {
if (ni.isUp()) {
if (ni.isUp() && allCandidates.containsKey(ni)) {
correct.put(ni, getRightTypeAddresses(allCandidates.get(ni)));
}
}
Expand All @@ -115,7 +115,7 @@ public void testMultipleMatches() throws Exception {
@Test
public void testNoMatch() throws Exception {

Assume.assumeFalse(loopbackInterfaces.size() < 1);
Assume.assumeFalse(loopbackInterfaces.isEmpty());

for (NetworkInterface nic : allCandidates.keySet()) {
Assume.assumeFalse("bogus".equals(nic.getName()));
Expand All @@ -134,8 +134,8 @@ public void testNoMatch() throws Exception {
/** WFCORE-2626 */
@Test
public void testInetAddressDuplicates() throws Exception {
Assume.assumeFalse(loopbackInterfaces.size() < 1);
Assume.assumeFalse(nonLoopBackInterfaces.size() < 1);
Assume.assumeFalse(loopbackInterfaces.isEmpty());
Assume.assumeFalse(nonLoopBackInterfaces.isEmpty());

// Build up a fake candidate set where the same addresses appear associated with 2 NICs, one up, one down
// This simulates an environment with multiple NICs with the same address configured
Expand All @@ -150,7 +150,7 @@ public void testInetAddressDuplicates() throws Exception {
down = nic;
} else if (addresses == null && nic.isUp()) {
Set<InetAddress> nicAddresses = allCandidates.get(nic);
if (nicAddresses.size() > 0) {
if (!nicAddresses.isEmpty()) {
addresses = nicAddresses;
up = nic;
}
Expand Down

0 comments on commit 759fd65

Please sign in to comment.