package uk.gov.register.core;

import org.junit.Test;

import java.net.URI;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;

public class UriTemplateLinkResolverTest {

    private final UriTemplateLinkResolver localResolver = new UriTemplateLinkResolver(register -> URI.create("http://" + register + ".openregister.dev:8080"));
    private final UriTemplateLinkResolver prodResolver = new UriTemplateLinkResolver(register -> URI.create("https://" + register + ".register.gov.uk"));

    @Test
    public void linkValueReturnsLink() {
        LinkValue linkValue = new LinkValue(new RegisterName("address"), "1111112");

        assertThat(localResolver.resolve(linkValue), is(URI.create("http://address.openregister.dev:8080/record/1111112")));
        assertThat(prodResolver.resolve(linkValue), is(URI.create("https://address.register.gov.uk/record/1111112")));
    }

    @Test
    public void curieValueReturnsCorrectLink() {
        LinkValue.CurieValue charityCurieValue = new LinkValue.CurieValue("charity:123456");
        LinkValue.CurieValue companyCurieValue = new LinkValue.CurieValue("company:654321");

        assertThat(localResolver.resolve(charityCurieValue), is(URI.create("http://charity.openregister.dev:8080/record/123456")));
        assertThat(localResolver.resolve(companyCurieValue), is(URI.create("http://company.openregister.dev:8080/record/654321")));
    }

    @Test
    public void separateRegisterAndValueReturnsCorrectLink() throws Exception {
        assertThat(localResolver.resolve(new RegisterName("country"),"CZ"), is(URI.create("http://country.openregister.dev:8080/record/CZ")));
    }
}

@@ -883,32 +883,347 @@
 112%22)));%0A    %7D%0A%0A
+    @Test%0A    public void urlValueReturnsLink() %7B%0A        UrlValue urlValue = new UrlValue(%22http://www.example.com%22);%0A%0A        assertThat(localResolver.resolve(urlValue), is(URI.create(%22http://www.example.com%22)));%0A        assertThat(prodResolver.resolve(urlValue), is(URI.create(%22http://www.example.com%22)));%0A    %7D%0A%0A
     @Test%0A    pu

add test