CidrBlockValidator { public void validate(List<String> cidrBlocks) { cidrBlocks.forEach(cidrBlock -> { try { new SubnetUtils(cidrBlock); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( String.format("%s is not a valid CIDR Block: %s", cidrBlock, e.getMessage())); } }); }  void validate(List<String> cidrBlocks);  }
@Test public void validCidrBlock() throws Exception { underTest.validate(singletonList("0.0.0.0/0")); }
@Test(expected = IllegalArgumentException.class) public void invalidCidrBlock() throws Exception { underTest.validate(singletonList("cidrBlock")); }