### Question:
OAuth2Utils { public static URI appendQuery(final URI uri, final Form query) { Reject.ifNull(uri); if (query == null || query.isEmpty()) { return uri; } if (uri.getRawQuery() != null) { query.fromQueryString(uri.getRawQuery()); } try { return create(uri.getScheme(), uri.getRawUserInfo(), uri.getHost(), uri.getPort(), uri.getRawPath(), query.toQueryString(), uri.getRawFragment()); } catch (final URISyntaxException e) { throw new IllegalStateException(e); } } private  OAuth2Utils(); static URI appendQuery(final URI uri, final Form query);  }### Answer:
@Test public void shouldAppendQuery() throws URISyntaxException { final URI uri = new URI("http: final URI uriWithoutParam = new URI("http: assertThat(appendQuery(uri, new Form().fromFormString("name=IG&id=42")).getQuery()) .contains("p=1", "n=2", "name=IG", "id=42"); assertThat(appendQuery(uri, null)).isEqualTo(uri); assertThat(appendQuery(uri, new Form())).isEqualTo(uri); assertThat(appendQuery(uriWithoutParam, null)).isEqualTo(uriWithoutParam); assertThat(appendQuery(uriWithoutParam, new Form().fromFormString("name=IG&id=42")).getQuery()) .contains("name=IG", "id=42"); }
@Test(expectedExceptions = NullPointerException.class) public void shouldFailToAppendQueryToNullURI() { appendQuery(null, new Form()); }