@Test public void test_getFullSourcePath_relative() throws Exception { final URL mockUrl = new URL("file:/D:/repos/git/ops/ops-ext4/target/jasmine/SpecRunner.html"); when(htmlPage.getUrl()).thenReturn(mockUrl); final String sourceName = "src/app/utils/FieldLayout.js?_dc=1351820085178"; final String fullSourcePath = MiscUtil.getFullSourcePath(htmlPage, sourceName); if (File.separatorChar == '/') { assertThat(fullSourcePath, equalTo("/D:/repos/git/ops/ops-ext4/target/jasmine/src/app/utils/FieldLayout.js")); } else { assertThat(fullSourcePath, equalTo("D:\\repos\\git\\ops\\ops-ext4\\target\\jasmine\\src\\app\\utils\\FieldLayout.js")); } }
public static String getFullSourcePath(final HtmlPage htmlPage, final String sourceName) { try { final URI sourceUri = URI.create(sourceName.replaceAll(" ", "%20")); if (sourceUri.isAbsolute()) { return new File(URI.create(sourceUri.getScheme() + ": } final URI uri = htmlPage.getUrl().toURI(); final URI pageUriWithoutQuery = URI.create(uri.getScheme() + ": return new File(new File(pageUriWithoutQuery).getParent(), URI.create(sourceName).getPath()).getAbsolutePath(); } catch (final Exception e) { throw new RuntimeException("Error getting full path for " + sourceName + " at " + htmlPage.getUrl(), e); } }
MiscUtil { public static String getFullSourcePath(final HtmlPage htmlPage, final String sourceName) { try { final URI sourceUri = URI.create(sourceName.replaceAll(" ", "%20")); if (sourceUri.isAbsolute()) { return new File(URI.create(sourceUri.getScheme() + ": } final URI uri = htmlPage.getUrl().toURI(); final URI pageUriWithoutQuery = URI.create(uri.getScheme() + ": return new File(new File(pageUriWithoutQuery).getParent(), URI.create(sourceName).getPath()).getAbsolutePath(); } catch (final Exception e) { throw new RuntimeException("Error getting full path for " + sourceName + " at " + htmlPage.getUrl(), e); } } }
MiscUtil { public static String getFullSourcePath(final HtmlPage htmlPage, final String sourceName) { try { final URI sourceUri = URI.create(sourceName.replaceAll(" ", "%20")); if (sourceUri.isAbsolute()) { return new File(URI.create(sourceUri.getScheme() + ": } final URI uri = htmlPage.getUrl().toURI(); final URI pageUriWithoutQuery = URI.create(uri.getScheme() + ": return new File(new File(pageUriWithoutQuery).getParent(), URI.create(sourceName).getPath()).getAbsolutePath(); } catch (final Exception e) { throw new RuntimeException("Error getting full path for " + sourceName + " at " + htmlPage.getUrl(), e); } } private  MiscUtil(); }
MiscUtil { public static String getFullSourcePath(final HtmlPage htmlPage, final String sourceName) { try { final URI sourceUri = URI.create(sourceName.replaceAll(" ", "%20")); if (sourceUri.isAbsolute()) { return new File(URI.create(sourceUri.getScheme() + ": } final URI uri = htmlPage.getUrl().toURI(); final URI pageUriWithoutQuery = URI.create(uri.getScheme() + ": return new File(new File(pageUriWithoutQuery).getParent(), URI.create(sourceName).getPath()).getAbsolutePath(); } catch (final Exception e) { throw new RuntimeException("Error getting full path for " + sourceName + " at " + htmlPage.getUrl(), e); } } private  MiscUtil(); static int toCoverage(final int totalStatements, final int totalExecuted); static double toCoverageRate(final int totalStatements, final int totalExecuted); static int sum(final Iterable<T> objects, final Function<T, Integer> transformer); static String getColor(final int coverage); static int getColorAsArgb(final int coverage); static String getFullSourcePath(final HtmlPage htmlPage, final String sourceName); }
MiscUtil { public static String getFullSourcePath(final HtmlPage htmlPage, final String sourceName) { try { final URI sourceUri = URI.create(sourceName.replaceAll(" ", "%20")); if (sourceUri.isAbsolute()) { return new File(URI.create(sourceUri.getScheme() + ": } final URI uri = htmlPage.getUrl().toURI(); final URI pageUriWithoutQuery = URI.create(uri.getScheme() + ": return new File(new File(pageUriWithoutQuery).getParent(), URI.create(sourceName).getPath()).getAbsolutePath(); } catch (final Exception e) { throw new RuntimeException("Error getting full path for " + sourceName + " at " + htmlPage.getUrl(), e); } } private  MiscUtil(); static int toCoverage(final int totalStatements, final int totalExecuted); static double toCoverageRate(final int totalStatements, final int totalExecuted); static int sum(final Iterable<T> objects, final Function<T, Integer> transformer); static String getColor(final int coverage); static int getColorAsArgb(final int coverage); static String getFullSourcePath(final HtmlPage htmlPage, final String sourceName);  }