// Path: src/main/java/org/commonwl/view/git/GitDetails.java
// public static String normaliseUrl(String url) {
//     return url.replace("http://", "")
//               .replace("https://", "")
//               .replace("ssh://", "")
//               .replace("git://", "")
//               .replace("www.", "");
// }


import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import static org.commonwl.view.git.GitDetails.normaliseUrl;
    /**
     * Construct the internal link to a workflow from Git details
     */
    @Test
    public void getInternalUrl() throws Exception {
        assertEquals("/workflows/github.com/owner/repoName/blob/branch/path/within/structure.cwl", GITHUB_DETAILS.getInternalUrl());
        assertEquals("/workflows/gitlab.com/owner/repoName/blob/branch/path/within/structure.cwl", GITLAB_DETAILS.getInternalUrl());
        assertEquals("/workflows/bitbucket.org/owner/repoName.git/branch/path/within/structure.cwl", BITBUCKET_DETAILS.getInternalUrl());
        assertEquals("/workflows/could.com/be/anything.git/branch/path/within/structure.cwl", GENERIC_DETAILS.getInternalUrl());
        assertEquals("/workflows/could.com/be/anything.git/branch/path/within/structure/packed.cwl#testId", PACKED_DETAILS.getInternalUrl());
    }

    /**
     * Construct the raw URL to a workflow file from Git details
     */
    @Test
    public void getRawUrl() throws Exception {
        assertEquals("https://raw.githubusercontent.com/owner/repoName/branch/path/within/structure.cwl", GITHUB_DETAILS.getRawUrl());
        assertEquals("https://gitlab.com/owner/repoName/raw/branch/path/within/structure.cwl", GITLAB_DETAILS.getRawUrl());
        assertEquals("https://bitbucket.org/owner/repoName/raw/branch/path/within/structure.cwl", BITBUCKET_DETAILS.getRawUrl());

        // No raw URL for generic git repo
        assertEquals("https://could.com/be/anything.git", GENERIC_DETAILS.getRawUrl());
    }

    /**
     * Normalise a URL removing protocol and www.
     */
    @Test
    public void getNormaliseUrl() throws Exception {
// Path: src/main/java/org/commonwl/view/git/GitDetails.java
// public static String normaliseUrl(String url) {
//     return url.replace("http://", "")
//               .replace("https://", "")
//               .replace("ssh://", "")
//               .replace("git://", "")
//               .replace("www.", "");
// }


// Path: src/test/java/org/commonwl/view/git/GitDetailsTest.java
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import static org.commonwl.view.git.GitDetails.normaliseUrl;

    /**
     * Construct the internal link to a workflow from Git details
     */
    @Test
    public void getInternalUrl() throws Exception {
        assertEquals("/workflows/github.com/owner/repoName/blob/branch/path/within/structure.cwl", GITHUB_DETAILS.getInternalUrl());
        assertEquals("/workflows/gitlab.com/owner/repoName/blob/branch/path/within/structure.cwl", GITLAB_DETAILS.getInternalUrl());
        assertEquals("/workflows/bitbucket.org/owner/repoName.git/branch/path/within/structure.cwl", BITBUCKET_DETAILS.getInternalUrl());
        assertEquals("/workflows/could.com/be/anything.git/branch/path/within/structure.cwl", GENERIC_DETAILS.getInternalUrl());
        assertEquals("/workflows/could.com/be/anything.git/branch/path/within/structure/packed.cwl#testId", PACKED_DETAILS.getInternalUrl());
    }

    /**
     * Construct the raw URL to a workflow file from Git details
     */
    @Test
    public void getRawUrl() throws Exception {
        assertEquals("https://raw.githubusercontent.com/owner/repoName/branch/path/within/structure.cwl", GITHUB_DETAILS.getRawUrl());
        assertEquals("https://gitlab.com/owner/repoName/raw/branch/path/within/structure.cwl", GITLAB_DETAILS.getRawUrl());
        assertEquals("https://bitbucket.org/owner/repoName/raw/branch/path/within/structure.cwl", BITBUCKET_DETAILS.getRawUrl());

        // No raw URL for generic git repo
        assertEquals("https://could.com/be/anything.git", GENERIC_DETAILS.getRawUrl());
    }

    /**
     * Normalise a URL removing protocol and www.
     */
    @Test
    public void getNormaliseUrl() throws Exception {
        assertEquals("github.com/test/url/here", normaliseUrl("https://www.github.com/test/url/here"));