UriResolverImpl implements UriResolver { @Override public String resolve(String uri) { final URI resolved; if (PIDUtils.isHandle(uri)) { resolved = resolve(handleClient, HANDLE_PREFIX + PIDUtils.getSchemeSpecificId(uri)); } else if (PIDUtils.isDoi(uri)) { resolved = resolve(doiClient, DOI_PREFIX + PIDUtils.getSchemeSpecificId(uri)); } else { resolved = null; } return (resolved != null) ? resolved.toString() : uri; } UriResolverImpl(PIDResolver handleClient, PIDResolver doiClient); @Override boolean canResolve(String uri); @Override String resolve(String uri);  }
@Test public void testResolveNonHandle() { String result = instance.resolve("http: assertEquals("http: }
@Test public void testResolveHandleScheme() throws InvalidHandleException { context.checking(new Expectations() { { oneOf(handleClient).resolve(URI.create("hdl:1234/5678")); will(returnValue(URI.create("http: } }); String result = instance.resolve("hdl:1234/5678"); assertEquals("http: }
@Test public void testResolveHandleProxy() throws InvalidHandleException { context.checking(new Expectations() { { oneOf(handleClient).resolve(URI.create("hdl:1234/5678")); will(returnValue(URI.create("http: } }); String result = instance.resolve("http: assertEquals("http: }
@Test public void testResolveDoiScheme() throws InvalidHandleException { context.checking(new Expectations() { { oneOf(doiClient).resolve(URI.create("doi:1234/5678")); will(returnValue(URI.create("http: } }); String result = instance.resolve("doi:1234/5678"); assertEquals("http: }
@Test public void testResolveDoiUrl() throws InvalidHandleException { context.checking(new Expectations() { { oneOf(doiClient).resolve(URI.create("doi:1234/5678")); will(returnValue(URI.create("http: } }); String result = instance.resolve("https: assertEquals("http: }