ARPInfo { public static String getIPAddressFromMAC(String macAddress) { if (macAddress == null) { return null; } if (!macAddress.matches("..:..:..:..:..:..")) { throw new IllegalArgumentException("Invalid MAC Address"); } HashMap<String, String> cache = getAllIPAndMACAddressesInARPCache(); for (String ip : cache.keySet()) { if (cache.get(ip).equalsIgnoreCase(macAddress)) { return ip; } } return null; } private  ARPInfo(); static String getMACFromIPAddress(String ip); static String getIPAddressFromMAC(String macAddress); static ArrayList<String> getAllIPAddressesInARPCache(); static ArrayList<String> getAllMACAddressesInARPCache(); static HashMap<String, String> getAllIPAndMACAddressesInARPCache();  }
@Test(expected = IllegalArgumentException.class) public void testIllegalArgumentThrownOnInvalidMACaddress() { ARPInfo.getIPAddressFromMAC("00:00:00:xx"); }