package org.jboss.windup.reporting;

import java.io.File;

import org.junit.Assert;
import org.junit.Test;

public class ReportUtilTests {
	@Test
	public void testCalculateRelativePathToRoot_Simple() {
		String relativePathToRoot = ReportUtil.calculateRelativePathToRoot(
				new File("C:\\Users\\Foo\\Desktop\\temp\\WAS-EAR-doc\\"),
				new File("C:\\Users\\Foo\\Desktop\\temp\\WAS-EAR-doc\\WAS-EAR\\.settings\\org.eclipse.wst.common.project.facet.core.xml.html"));
		
		Assert.assertEquals("../../", relativePathToRoot);
	}
	
	@Test
	public void testCalculateRelativePathFromRoot_Simple() {
		String relativePathToRoot = ReportUtil.calculateRelativePathFromRoot(
				new File("C:\\Users\\Foo\\Desktop\\temp\\WAS-EAR-doc\\"),
				new File("C:\\Users\\Foo\\Desktop\\temp\\WAS-EAR-doc\\WAS-EAR\\.settings\\org.eclipse.wst.common.project.facet.core.xml.html"));
		
		Assert.assertEquals("WAS-EAR/.settings/org.eclipse.wst.common.project.facet.core.xml.html", relativePathToRoot);
	}
	
	@Test
	public void testCalculateRelativePathToRoot_Elipses0() {
		String relativePathToRoot = ReportUtil.calculateRelativePathToRoot(
				new File("C:\\Users\\Foo\\Desktop\\temp\\windup-cli-0.7.0\\..\\WAS-EAR-doc\\"),
				new File("C:\\Users\\Foo\\Desktop\\temp\\WAS-EAR-doc\\WAS-EAR\\.settings\\org.eclipse.wst.common.project.facet.core.xml.html"));
		
		Assert.assertEquals("../../", relativePathToRoot);
	}
	
	@Test
	public void testCalculateRelativePathFromRoot_Elipses0() {
		String relativePathToRoot = ReportUtil.calculateRelativePathFromRoot(
				new File("C:\\Users\\Foo\\Desktop\\temp\\windup-cli-0.7.0\\..\\WAS-EAR-doc\\"),
				new File("C:\\Users\\Foo\\Desktop\\temp\\WAS-EAR-doc\\WAS-EAR\\.settings\\org.eclipse.wst.common.project.facet.core.xml.html"));
		
		Assert.assertEquals("WAS-EAR/.settings/org.eclipse.wst.common.project.facet.core.xml.html", relativePathToRoot);
	}
}
@@ -132,16 +132,104 @@
 Tests %7B%0A
+    %0A    private static final String TMP_PATH = %22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5C%22;%0A    %0A
 %09@Test%0A%09
@@ -370,102 +370,62 @@
 ile(
-%22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5CWAS-EAR-doc%5C%5C%22),%0A%09%09%09%09new File(%22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5C
+TMP_PATH + %22WAS-EAR-doc%5C%5C%22),%0A%09%09%09%09new File(TMP_PATH + %22
 WAS-
@@ -723,102 +723,62 @@
 ile(
-%22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5CWAS-EAR-doc%5C%5C%22),%0A%09%09%09%09new File(%22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5C
+TMP_PATH + %22WAS-EAR-doc%5C%5C%22),%0A%09%09%09%09new File(TMP_PATH + %22
 WAS-
@@ -1136,40 +1136,20 @@
 ile(
-%22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5C
+TMP_PATH + %22
 wind
@@ -1200,40 +1200,20 @@
 ile(
-%22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5C
+TMP_PATH + %22
 WAS-
@@ -1513,40 +1513,20 @@
 ile(
-%22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5C
+TMP_PATH + %22
 wind
@@ -1577,40 +1577,20 @@
 ile(
-%22C:%5C%5CUsers%5C%5CFoo%5C%5CDesktop%5C%5Ctemp%5C%5C
+TMP_PATH + %22
 WAS-

Refactor path a bit