### Question:
UriUtils { public static String extractEtherAddressFromUri(String uri) throws InvalidEthereumAddressException { String uriWithoutSchema = uri.replaceFirst("ethereum:", ""); uriWithoutSchema = Numeric.cleanHexPrefix(uriWithoutSchema); if (uriWithoutSchema.length() != 40) { throw new InvalidEthereumAddressException( "Invalid address. The Ethereum address does not match the 40 char length!"); } boolean hasChecksum = !uriWithoutSchema.equals(uriWithoutSchema.toLowerCase()) && !uriWithoutSchema.equals(uriWithoutSchema.toUpperCase()); uriWithoutSchema = Numeric.prependHexPrefix(uriWithoutSchema); if (hasChecksum) { if (!uriWithoutSchema.equals(Keys.toChecksumAddress(uriWithoutSchema))) { throw new InvalidEthereumAddressException("Wrong checksum. The Ethereum address is invalid!"); } } return uriWithoutSchema; }  static String extractEtherAddressFromUri(String uri);  }### Answer:
@Test public void extractEtherAddressWithChecksum() throws InvalidEthereumAddressException { final String result = UriUtils.extractEtherAddressFromUri("6e670c473A2AD5894aE354b832aD4BADF1d919bf"); assertEquals("0x6e670c473A2AD5894aE354b832aD4BADF1d919bf", result); }
@Test public void extractEtherAddressWithoutChecksum() throws InvalidEthereumAddressException { final String result = UriUtils.extractEtherAddressFromUri("0x6e670c473a2ad5894ae354b832ad4badf1d919bf"); assertEquals("0x6e670c473a2ad5894ae354b832ad4badf1d919bf", result); }
@Test(expected = InvalidEthereumAddressException.class) public void extractEtherAddressWithoutInvalidLength() throws InvalidEthereumAddressException { UriUtils.extractEtherAddressFromUri("0x6e670c473a2ad5894ae354b832ad4badf1d919bfttttttttttttttttt"); }
@Test public void extractEtherAddressWithSchema() throws InvalidEthereumAddressException { final String result = UriUtils.extractEtherAddressFromUri("ethereum:6e670c473A2AD5894aE354b832aD4BADF1d919bf"); assertEquals("0x6e670c473A2AD5894aE354b832aD4BADF1d919bf", result); }
@Test(expected = InvalidEthereumAddressException.class) public void extractEtherAddressWithInvalidChecksum() throws InvalidEthereumAddressException { UriUtils.extractEtherAddressFromUri("0x6e670c473A2AD5894aE354b832aD4BADF1d919bF"); }
@Test public void extractEtherAddressWithUppercaseLetters() throws InvalidEthereumAddressException { final String result = UriUtils.extractEtherAddressFromUri("0x6E670C473A2AD5894AE354B832AD4BADF1D919BF"); assertEquals("0x6E670C473A2AD5894AE354B832AD4BADF1D919BF", result); }