@Test
public void testConvertToBitcoinURI() throws Exception {

    Address goodAddress = LegacyAddress.fromBase58(MAINNET, MAINNET_GOOD_ADDRESS);
    
    // simple example
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?amount=12.34&label=Hello&message=AMessage", UlordURI.convertToBitcoinURI(goodAddress, parseCoin("12.34"), "Hello", "AMessage"));
    
    // example with spaces, ampersand and plus
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?amount=12.34&label=Hello%20World&message=Mess%20%26%20age%20%2B%20hope", UlordURI.convertToBitcoinURI(goodAddress, parseCoin("12.34"), "Hello World", "Mess & age + hope"));
    // no amount, label present, message present
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?label=Hello&message=glory", UlordURI.convertToBitcoinURI(goodAddress, null, "Hello", "glory"));
    
    // amount present, no label, message present
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?amount=0.1&message=glory", UlordURI.convertToBitcoinURI(goodAddress, parseCoin("0.1"), null, "glory"));
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?amount=0.1&message=glory", UlordURI.convertToBitcoinURI(goodAddress, parseCoin("0.1"), "", "glory"));
    // amount present, label present, no message
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?amount=12.34&label=Hello", UlordURI.convertToBitcoinURI(goodAddress, parseCoin("12.34"), "Hello", null));
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?amount=12.34&label=Hello", UlordURI.convertToBitcoinURI(goodAddress, parseCoin("12.34"), "Hello", ""));
          
    // amount present, no label, no message
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?amount=1000", UlordURI.convertToBitcoinURI(goodAddress, parseCoin("1000"), null, null));
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?amount=1000", UlordURI.convertToBitcoinURI(goodAddress, parseCoin("1000"), "", ""));
    
    // no amount, label present, no message
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?label=Hello", UlordURI.convertToBitcoinURI(goodAddress, null, "Hello", null));
    
    // no amount, no label, message present
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?message=Agatha", UlordURI.convertToBitcoinURI(goodAddress, null, null, "Agatha"));
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS + "?message=Agatha", UlordURI.convertToBitcoinURI(goodAddress, null, "", "Agatha"));
  
    // no amount, no label, no message
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS, UlordURI.convertToBitcoinURI(goodAddress, null, null, null));
    assertEquals("ulord:" + MAINNET_GOOD_ADDRESS, UlordURI.convertToBitcoinURI(goodAddress, null, "", ""));
    // different scheme
    final NetworkParameters alternativeParameters = new MainNetParams() {
        @Override
        public String getUriScheme() {
            return "test";
        }
    };
    assertEquals("test:" + MAINNET_GOOD_ADDRESS + "?amount=12.34&label=Hello&message=AMessage",
         UlordURI.convertToBitcoinURI(LegacyAddress.fromBase58(alternativeParameters, MAINNET_GOOD_ADDRESS), parseCoin("12.34"), "Hello", "AMessage"));
}