ReferenceResolver { public static URI resolve(final URI parentScope, final String encounteredSegment) { try { return new URI(resolve(parentScope == null ? null : parentScope.toString(), encounteredSegment)); } catch (URISyntaxException e) { throw new RuntimeException(e); } } private  ReferenceResolver(); static URI resolve(final URI parentScope, final String encounteredSegment); static String resolve(String parentScope, final String encounteredSegment);  }
@Test public void test() { String actual = ReferenceResolver.resolve(parentScope, encounteredSegment); assertEquals(expectedOutput, actual); }
@Test public void testURI() { URI parentScopeURI; try { parentScopeURI = new URI(parentScope); } catch (URISyntaxException | NullPointerException e) { parentScopeURI = null; } URI actual = ReferenceResolver.resolve(parentScopeURI, encounteredSegment); }
@Test public void resolveWrapsURISyntaxException() { try { ReferenceResolver.resolve("\\\\somethin\010g invalid fail("did not throw exception for invalid URI"); } catch (RuntimeException e) { assertEquals(URISyntaxException.class, e.getCause().getClass()); } }
@Test public void resolveURIWrapsURISyntaxException() throws Exception { try { ReferenceResolver.resolve(new URI("http: fail("did not throw exception for invalid URI"); } catch (RuntimeException e) { assertEquals(URISyntaxException.class, e.getCause().getClass()); } }