package uk.gov.openregister.linking;

import org.junit.Test;

import java.net.URI;

import static org.fest.assertions.Assertions.assertThat;

public class CurieResolverTest {
    @Test
    public void shouldResolveCurieBasedOnTemplate() throws Exception {
        CurieResolver resolver = new CurieResolver("http://__REGISTER__.register.elbonia");

        URI widgetUri = resolver.resolve(new Curie("widget", "1234"));

        assertThat(widgetUri).isEqualTo(URI.create("http://widget.register.elbonia/widget/1234"));
    }

    @Test
    public void shouldResolveCurieBasedOnTemplateWithExplicitPort() throws Exception {
        CurieResolver resolver = new CurieResolver("http://__REGISTER__.register.elbonia:5555");

        URI widgetUri = resolver.resolve(new Curie("widget", "1234"));

        assertThat(widgetUri).isEqualTo(URI.create("http://widget.register.elbonia:5555/widget/1234"));
    }

}

@@ -898,10 +898,367 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void shouldEscapeSpacesInCurieValue() throws Exception %7B%0A        CurieResolver resolver = new CurieResolver(%22http://__REGISTER__.register.elbonia%22);%0A%0A        URI widgetUri = resolver.resolve(new Curie(%22widget%22, %22ABC DEF%22));%0A%0A        assertThat(widgetUri).isEqualTo(URI.create(%22http://widget.register.elbonia/widget/ABC%2520DEF%22));%0A    %7D%0A%0A
 %7D%0A

test that we escape spaces from curies properly