### Question:
BitcoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } BitcoinURI(String uri);  BitcoinURI(@Nullable NetworkParameters params, String input); @Nullable Address getAddress(); Coin getAmount(); String getLabel(); String getMessage(); final String getPaymentRequestUrl(); List<String> getPaymentRequestUrls(); Object getParameterByName(String name); @Override String toString(); static String convertToBitcoinURI(Address address, Coin amount,
                                             String label, String message); static String convertToBitcoinURI(NetworkParameters params,
                                             String address, @Nullable Coin amount,
                                             @Nullable String label, @Nullable String message); static final String FIELD_MESSAGE; static final String FIELD_LABEL; static final String FIELD_AMOUNT; static final String FIELD_ADDRESS; static final String FIELD_PAYMENT_REQUEST_URL; @Deprecated
    static final String BITCOIN_SCHEME; }### Answer:
@Test public void testBad_BadSyntax() { try { testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + "|" + MAINNET_GOOD_ADDRESS); fail("Expecting BitcoinURIParseException"); } catch (BitcoinURIParseException e) { assertTrue(e.getMessage().contains("Bad URI syntax")); } try { testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS + "\\"); fail("Expecting BitcoinURIParseException"); } catch (BitcoinURIParseException e) { assertTrue(e.getMessage().contains("Bad URI syntax")); } try { testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":"); fail("Expecting BitcoinURIParseException"); } catch (BitcoinURIParseException e) { assertTrue(e.getMessage().contains("Bad URI syntax")); } }
@Test public void testBad_IncorrectAddressType() { try { testObject = new BitcoinURI(TESTNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS); fail("Expecting BitcoinURIParseException"); } catch (BitcoinURIParseException e) { assertTrue(e.getMessage().contains("Bad address")); } }
@Test public void testGood_Message() throws BitcoinURIParseException { testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS + "?message=Hello%20World"); assertEquals("Hello World", testObject.getMessage()); }
@Test public void testBad_Amount() throws BitcoinURIParseException { try { testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS + "?amount="); fail("Expecting BitcoinURIParseException"); } catch (BitcoinURIParseException e) { assertTrue(e.getMessage().contains("amount")); } try { testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS + "?amount=12X4"); fail("Expecting BitcoinURIParseException"); } catch (BitcoinURIParseException e) { assertTrue(e.getMessage().contains("amount")); } }
@Test public void testEmpty_Message() throws BitcoinURIParseException { assertNull(new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS + "?message=").getMessage()); }
@Test public void testBad_Duplicated() throws BitcoinURIParseException { try { testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS + "?address=aardvark"); fail("Expecting BitcoinURIParseException"); } catch (BitcoinURIParseException e) { assertTrue(e.getMessage().contains("address")); } }
@Test public void testBad_IncorrectAddressType() { try { testObject = new BitcoinURI(TestNet3Params.get(), BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS); fail("Expecting BitcoinURIParseException"); } catch (BitcoinURIParseException e) { assertTrue(e.getMessage().contains("Bad address")); } }