Example #1
0
  private ContentEntry getContentRoot(String moduleName) {
    ContentEntry[] ee = getContentRoots(moduleName);
    List<String> roots = new ArrayList<String>();
    for (ContentEntry e : ee) {
      roots.add(e.getUrl());
    }

    String message = "Several content roots found: [" + StringUtil.join(roots, ", ") + "]";
    assertEquals(message, 1, ee.length);

    return ee[0];
  }
Example #2
0
  protected void assertContentRoots(String moduleName, String... expectedRoots) {
    List<String> actual = new ArrayList<String>();
    for (ContentEntry e : getContentRoots(moduleName)) {
      actual.add(e.getUrl());
    }

    for (int i = 0; i < expectedRoots.length; i++) {
      expectedRoots[i] = VfsUtil.pathToUrl(expectedRoots[i]);
    }

    assertUnorderedPathsAreEqual(actual, Arrays.asList(expectedRoots));
  }
Example #3
0
 protected void assertGeneratedSources(String moduleName, String... expectedSources) {
   ContentEntry contentRoot = getContentRoot(moduleName);
   List<ContentFolder> folders = new ArrayList<ContentFolder>();
   for (SourceFolder folder : contentRoot.getSourceFolders(JavaSourceRootType.SOURCE)) {
     JavaSourceRootProperties properties =
         folder.getJpsElement().getProperties(JavaSourceRootType.SOURCE);
     assertNotNull(properties);
     if (properties.isForGeneratedSources()) {
       folders.add(folder);
     }
   }
   doAssertContentFolders(contentRoot, folders, expectedSources);
 }
 private static void excludeDirFromContent(
     ContentEntry content, VirtualFile root, String excludeDir) {
   VirtualFile excludeDirFile = root.findChild(excludeDir);
   if (excludeDirFile != null) {
     content.addExcludeFolder(excludeDirFile);
   }
 }
 private static void addSourceDirToContent(
     @NotNull ContentEntry content,
     @NotNull VirtualFile root,
     @NotNull String sourceDir,
     boolean test) {
   VirtualFile sourceDirFile = root.findChild(sourceDir);
   if (sourceDirFile != null) {
     content.addSourceFolder(sourceDirFile, test);
   }
 }
Example #6
0
  private static void doAssertContentFolders(
      ContentEntry e, final List<? extends ContentFolder> folders, String... expected) {
    List<String> actual = new ArrayList<String>();
    for (ContentFolder f : folders) {
      String rootUrl = e.getUrl();
      String folderUrl = f.getUrl();

      if (folderUrl.startsWith(rootUrl)) {
        int length = rootUrl.length() + 1;
        folderUrl = folderUrl.substring(Math.min(length, folderUrl.length()));
      }

      actual.add(folderUrl);
    }

    assertOrderedElementsAreEqual(actual, Arrays.asList(expected));
  }
Example #7
0
 private ContentEntry getContentRoot(String moduleName, String path) {
   for (ContentEntry e : getContentRoots(moduleName)) {
     if (e.getUrl().equals(VfsUtil.pathToUrl(path))) return e;
   }
   throw new AssertionError("content root not found");
 }
Example #8
0
 private void doAssertContentFolders(
     String moduleName, @NotNull JpsModuleSourceRootType<?> rootType, String... expected) {
   ContentEntry contentRoot = getContentRoot(moduleName);
   doAssertContentFolders(contentRoot, contentRoot.getSourceFolders(rootType), expected);
 }
Example #9
0
 protected void assertContentRootExcludes(
     String moduleName, String contentRoot, String... expectedExcudes) {
   ContentEntry root = getContentRoot(moduleName, contentRoot);
   doAssertContentFolders(root, Arrays.asList(root.getExcludeFolders()), expectedExcudes);
 }