// Path: src/main/java/de/otto/edison/hal/Link.java
// public static Link curi(final String name, final String relTemplate) {
//     if (!relTemplate.contains("{rel}")) {
//         throw new IllegalArgumentException("Not a CURI template. Template is required to contain a {rel} placeholder");
//     }
//     return new Link("curies", relTemplate, null, null, null, name, null, null);
// }
// 
// Path: src/main/java/de/otto/edison/hal/Link.java
// public static Link link(final String rel, final String href) {
//     return new Link(rel, href);
// }
// 
// Path: src/main/java/de/otto/edison/hal/Links.java
// public static Builder linkingTo() {
//     return new Builder();
// }
// 
// Path: src/main/java/de/otto/edison/hal/Curies.java
// public static Curies emptyCuries() {
//     return new Curies();
// }
// 
// Path: src/main/java/de/otto/edison/hal/Curies.java
// public static Curies curies(final Links links) {
//     List<Link> curies = links.getLinksBy("curies");
//     return curies(curies);
// }


import org.junit.Test;
import static de.otto.edison.hal.Link.curi;
import static de.otto.edison.hal.Link.link;
import static de.otto.edison.hal.Links.linkingTo;
import static de.otto.edison.hal.Curies.emptyCuries;
import static de.otto.edison.hal.Curies.curies;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
        // then
        assertThat(merged.resolve("http://spec.otto.de/rels/foo"), is("x:foo"));
    }

    @Test
    public void shouldMergeEmptyRegistryWithNonEmpty() {
        // given
        final Curies empty = emptyCuries();
        final Curies other = emptyCuries();
        other.register(curi("o", "http://spec.otto.de/rels/{rel}"));
        // when
        final Curies merged = empty.mergeWith(other);
        // then
        assertThat(empty, is(emptyCuries()));
        assertThat(merged.resolve("http://spec.otto.de/rels/foo"), is("o:foo"));
    }

    @Test
    public void shouldExpandCuri() {
        // given
        final Curies curies = Curies.curies(linkingTo().curi("x", "http://example.com/rels/{rel}").build());
        // when
        final String expanded = curies.expand("x:foo");
        // then
        assertThat(expanded, is("http://example.com/rels/foo"));
    }

    @Test
    public void shouldReturnCuriIfNotResolvable() {
        // given
// Path: src/main/java/de/otto/edison/hal/Link.java
// public static Link curi(final String name, final String relTemplate) {
//     if (!relTemplate.contains("{rel}")) {
//         throw new IllegalArgumentException("Not a CURI template. Template is required to contain a {rel} placeholder");
//     }
//     return new Link("curies", relTemplate, null, null, null, name, null, null);
// }
// 
// Path: src/main/java/de/otto/edison/hal/Link.java
// public static Link link(final String rel, final String href) {
//     return new Link(rel, href);
// }
// 
// Path: src/main/java/de/otto/edison/hal/Links.java
// public static Builder linkingTo() {
//     return new Builder();
// }
// 
// Path: src/main/java/de/otto/edison/hal/Curies.java
// public static Curies emptyCuries() {
//     return new Curies();
// }
// 
// Path: src/main/java/de/otto/edison/hal/Curies.java
// public static Curies curies(final Links links) {
//     List<Link> curies = links.getLinksBy("curies");
//     return curies(curies);
// }


// Path: src/test/java/de/otto/edison/hal/CuriesTest.java
import org.junit.Test;
import static de.otto.edison.hal.Link.curi;
import static de.otto.edison.hal.Link.link;
import static de.otto.edison.hal.Links.linkingTo;
import static de.otto.edison.hal.Curies.emptyCuries;
import static de.otto.edison.hal.Curies.curies;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

        // then
        assertThat(merged.resolve("http://spec.otto.de/rels/foo"), is("x:foo"));
    }

    @Test
    public void shouldMergeEmptyRegistryWithNonEmpty() {
        // given
        final Curies empty = emptyCuries();
        final Curies other = emptyCuries();
        other.register(curi("o", "http://spec.otto.de/rels/{rel}"));
        // when
        final Curies merged = empty.mergeWith(other);
        // then
        assertThat(empty, is(emptyCuries()));
        assertThat(merged.resolve("http://spec.otto.de/rels/foo"), is("o:foo"));
    }

    @Test
    public void shouldExpandCuri() {
        // given
        final Curies curies = Curies.curies(linkingTo().curi("x", "http://example.com/rels/{rel}").build());
        // when
        final String expanded = curies.expand("x:foo");
        // then
        assertThat(expanded, is("http://example.com/rels/foo"));
    }

    @Test
    public void shouldReturnCuriIfNotResolvable() {
        // given
        final Curies curies = emptyCuries();