### Question:
LnurlDecoder { public static String decode(String lnurl) throws NoLnUrlDataException { if (lnurl == null) { throw new NoLnUrlDataException("LNURL decoding failed: The data to decode is not a LNURL"); } lnurl = UriUtil.removeURI(lnurl); if (lnurl.length() < 5 || !lnurl.substring(0, 5).toLowerCase().equals("lnurl")) { throw new NoLnUrlDataException("LNURL decoding failed: The data to decode is not a LNURL"); } String decodedLnurl = null; try { byte[] decodedBech32 = Bech32.bech32Decode(lnurl, false).second; byte[] regroupedBytes = Bech32.regroupBytes(decodedBech32); decodedLnurl = new String(regroupedBytes); } catch (Exception e) { throw new IllegalArgumentException("LNURL decoding failed: " + e.getMessage()); } return decodedLnurl; }  static String decode(String lnurl);  }### Answer:
@Test public void givenValidLnurl_WhenDecode_ThenReturnDecoded() throws LnurlDecoder.NoLnUrlDataException { assertEquals(LNURL_PAY_DECODED, LnurlDecoder.decode(LNURL_PAY)); assertEquals(LNURL_PAY_DECODED, LnurlDecoder.decode(LNURL_PAY_WITH_URI)); assertEquals(LNURL_WITHDRAW_DECODED, LnurlDecoder.decode(LNURL_WITHDRAW)); assertEquals("test", LnurlDecoder.decode(LNURL_TEST)); }
@Test public void givenInvalidLnurl_WhenDecode_ThenReturnError() { try { String decoded = LnurlDecoder.decode(null); } catch (IllegalArgumentException e) { assert false; } catch (LnurlDecoder.NoLnUrlDataException e) { assert true; } try { String decoded = LnurlDecoder.decode(INVALID_LNURL_INVALID_PREFIX); assertNull(decoded); } catch (IllegalArgumentException e) { assert false; } catch (LnurlDecoder.NoLnUrlDataException e) { assert true; } try { String decoded = LnurlDecoder.decode(INVALID_LNURL_MIXED_CASE); assertNull(decoded); } catch (Exception e) { assertEquals(e.getMessage(), "LNURL decoding failed: bech32 cannot mix upper and lower case"); } try { String decoded = LnurlDecoder.decode(INVALID_LNURL_WRONG_CHECKSUM); assertNull(decoded); } catch (Exception e) { assertEquals(e.getMessage(), "LNURL decoding failed: invalid bech32 checksum"); } try { String decoded = LnurlDecoder.decode(INVALID_LNURL_WRONG_CHARACTER); assertNull(decoded); } catch (Exception e) { assertEquals(e.getMessage(), "LNURL decoding failed: bech32 characters out of range"); } }