Registry { public Link asLinkFor(final URI baseUri) { final URI uri; if (baseUri.toString().endsWith("/")) { uri = baseUri.resolve("registries/" + name); } else { uri = URI.create(baseUri.toString() + "/registries/" + name); } return new Link( uri, title ); } Registry(final String name, final String title, final List<Link> links); String getName(); String getTitle(); Collection<Link> getAll(); Link findByHref(final URI href); Link asLinkFor(final URI baseUri);  }
@Test public void shouldReturnLinkForSimpleBaseUri() { final Registry registry = new Registry("foo", "Registry Foo", Collections.<Link>emptyList()); assertEquals( registry.asLinkFor(create("http: new Link(create("http: }
@Test public void shouldReturnLinkForBaseUriWithContext() { final Registry registry = new Registry("foo", "Registry Foo", Collections.<Link>emptyList()); assertEquals( registry.asLinkFor(create("http: new Link(create("http: }
@Test public void shouldReturnLinkForSimpleBaseUriWithTrailingSlash() { final Registry registry = new Registry("foo", "Registry Foo", Collections.<Link>emptyList()); assertEquals( registry.asLinkFor(create("http: new Link(create("http: }
@Test public void shouldReturnLinkForBaseUriWithContextAndTrailingSlash() { final Registry registry = new Registry("foo", "Registry Foo", Collections.<Link>emptyList()); assertEquals( registry.asLinkFor(create("http: new Link(create("http: }