Skip to content

Commit

Permalink
move assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ywelsch committed Oct 16, 2018
1 parent f196a2a commit 6589027
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,15 @@ ClusterNode getAnyNode() {
}

ClusterNode getAnyNodeExcept(ClusterNode... clusterNodes) {
return randomFrom(getAllNodesExcept(clusterNodes));
List<ClusterNode> filteredNodes = getAllNodesExcept(clusterNodes);
assert filteredNodes.isEmpty() == false;
return randomFrom(filteredNodes);
}

List<ClusterNode> getAllNodesExcept(ClusterNode... clusterNodes) {
Set<String> forbiddenIds = Arrays.stream(clusterNodes).map(ClusterNode::getId).collect(Collectors.toSet());
List<ClusterNode> acceptableNodes
= this.clusterNodes.stream().filter(n -> forbiddenIds.contains(n.getId()) == false).collect(Collectors.toList());
assert acceptableNodes.isEmpty() == false;
return acceptableNodes;
}

Expand Down

0 comments on commit 6589027

Please sign in to comment.