package com.blackducksoftware.integration.hub.rest;

import static org.junit.Assert.assertEquals;

import java.net.URISyntaxException;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class RestConnectionTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Test
	public void testGetBaseUrlWithPort() throws URISyntaxException {
		final String urlPrefix = "https://hub.bds.com:8080/";
		final String projectVersionRelativeUrl = "api/projects/1234/versions/5678";
		final String projectVersionUrl = urlPrefix + projectVersionRelativeUrl;

		assertEquals(urlPrefix, RestConnection.getBaseUrl(projectVersionUrl));
	}

	@Test
	public void testGetBaseUrlWithoutPort() throws URISyntaxException {
		final String urlPrefix = "https://hub.bds.com/";
		final String projectVersionRelativeUrl = "api/projects/1234/versions/5678";
		final String projectVersionUrl = urlPrefix + projectVersionRelativeUrl;

		assertEquals(urlPrefix, RestConnection.getBaseUrl(projectVersionUrl));
	}

	@Test
	public void testGetRelativeUrl() throws URISyntaxException {
		final String urlPrefix = "https://hub.bds.com:8080/";
		final String projectVersionRelativeUrl = "api/projects/1234/versions/5678";
		final String projectVersionUrl = urlPrefix + projectVersionRelativeUrl;

		assertEquals(projectVersionRelativeUrl, RestConnection.getRelativeUrl(projectVersionUrl));
	}

	@Test
	public void testGetRelativeUrlTrailingSlashNormalization() throws URISyntaxException {
		final String urlPrefix = "https://hub.bds.com:8080/";
		final String projectVersionRelativeUrl = "api/projects/1234/versions/5678" + "/";
		final String projectVersionUrl = urlPrefix + projectVersionRelativeUrl;

		assertEquals(projectVersionRelativeUrl, RestConnection.getRelativeUrl(projectVersionUrl));
	}
}

@@ -212,16 +212,81 @@
 .Test;%0A%0A
+import com.blackducksoftware.integration.hub.util.HubUrlParser;%0A%0A
 public c
@@ -769,38 +769,36 @@
 (urlPrefix, 
-RestConnection
+HubUrlParser
 .getBaseUrl(
@@ -1128,30 +1128,28 @@
 Prefix, 
-RestConnection
+HubUrlParser
 .getBase
@@ -1493,38 +1493,36 @@
 elativeUrl, 
-RestConnection
+HubUrlParser
 .getRelative
@@ -1902,30 +1902,28 @@
 iveUrl, 
-RestConnection
+HubUrlParser
 .getRela

Fix test