### Question:
DiscoveryFilter implements Filter { AccountIdentifier extractFromInput(final String decodedUserInput) throws URISyntaxException { if (decodedUserInput == null || decodedUserInput.isEmpty()) { throw new IllegalArgumentException("Invalid input"); } final URI uri; String normalizedIdentifier = decodedUserInput; if (decodedUserInput.startsWith("acct:") || decodedUserInput.contains("@")) { if (!decodedUserInput.startsWith("acct:")) { normalizedIdentifier = "acct:" + decodedUserInput; } if (decodedUserInput.lastIndexOf("@") > decodedUserInput.indexOf("@") + 1) { uri = new URI("https: decodedUserInput.length()))); } else { uri = new URI(normalizedIdentifier.replace("acct:", "acct: } } else { uri = new URI(decodedUserInput); if (decodedUserInput.contains("#")) { normalizedIdentifier = decodedUserInput.substring(0, decodedUserInput.indexOf("#")); } } final int port = uri.getPort(); final String host = uri.getHost(); return new AccountIdentifier(new URI(normalizedIdentifier), new URI("http".equals(uri.getScheme()) ? "http" : "https", null, host, port, "/", null, null)); } DiscoveryFilter(final Handler handler, final Heap heap); @Override Promise<Response, NeverThrowsException> filter(Context context,
                                                          Request request,
                                                          Handler next);  }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void shouldFailWhenInputIsNull() throws Exception { final DiscoveryFilter df = new DiscoveryFilter(handler, heap); df.extractFromInput(null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void shouldFailWhenInputIsEmpty() throws Exception { final DiscoveryFilter df = new DiscoveryFilter(handler, heap); df.extractFromInput(""); }
@Test(expectedExceptions = URISyntaxException.class) public void shouldFailWhenInputIsInvalid() throws Exception { final DiscoveryFilter df = new DiscoveryFilter(handler, heap); df.extractFromInput("+: }
@Test(dataProvider = "givenInputAndNormalizedIdentifierExtracted") public void shouldExtractParameters(final String input, final String expected) throws Exception { final DiscoveryFilter df = new DiscoveryFilter(handler, heap); final AccountIdentifier account = df.extractFromInput(formDecodeParameterNameOrValue(input)); assertThat(account.getNormalizedIdentifier().toString()).isEqualTo(expected); }