/**
   * Tests conversion to Feathercoin URI
   *
   * @throws FeathercoinURIParseException If something goes wrong
   * @throws AddressFormatException
   */
  @Test
  public void testConvertToFeathercoinURI() throws Exception {
    Address goodAddress = new Address(NetworkParameters.prodNet(), PRODNET_GOOD_ADDRESS);

    // simple example
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?amount=12.34&label=Hello&message=AMessage",
        FeathercoinURI.convertToFeathercoinURI(
            goodAddress, Utils.toNanoCoins("12.34"), "Hello", "AMessage"));

    // example with spaces, ampersand and plus
    assertEquals(
        "feathercoin:"
            + PRODNET_GOOD_ADDRESS
            + "?amount=12.34&label=Hello%20World&message=Mess%20%26%20age%20%2B%20hope",
        FeathercoinURI.convertToFeathercoinURI(
            goodAddress, Utils.toNanoCoins("12.34"), "Hello World", "Mess & age + hope"));

    // amount negative
    try {
      FeathercoinURI.convertToFeathercoinURI(
          goodAddress, Utils.toNanoCoins("-0.1"), "hope", "glory");
      fail("Expecting IllegalArgumentException");
    } catch (IllegalArgumentException e) {
      assertTrue(e.getMessage().contains("Amount must be positive"));
    }

    // no amount, label present, message present
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?label=Hello&message=glory",
        FeathercoinURI.convertToFeathercoinURI(goodAddress, null, "Hello", "glory"));

    // amount present, no label, message present
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?amount=0.1&message=glory",
        FeathercoinURI.convertToFeathercoinURI(
            goodAddress, Utils.toNanoCoins("0.1"), null, "glory"));
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?amount=0.1&message=glory",
        FeathercoinURI.convertToFeathercoinURI(goodAddress, Utils.toNanoCoins("0.1"), "", "glory"));

    // amount present, label present, no message
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?amount=12.34&label=Hello",
        FeathercoinURI.convertToFeathercoinURI(
            goodAddress, Utils.toNanoCoins("12.34"), "Hello", null));
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?amount=12.34&label=Hello",
        FeathercoinURI.convertToFeathercoinURI(
            goodAddress, Utils.toNanoCoins("12.34"), "Hello", ""));

    // amount present, no label, no message
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?amount=1000",
        FeathercoinURI.convertToFeathercoinURI(goodAddress, Utils.toNanoCoins("1000"), null, null));
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?amount=1000",
        FeathercoinURI.convertToFeathercoinURI(goodAddress, Utils.toNanoCoins("1000"), "", ""));

    // no amount, label present, no message
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?label=Hello",
        FeathercoinURI.convertToFeathercoinURI(goodAddress, null, "Hello", null));

    // no amount, no label, message present
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?message=Agatha",
        FeathercoinURI.convertToFeathercoinURI(goodAddress, null, null, "Agatha"));
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS + "?message=Agatha",
        FeathercoinURI.convertToFeathercoinURI(goodAddress, null, "", "Agatha"));

    // no amount, no label, no message
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS,
        FeathercoinURI.convertToFeathercoinURI(goodAddress, null, null, null));
    assertEquals(
        "feathercoin:" + PRODNET_GOOD_ADDRESS,
        FeathercoinURI.convertToFeathercoinURI(goodAddress, null, "", ""));
  }