Constants { public static String webViewLocation(Parameters parameters) { if (isExternalUi(parameters)) { return "http: } URL selfUri = checkNotNull(Constants.class.getResource(Constants.class.getSimpleName() + ".class")); String protocol = selfUri.getProtocol(); if ("file".equals(protocol)) { String path = selfUri.getPath(); checkState(path.contains("target/classes")); String rootPath = path.substring(0, path.indexOf("target/classes")); File file = new File(rootPath); String localPath = file.getParentFile().getPath() + "/ui/dist/index.html"; return "file: } else if ("jar".equals(protocol)) { String path = selfUri.getPath(); Matcher matcher = Pattern.compile("(.*?/)([^/]+\\.jar!).*").matcher(path); checkState(matcher.matches(), "%s", path); String prefix = matcher.group(1); return prefix + "web-assets/index.html"; } else { throw new IllegalStateException(selfUri.toString()); } }  static boolean isExternalUi(Parameters parameters); static String webViewLocation(Parameters parameters); static final int DEFAULT_HEIGHT; static final int DEFAULT_WIDTH; static final Color DEFAULT_FILL_COLOUR; static final Object PARAM_EXTERNAL_UI; }
@Test public void webViewLocationWithParameter() { unnamed.add("-XexternalUI"); assertEquals("http: }
@Test public void webViewLocation() { File base = new File(".").getAbsoluteFile().getParentFile().getParentFile(); assertEquals("file: }